cifs: obtain file access during backup intent lookup (resend)
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / cifs / smb1ops.c
index 068d609bd02afd81b80ac92c7cee18687ebb023b..56cc4be87807ae2c734b647c5c78d5480d234e7b 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include <linux/pagemap.h>
+#include <linux/vfs.h>
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
@@ -441,9 +442,6 @@ cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
                wsize = min_t(unsigned int, wsize,
                                server->maxBuf - sizeof(WRITE_REQ) + 4);
 
-       /* limit to the amount that we can kmap at once */
-       wsize = min_t(unsigned int, wsize, CIFS_KMAP_SIZE_LIMIT);
-
        /* hard limit of CIFS_MAX_WSIZE */
        wsize = min_t(unsigned int, wsize, CIFS_MAX_WSIZE);
 
@@ -485,9 +483,6 @@ cifs_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
        if (!(server->capabilities & CAP_LARGE_READ_X))
                rsize = min_t(unsigned int, CIFSMaxBufSize, rsize);
 
-       /* limit to the amount that we can kmap at once */
-       rsize = min_t(unsigned int, rsize, CIFS_KMAP_SIZE_LIMIT);
-
        /* hard limit of CIFS_MAX_RSIZE */
        rsize = min_t(unsigned int, rsize, CIFS_MAX_RSIZE);
 
@@ -725,11 +720,11 @@ cifs_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock)
        cinode->can_cache_brlcks = cinode->clientCanCacheAll;
 }
 
-static int
+static void
 cifs_close_file(const unsigned int xid, struct cifs_tcon *tcon,
                struct cifs_fid *fid)
 {
-       return CIFSSMBClose(xid, tcon, fid->netfid);
+       CIFSSMBClose(xid, tcon, fid->netfid);
 }
 
 static int
@@ -842,10 +837,8 @@ cifs_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
                     struct cifs_fid *fid, __u16 search_flags,
                     struct cifs_search_info *srch_inf)
 {
-       return CIFSFindFirst(xid, tcon, path, cifs_sb->local_nls,
-                            &fid->netfid, search_flags, srch_inf,
-                            cifs_sb->mnt_cifs_flags &
-                            CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb));
+       return CIFSFindFirst(xid, tcon, path, cifs_sb,
+                            &fid->netfid, search_flags, srch_inf, true);
 }
 
 static int
@@ -863,6 +856,56 @@ cifs_close_dir(const unsigned int xid, struct cifs_tcon *tcon,
        return CIFSFindClose(xid, tcon, fid->netfid);
 }
 
+static int
+cifs_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid,
+                    struct cifsInodeInfo *cinode)
+{
+       return CIFSSMBLock(0, tcon, fid->netfid, current->tgid, 0, 0, 0, 0,
+                          LOCKING_ANDX_OPLOCK_RELEASE, false,
+                          cinode->clientCanCacheRead ? 1 : 0);
+}
+
+static int
+cifs_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
+            struct kstatfs *buf)
+{
+       int rc = -EOPNOTSUPP;
+
+       buf->f_type = CIFS_MAGIC_NUMBER;
+
+       /*
+        * We could add a second check for a QFS Unix capability bit
+        */
+       if ((tcon->ses->capabilities & CAP_UNIX) &&
+           (CIFS_POSIX_EXTENSIONS & le64_to_cpu(tcon->fsUnixInfo.Capability)))
+               rc = CIFSSMBQFSPosixInfo(xid, tcon, buf);
+
+       /*
+        * Only need to call the old QFSInfo if failed on newer one,
+        * e.g. by OS/2.
+        **/
+       if (rc && (tcon->ses->capabilities & CAP_NT_SMBS))
+               rc = CIFSSMBQFSInfo(xid, tcon, buf);
+
+       /*
+        * Some old Windows servers also do not support level 103, retry with
+        * older level one if old server failed the previous call or we
+        * bypassed it because we detected that this was an older LANMAN sess
+        */
+       if (rc)
+               rc = SMBOldQFSInfo(xid, tcon, buf);
+       return rc;
+}
+
+static int
+cifs_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
+              __u64 length, __u32 type, int lock, int unlock, bool wait)
+{
+       return CIFSSMBLock(xid, tlink_tcon(cfile->tlink), cfile->fid.netfid,
+                          current->tgid, length, offset, unlock, lock,
+                          (__u8)type, wait, 0);
+}
+
 struct smb_version_operations smb1_operations = {
        .send_cancel = send_nt_cancel,
        .compare_fids = cifs_compare_fids,
@@ -922,6 +965,11 @@ struct smb_version_operations smb1_operations = {
        .query_dir_next = cifs_query_dir_next,
        .close_dir = cifs_close_dir,
        .calc_smb_size = smbCalcSize,
+       .oplock_response = cifs_oplock_response,
+       .queryfs = cifs_queryfs,
+       .mand_lock = cifs_mand_lock,
+       .mand_unlock_range = cifs_unlock_range,
+       .push_mand_locks = cifs_push_mandatory_locks,
 };
 
 struct smb_version_values smb1_values = {