]> www.infradead.org Git - users/hch/xfs.git/commitdiff
smb: client: change lease epoch type from unsigned int to __u16
authorMeetakshi Setiya <msetiya@microsoft.com>
Thu, 6 Feb 2025 06:50:41 +0000 (01:50 -0500)
committerSteve French <stfrench@microsoft.com>
Thu, 6 Feb 2025 16:01:22 +0000 (10:01 -0600)
MS-SMB2 section 2.2.13.2.10 specifies that 'epoch' should be a 16-bit
unsigned integer used to track lease state changes. Change the data
type of all instances of 'epoch' from unsigned int to __u16. This
simplifies the epoch change comparisons and makes the code more
compliant with the protocol spec.

Cc: stable@vger.kernel.org
Signed-off-by: Meetakshi Setiya <msetiya@microsoft.com>
Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifsglob.h
fs/smb/client/smb1ops.c
fs/smb/client/smb2ops.c
fs/smb/client/smb2pdu.c
fs/smb/client/smb2proto.h

index a68434ad744ae344729847474fd90086c80cd192..ac1f890a0d543e3a55d6c4c998ec33f26d2c66a3 100644 (file)
@@ -357,7 +357,7 @@ struct smb_version_operations {
        int (*handle_cancelled_mid)(struct mid_q_entry *, struct TCP_Server_Info *);
        void (*downgrade_oplock)(struct TCP_Server_Info *server,
                                 struct cifsInodeInfo *cinode, __u32 oplock,
-                                unsigned int epoch, bool *purge_cache);
+                                __u16 epoch, bool *purge_cache);
        /* process transaction2 response */
        bool (*check_trans2)(struct mid_q_entry *, struct TCP_Server_Info *,
                             char *, int);
