CIFS: Make SMB2_open use cifs_open_parms struct
authorPavel Shilovsky <pshilovsky@samba.org>
Tue, 9 Jul 2013 14:20:30 +0000 (18:20 +0400)
committerSteve French <smfrench@gmail.com>
Wed, 10 Jul 2013 18:08:40 +0000 (13:08 -0500)
to prepare it for further durable handle reconnect processing.

Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: Steven French <steven@steven-GA-970A-DS3.(none)>
fs/cifs/smb2file.c
fs/cifs/smb2inode.c
fs/cifs/smb2ops.c
fs/cifs/smb2pdu.c
fs/cifs/smb2proto.h

index 5bab192f64e874c3f3c6f21e539c718eb1eab0ca..398992962cc6bec794a67a5580a8bab704755b90 100644 (file)
@@ -85,10 +85,7 @@ smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
        if (oparms->tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
                memcpy(smb2_oplock + 1, fid->lease_key, SMB2_LEASE_KEY_SIZE);
 
-       rc = SMB2_open(xid, oparms->tcon, smb2_path, &fid->persistent_fid,
-                      &fid->volatile_fid, oparms->desired_access,
-                      oparms->disposition, oparms->create_options, smb2_oplock,
-                      smb2_data);
+       rc = SMB2_open(xid, oparms, smb2_path, smb2_oplock, smb2_data);
        if (rc)
                goto out;
 
index f50eefd9e005e550b69d0ddd12d7806f3f9a83d8..9841df771f08eda368027b1737783e15f677a77c 100644 (file)
@@ -44,17 +44,22 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon,
                   __u32 create_options, void *data, int command)
 {
        int rc, tmprc = 0;
-       u64 persistent_fid, volatile_fid;
        __le16 *utf16_path;
        __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
+       struct cifs_open_parms oparms;
+       struct cifs_fid fid;
 
        utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
        if (!utf16_path)
                return -ENOMEM;
 
-       rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid,
-                      desired_access, create_disposition, create_options,
-                      &oplock, NULL);
+       oparms.tcon = tcon;
+       oparms.desired_access = desired_access;
+       oparms.disposition = create_disposition;
+       oparms.create_options = create_options;
+       oparms.fid = &fid;
+
+       rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL);
        if (rc) {
                kfree(utf16_path);
                return rc;
@@ -64,8 +69,8 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon,
        case SMB2_OP_DELETE:
                break;
        case SMB2_OP_QUERY_INFO:
-               tmprc = SMB2_query_info(xid, tcon, persistent_fid,
-                                       volatile_fid,
+               tmprc = SMB2_query_info(xid, tcon, fid.persistent_fid,
+                                       fid.volatile_fid,
                                        (struct smb2_file_all_info *)data);
                break;
        case SMB2_OP_MKDIR:
@@ -75,19 +80,21 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon,
                 */
                break;
        case SMB2_OP_RENAME:
-               tmprc = SMB2_rename(xid, tcon, persistent_fid, volatile_fid,
-                                   (__le16 *)data);
+               tmprc = SMB2_rename(xid, tcon, fid.persistent_fid,
+                                   fid.volatile_fid, (__le16 *)data);
                break;
        case SMB2_OP_HARDLINK:
-               tmprc = SMB2_set_hardlink(xid, tcon, persistent_fid,
-                                         volatile_fid, (__le16 *)data);
+               tmprc = SMB2_set_hardlink(xid, tcon, fid.persistent_fid,
+                                         fid.volatile_fid, (__le16 *)data);
                break;
        case SMB2_OP_SET_EOF:
-               tmprc = SMB2_set_eof(xid, tcon, persistent_fid, volatile_fid,
-                                    current->tgid, (__le64 *)data);
+               tmprc = SMB2_set_eof(xid, tcon, fid.persistent_fid,
+                                    fid.volatile_fid, current->tgid,
+                                    (__le64 *)data);
                break;
        case SMB2_OP_SET_INFO:
-               tmprc = SMB2_set_info(xid, tcon, persistent_fid, volatile_fid,
+               tmprc = SMB2_set_info(xid, tcon, fid.persistent_fid,
+                                     fid.volatile_fid,
                                      (FILE_BASIC_INFO *)data);
                break;
        default:
@@ -95,7 +102,7 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon,
                break;
        }
 
-       rc = SMB2_close(xid, tcon, persistent_fid, volatile_fid);
+       rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
        if (tmprc)
                rc = tmprc;
        kfree(utf16_path);
index 92bdc7ec5c99cd581d79fc6795b9be9b396ed2bf..1bc7d7e64cf53a75a65c2820a88362c61fb8b452 100644 (file)
@@ -213,22 +213,28 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
                        struct cifs_sb_info *cifs_sb, const char *full_path)
 {
        int rc;
-       __u64 persistent_fid, volatile_fid;
        __le16 *utf16_path;
        __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
+       struct cifs_open_parms oparms;
+       struct cifs_fid fid;
 
        utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
        if (!utf16_path)
                return -ENOMEM;
 
-       rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid,
-                      FILE_READ_ATTRIBUTES, FILE_OPEN, 0, &oplock, NULL);
+       oparms.tcon = tcon;
+       oparms.desired_access = FILE_READ_ATTRIBUTES;
+       oparms.disposition = FILE_OPEN;
+       oparms.create_options = 0;
+       oparms.fid = &fid;
+
+       rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL);
        if (rc) {
                kfree(utf16_path);
                return rc;
        }
 
