cifs: Rename and cleanup open_query_close_cifs_symlink()
authorSachin Prabhu <sprabhu@redhat.com>
Mon, 25 Nov 2013 17:09:49 +0000 (17:09 +0000)
committerSteve French <smfrench@gmail.com>
Mon, 20 Jan 2014 06:13:51 +0000 (00:13 -0600)
Rename open_query_close_cifs_symlink to cifs_query_mf_symlink() to make
the name more consistent with other protocol version specific functions.

We also pass tcon as an argument to the function. This is already
available in the calling functions and we can avoid having to make an
unnecessary lookup.

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/cifsglob.h
fs/cifs/cifsproto.h
fs/cifs/link.c
fs/cifs/smb1ops.c

index f918a998a08758caac54bf8205cd7da7705c1efc..fba4d1341f88977416cd0bbf982591e7df3c2bdc 100644 (file)
@@ -370,8 +370,9 @@ struct smb_version_operations {
        void (*new_lease_key)(struct cifs_fid *);
        int (*generate_signingkey)(struct cifs_ses *);
        int (*calc_signature)(struct smb_rqst *, struct TCP_Server_Info *);
-       int (*query_mf_symlink)(const unsigned char *, char *, unsigned int *,
-                               struct cifs_sb_info *, unsigned int);
+       int (*query_mf_symlink)(unsigned int, struct cifs_tcon *,
+                               struct cifs_sb_info *, const unsigned char *,
+                               char *, unsigned int *);
        /* if we can do cache read operations */
        bool (*is_read_op)(__u32);
        /* set oplock level for the inode */
index 2c29db6a247e4788256461100bed11ac79648d26..10b9ab1d1ae972845b191c16c753cd822193cb57 100644 (file)
@@ -496,7 +496,8 @@ void cifs_writev_complete(struct work_struct *work);
 struct cifs_writedata *cifs_writedata_alloc(unsigned int nr_pages,
                                                work_func_t complete);
 void cifs_writedata_release(struct kref *refcount);
-int open_query_close_cifs_symlink(const unsigned char *path, char *pbuf,
-                       unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb,
-                       unsigned int xid);
+int cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
+                         struct cifs_sb_info *cifs_sb,
+                         const unsigned char *path, char *pbuf,
+                         unsigned int *pbytes_read);
 #endif                 /* _CIFSPROTO_H */
index 28bc8ee97056f1688d487f65c26ffb105c655c38..c8e29682ccdb063b4fe27910f097e956b4d3db71 100644 (file)
@@ -305,54 +305,41 @@ CIFSCouldBeMFSymlink(const struct cifs_fattr *fattr)
 }
 
 int
-open_query_close_cifs_symlink(const unsigned char *path, char *pbuf,
-                       unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb,
-                       unsigned int xid)
+cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
+                     struct cifs_sb_info *cifs_sb, const unsigned char *path,
+                     char *pbuf, unsigned int *pbytes_read)
 {
        int rc;
        int oplock = 0;
        __u16 netfid = 0;
-       struct tcon_link *tlink;
-       struct cifs_tcon *ptcon;
        struct cifs_io_parms io_parms;
        int buf_type = CIFS_NO_BUFFER;
        FILE_ALL_INFO file_info;
 
-       tlink = cifs_sb_tlink(cifs_sb);
-       if (IS_ERR(tlink))
-               return PTR_ERR(tlink);
-       ptcon = tlink_tcon(tlink);
-
-       rc = CIFSSMBOpen(xid, ptcon, path, FILE_OPEN, GENERIC_READ,
+       rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, GENERIC_READ,
                         CREATE_NOT_DIR, &netfid, &oplock, &file_info,
                         cifs_sb->local_nls,
                         cifs_sb->mnt_cifs_flags &
                                CIFS_MOUNT_MAP_SPECIAL_CHR);
-       if (rc != 0) {
-               cifs_put_tlink(tlink);
+       if (rc)
                return rc;
-       }
 
-       if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
-               CIFSSMBClose(xid, ptcon, netfid);
-               cifs_put_tlink(tlink);
+       if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE))
                /* it's not a symlink */
-               return rc;
-       }
+               goto out;
 
        io_parms.netfid = netfid;
        io_parms.pid = current->tgid;
-       io_parms.tcon = ptcon;
+       io_parms.tcon = tcon;
        io_parms.offset = 0;
        io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
 
        rc = CIFSSMBRead(xid, &io_parms, pbytes_read, &pbuf, &buf_type);
-       CIFSSMBClose(xid, ptcon, netfid);
-       cifs_put_tlink(tlink);
+out:
+       CIFSSMBClose(xid, tcon, netfid);
        return rc;
 }
 
-
 int
 CIFSCheckMFSymlink(unsigned int xid, struct cifs_tcon *tcon,
                   struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
@@ -372,8 +359,8 @@ CIFSCheckMFSymlink(unsigned int xid, struct cifs_tcon *tcon,
                return -ENOMEM;
 
        if (tcon->ses->server->ops->query_mf_symlink)
-               rc = tcon->ses->server->ops->query_mf_symlink(path, buf,
-                                               &bytes_read, cifs_sb, xid);
+               rc = tcon->ses->server->ops->query_mf_symlink(xid, tcon,
+                                             cifs_sb, path, buf, &bytes_read);
        else
                rc = -ENOSYS;
 
index 5f5ba0dc2ee1b9c7b3d26ede9590a185ac6925e0..099c27602257429eac437d212c00c581994bb182 100644 (file)
@@ -1009,7 +1009,7 @@ struct smb_version_operations smb1_operations = {
        .mand_lock = cifs_mand_lock,
        .mand_unlock_range = cifs_unlock_range,
        .push_mand_locks = cifs_push_mandatory_locks,
-       .query_mf_symlink = open_query_close_cifs_symlink,
+       .query_mf_symlink = cifs_query_mf_symlink,
        .is_read_op = cifs_is_read_op,
 };