@@ -552,12 +552,12 @@ struct smb_version_operations {
        /* if we can do cache read operations */
        bool (*is_read_op)(__u32);
        /* set oplock level for the inode */
-       void (*set_oplock_level)(struct cifsInodeInfo *, __u32, unsigned int,
-                                bool *);
+       void (*set_oplock_level)(struct cifsInodeInfo *cinode, __u32 oplock, __u16 epoch,
+                                bool *purge_cache);
        /* create lease context buffer for CREATE request */
        char * (*create_lease_buf)(u8 *lease_key, u8 oplock);
        /* parse lease context buffer and return oplock/epoch info */
-       __u8 (*parse_lease_buf)(void *buf, unsigned int *epoch, char *lkey);
+       __u8 (*parse_lease_buf)(void *buf, __u16 *epoch, char *lkey);
        ssize_t (*copychunk_range)(const unsigned int,
                        struct cifsFileInfo *src_file,
                        struct cifsFileInfo *target_file,
@@ -1447,7 +1447,7 @@ struct cifs_fid {
        __u8 create_guid[16];
        __u32 access;
        struct cifs_pending_open *pending_open;
-       unsigned int epoch;
+       __u16 epoch;
 #ifdef CONFIG_CIFS_DEBUG2
        __u64 mid;
 #endif /* CIFS_DEBUG2 */
@@ -1480,7 +1480,7 @@ struct cifsFileInfo {
        bool oplock_break_cancelled:1;
        bool status_file_deleted:1; /* file has been deleted */
        bool offload:1; /* offload final part of _put to a wq */
-       unsigned int oplock_epoch; /* epoch from the lease break */
+       __u16 oplock_epoch; /* epoch from the lease break */
        __u32 oplock_level; /* oplock/lease level from the lease break */
        int count;
        spinlock_t file_info_lock; /* protects four flag/count fields above */
@@ -1577,7 +1577,7 @@ struct cifsInodeInfo {
        spinlock_t      open_file_lock; /* protects openFileList */
        __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
        unsigned int oplock;            /* oplock/lease level we have */
-       unsigned int epoch;             /* used to track lease state changes */
+       __u16 epoch;            /* used to track lease state changes */
 #define CIFS_INODE_PENDING_OPLOCK_BREAK   (0) /* oplock break in progress */
 #define CIFS_INODE_PENDING_WRITERS       (1) /* Writes in progress */
 #define CIFS_INODE_FLAG_UNUSED           (2) /* Unused flag */
index 9756b876a75e13df5b27e58ebdea4f25cb2fb132..d6e2fb669c401f9181ff1c9f55c7f28d2b934876 100644 (file)
@@ -377,7 +377,7 @@ coalesce_t2(char *second_buf, struct smb_hdr *target_hdr)
 static void
 cifs_downgrade_oplock(struct TCP_Server_Info *server,
                      struct cifsInodeInfo *cinode, __u32 oplock,
-                     unsigned int epoch, bool *purge_cache)
+                     __u16 epoch, bool *purge_cache)
 {
        cifs_set_oplock_level(cinode, oplock);
 }
index 77309217dab455f6d4e73abbd1a173fe51ceb64d..ec36bed54b0b95f019cc605536e27364e1407948 100644 (file)
@@ -3904,22 +3904,22 @@ static long smb3_fallocate(struct file *file, struct cifs_tcon *tcon, int mode,
 static void
 smb2_downgrade_oplock(struct TCP_Server_Info *server,
                      struct cifsInodeInfo *cinode, __u32 oplock,
-                     unsigned int epoch, bool *purge_cache)
+                     __u16 epoch, bool *purge_cache)
 {
        server->ops->set_oplock_level(cinode, oplock, 0, NULL);
 }
 
 static void
 smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
-                      unsigned int epoch, bool *purge_cache);
+                      __u16 epoch, bool *purge_cache);
 
 static void
 smb3_downgrade_oplock(struct TCP_Server_Info *server,
                       struct cifsInodeInfo *cinode, __u32 oplock,
-                      unsigned int epoch, bool *purge_cache)
+                      __u16 epoch, bool *purge_cache)
 {
        unsigned int old_state = cinode->oplock;
-       unsigned int old_epoch = cinode->epoch;
+       __u16 old_epoch = cinode->epoch;
        unsigned int new_state;
 
        if (epoch > old_epoch) {
@@ -3939,7 +3939,7 @@ smb3_downgrade_oplock(struct TCP_Server_Info *server,
 
 static void
 smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
-                     unsigned int epoch, bool *purge_cache)
+                     __u16 epoch, bool *purge_cache)
 {
        oplock &= 0xFF;
        cinode->lease_granted = false;
@@ -3963,7 +3963,7 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
 
 static void
 smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
-                      unsigned int epoch, bool *purge_cache)
+                      __u16 epoch, bool *purge_cache)
 {
        char message[5] = {0};
        unsigned int new_oplock = 0;
@@ -4000,7 +4000,7 @@ smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
 
 static void
 smb3_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
-                     unsigned int epoch, bool *purge_cache)
+                     __u16 epoch, bool *purge_cache)
 {
        unsigned int old_oplock = cinode->oplock;
 
@@ -4114,7 +4114,7 @@ smb3_create_lease_buf(u8 *lease_key, u8 oplock)
 }
 
 static __u8
-smb2_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key)
+smb2_parse_lease_buf(void *buf, __u16 *epoch, char *lease_key)
 {
        struct create_lease *lc = (struct create_lease *)buf;
 
@@ -4125,7 +4125,7 @@ smb2_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key)
 }
 
 static __u8
-smb3_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key)
+smb3_parse_lease_buf(void *buf, __u16 *epoch, char *lease_key)
 {
        struct create_lease_v2 *lc = (struct create_lease_v2 *)buf;
 
index 78395195e01654452e31438963cb44c022e7b113..ed7812247ebc0e1c9a518456a826026d71096586 100644 (file)
@@ -2329,7 +2329,7 @@ parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
 
 int smb2_parse_contexts(struct TCP_Server_Info *server,
                        struct kvec *rsp_iov,
-                       unsigned int *epoch,
+                       __u16 *epoch,
                        char *lease_key, __u8 *oplock,
                        struct smb2_file_all_info *buf,
                        struct create_posix_rsp *posix)
index 2336dfb23f363b2f24faa4f62de5fa99b3b4acb8..4662c7e2d259cf4a22d886b54dee5ddb148ac69e 100644 (file)
@@ -283,7 +283,7 @@ extern enum securityEnum smb2_select_sectype(struct TCP_Server_Info *,
                                        enum securityEnum);
 int smb2_parse_contexts(struct TCP_Server_Info *server,
                        struct kvec *rsp_iov,
-                       unsigned int *epoch,
+                       __u16 *epoch,
                        char *lease_key, __u8 *oplock,
                        struct smb2_file_all_info *buf,
                        struct create_posix_rsp *posix);