diff mbox

[CIFS] Query device characteristics at mount time from server on SMB2/3 not just on cifs mounts

Message ID CAH2r5mt+1SDYeV_G2duC63BQg274tSaBn9oxrmy+6RNQuHAL=w@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Steve French Oct. 9, 2013, 6:44 p.m. UTC
Currently SMB2 and SMB3 mounts do not query the device information at mount time
from the server at mount time as is done for cifs.  These can be
useful for debugging.
This is a minor patch, that extends the previous one (which added ability to
query file system attributes at mount time - this returns the device
characteristics - also via in /proc/fs/cifs/DebugData).  I wonder if there is
a way to make additional device characteristics and fs attributes
available in consistent
way for nfs/cifs/smb3 and local file systems (as we do for certain
file attributes).

Signed-off-by: Steve French <smfrench@gmail.com>
---
 fs/cifs/smb2ops.c   |    5 ++++-
 fs/cifs/smb2pdu.c   |   31 +++++++++++++++++++++++--------
 fs/cifs/smb2proto.h |    2 +-
 3 files changed, 28 insertions(+), 10 deletions(-)

              const __u32 pid, const __u64 length, const __u64 offset,
diff mbox

Patch

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index a53e205..71a3460 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -229,7 +229,10 @@  smb2_qfs_tcon(const unsigned int xid, struct
cifs_tcon *tcon)
     if (rc)
         return;

-    SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid);
+    SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
+            SMB_QUERY_FS_ATTRIBUTE_INFO);
+    SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
+            SMB_QUERY_FS_DEVICE_INFO);
     SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
     return;
 }
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 2ade58b..c822d9a 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2347,17 +2347,27 @@  qfsinf_exit:

 int
 SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
-          u64 persistent_fid, u64 volatile_fid)
+          u64 persistent_fid, u64 volatile_fid, int level)
 {
     struct smb2_query_info_rsp *rsp = NULL;
     struct kvec iov;
     int rc = 0;
-    int resp_buftype;
+    int resp_buftype, max_len, min_len;
     struct cifs_ses *ses = tcon->ses;
     unsigned int rsp_len, offset;

-    rc = build_qfs_info_req(&iov, tcon, SMB_QUERY_FS_ATTRIBUTE_INFO,
-                sizeof(FILE_SYSTEM_ATTRIBUTE_INFO),
+    if (level == SMB_QUERY_FS_DEVICE_INFO) {
+        max_len = sizeof(FILE_SYSTEM_DEVICE_INFO);
+        min_len = sizeof(FILE_SYSTEM_DEVICE_INFO);
+    } else if (level == SMB_QUERY_FS_ATTRIBUTE_INFO) {
+        max_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO);
+        min_len = MIN_FS_ATTR_INFO_SIZE;
+    } else {
+        cifs_dbg(FYI, "Invalid qfsinfo level %d", level);
+        return -EINVAL;
+    }
+
+    rc = build_qfs_info_req(&iov, tcon, level, max_len,
                 persistent_fid, volatile_fid);
     if (rc)
         return rc;
@@ -2371,12 +2381,17 @@  SMB2_QFS_attr(const unsigned int xid, struct
cifs_tcon *tcon,

     rsp_len = le32_to_cpu(rsp->OutputBufferLength);
     offset = le16_to_cpu(rsp->OutputBufferOffset);
-    rc = validate_buf(offset, rsp_len, &rsp->hdr, MIN_FS_ATTR_INFO_SIZE);
-    if (!rc) {
+    rc = validate_buf(offset, rsp_len, &rsp->hdr, min_len);
+    if (rc)
+        goto qfsattr_exit;
+
+    if (level == SMB_QUERY_FS_ATTRIBUTE_INFO)
         memcpy(&tcon->fsAttrInfo, 4 /* RFC1001 len */ + offset
             + (char *)&rsp->hdr, min_t(unsigned int,
-            rsp_len, sizeof(FILE_SYSTEM_ATTRIBUTE_INFO)));
-    }
+            rsp_len, max_len));
+    else if (level == SMB_QUERY_FS_DEVICE_INFO)
+        memcpy(&tcon->fsDevInfo, 4 /* RFC1001 len */ + offset
+            + (char *)&rsp->hdr, sizeof(FILE_SYSTEM_DEVICE_INFO));

 qfsattr_exit:
     free_rsp_buf(resp_buftype, iov.iov_base);
diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
index 68dc00d..313813e 100644
--- a/fs/cifs/smb2proto.h
+++ b/fs/cifs/smb2proto.h
@@ -151,7 +151,7 @@  extern int SMB2_QFS_info(const unsigned int xid,
struct cifs_tcon *tcon,
              u64 persistent_file_id, u64 volatile_file_id,
              struct kstatfs *FSData);
 extern int SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
-             u64 persistent_file_id, u64 volatile_file_id);
+             u64 persistent_file_id, u64 volatile_file_id, int lvl);
 extern int SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon,
              const __u64 persist_fid, const __u64 volatile_fid,