-       rc = SMB2_close(xid, tcon, persistent_fid, volatile_fid);
+       rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
        kfree(utf16_path);
        return rc;
 }
@@ -443,15 +449,19 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
        __le16 *utf16_path;
        int rc;
        __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
-       __u64 persistent_fid, volatile_fid;
+       struct cifs_open_parms oparms;
 
        utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
        if (!utf16_path)
                return -ENOMEM;
 
-       rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid,
-                      FILE_READ_ATTRIBUTES | FILE_READ_DATA, FILE_OPEN, 0,
-                      &oplock, NULL);
+       oparms.tcon = tcon;
+       oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA;
+       oparms.disposition = FILE_OPEN;
+       oparms.create_options = 0;
+       oparms.fid = fid;
+
+       rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL);
        kfree(utf16_path);
        if (rc) {
                cifs_dbg(VFS, "open dir failed\n");
@@ -460,14 +470,12 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
 
        srch_inf->entries_in_buffer = 0;
        srch_inf->index_of_last_entry = 0;
-       fid->persistent_fid = persistent_fid;
-       fid->volatile_fid = volatile_fid;
 
-       rc = SMB2_query_directory(xid, tcon, persistent_fid, volatile_fid, 0,
-                                 srch_inf);
+       rc = SMB2_query_directory(xid, tcon, fid->persistent_fid,
+                                 fid->volatile_fid, 0, srch_inf);
        if (rc) {
                cifs_dbg(VFS, "query directory failed\n");
-               SMB2_close(xid, tcon, persistent_fid, volatile_fid);
+               SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
        }
        return rc;
 }
@@ -528,17 +536,24 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
             struct kstatfs *buf)
 {
        int rc;
-       u64 persistent_fid, volatile_fid;
        __le16 srch_path = 0; /* Null - open root of share */
        u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
+       struct cifs_open_parms oparms;
+       struct cifs_fid fid;
+
+       oparms.tcon = tcon;
+       oparms.desired_access = FILE_READ_ATTRIBUTES;
+       oparms.disposition = FILE_OPEN;
+       oparms.create_options = 0;
+       oparms.fid = &fid;
 
-       rc = SMB2_open(xid, tcon, &srch_path, &persistent_fid, &volatile_fid,
-                      FILE_READ_ATTRIBUTES, FILE_OPEN, 0, &oplock, NULL);
+       rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL);
        if (rc)
                return rc;
        buf->f_type = SMB2_MAGIC_NUMBER;
-       rc = SMB2_QFS_info(xid, tcon, persistent_fid, volatile_fid, buf);
-       SMB2_close(xid, tcon, persistent_fid, volatile_fid);
+       rc = SMB2_QFS_info(xid, tcon, fid.persistent_fid, fid.volatile_fid,
+                          buf);
+       SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
        return rc;
 }
 
index 140a613073fb63c1ea8b87ab7a53a94f73eb12f5..9d7341d696fc7aee5a3448344af1ef88deec10f0 100644 (file)
@@ -946,14 +946,13 @@ add_durable_context(struct kvec *iov, unsigned int *num_iovec)
 }
 
 int
-SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path,
-         u64 *persistent_fid, u64 *volatile_fid, __u32 desired_access,
-         __u32 create_disposition, __u32 create_options, __u8 *oplock,
-         struct smb2_file_all_info *buf)
+SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
+         __u8 *oplock, struct smb2_file_all_info *buf)
 {
        struct smb2_create_req *req;
        struct smb2_create_rsp *rsp;
        struct TCP_Server_Info *server;
+       struct cifs_tcon *tcon = oparms->tcon;
        struct cifs_ses *ses = tcon->ses;
        struct kvec iov[4];
        int resp_buftype;
@@ -975,16 +974,16 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path,
        if (rc)
                return rc;
 
-       if (create_options & CREATE_OPTION_READONLY)
+       if (oparms->create_options & CREATE_OPTION_READONLY)
                file_attributes |= ATTR_READONLY;
 
        req->ImpersonationLevel = IL_IMPERSONATION;
-       req->DesiredAccess = cpu_to_le32(desired_access);
+       req->DesiredAccess = cpu_to_le32(oparms->desired_access);
        /* File attributes ignored on open (used in create though) */
        req->FileAttributes = cpu_to_le32(file_attributes);
        req->ShareAccess = FILE_SHARE_ALL_LE;
-       req->CreateDisposition = cpu_to_le32(create_disposition);
-       req->CreateOptions = cpu_to_le32(create_options & CREATE_OPTIONS_MASK);
+       req->CreateDisposition = cpu_to_le32(oparms->disposition);
+       req->CreateOptions = cpu_to_le32(oparms->create_options & CREATE_OPTIONS_MASK);
        uni_path_len = (2 * UniStrnlen((wchar_t *)path, PATH_MAX)) + 2;
        /* do not count rfc1001 len field */
        req->NameOffset = cpu_to_le16(sizeof(struct smb2_create_req) - 4);
@@ -1055,8 +1054,8 @@ SMB2_open(const unsigned int xid, struct cifs_tcon *tcon, __le16 *path,
                goto creat_exit;
        }
 
-       *persistent_fid = rsp->PersistentFileId;
-       *volatile_fid = rsp->VolatileFileId;
+       oparms->fid->persistent_fid = rsp->PersistentFileId;
+       oparms->fid->volatile_fid = rsp->VolatileFileId;
 
        if (buf) {
                memcpy(buf, &rsp->CreationTime, 32);
index 206efde13f7168b19f6835e747bae6454428685f..1a5ecbed40edac9ae352a1baa2c162697712e9fd 100644 (file)
@@ -104,10 +104,8 @@ extern int SMB2_tcon(const unsigned int xid, struct cifs_ses *ses,
                     const char *tree, struct cifs_tcon *tcon,
                     const struct nls_table *);
 extern int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon);
-extern int SMB2_open(const unsigned int xid, struct cifs_tcon *tcon,
-                    __le16 *path, u64 *persistent_fid, u64 *volatile_fid,
-                    __u32 desired_access, __u32 create_disposition,
-                    __u32 create_options, __u8 *oplock,
+extern int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms,
+                    __le16 *path, __u8 *oplock,
                     struct smb2_file_all_info *buf);
 extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon,
                     u64 persistent_fid, u64 volatile_fid, u32 opcode,