Skip to content

Commit 57e4a9b

Browse files
meetakshi253Steve French
authored and
Steve French
committed
smb: client: change lease epoch type from unsigned int to __u16
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: [email protected] Signed-off-by: Meetakshi Setiya <[email protected]> Reviewed-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent be1963d commit 57e4a9b

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

fs/smb/client/cifsglob.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ struct smb_version_operations {
357357
int (*handle_cancelled_mid)(struct mid_q_entry *, struct TCP_Server_Info *);
358358
void (*downgrade_oplock)(struct TCP_Server_Info *server,
359359
struct cifsInodeInfo *cinode, __u32 oplock,
360-
unsigned int epoch, bool *purge_cache);
360+
__u16 epoch, bool *purge_cache);
361361
/* process transaction2 response */
362362
bool (*check_trans2)(struct mid_q_entry *, struct TCP_Server_Info *,
363363
char *, int);
@@ -552,12 +552,12 @@ struct smb_version_operations {
552552
/* if we can do cache read operations */
553553
bool (*is_read_op)(__u32);
554554
/* set oplock level for the inode */
555-
void (*set_oplock_level)(struct cifsInodeInfo *, __u32, unsigned int,
556-
bool *);
555+
void (*set_oplock_level)(struct cifsInodeInfo *cinode, __u32 oplock, __u16 epoch,
556+
bool *purge_cache);
557557
/* create lease context buffer for CREATE request */
558558
char * (*create_lease_buf)(u8 *lease_key, u8 oplock);
559559
/* parse lease context buffer and return oplock/epoch info */
560-
__u8 (*parse_lease_buf)(void *buf, unsigned int *epoch, char *lkey);
560+
__u8 (*parse_lease_buf)(void *buf, __u16 *epoch, char *lkey);
561561
ssize_t (*copychunk_range)(const unsigned int,
562562
struct cifsFileInfo *src_file,
563563
struct cifsFileInfo *target_file,
@@ -1447,7 +1447,7 @@ struct cifs_fid {
14471447
__u8 create_guid[16];
14481448
__u32 access;
14491449
struct cifs_pending_open *pending_open;
1450-
unsigned int epoch;
1450+
__u16 epoch;
14511451
#ifdef CONFIG_CIFS_DEBUG2
14521452
__u64 mid;
14531453
#endif /* CIFS_DEBUG2 */
@@ -1480,7 +1480,7 @@ struct cifsFileInfo {
14801480
bool oplock_break_cancelled:1;
14811481
bool status_file_deleted:1; /* file has been deleted */
14821482
bool offload:1; /* offload final part of _put to a wq */
1483-
unsigned int oplock_epoch; /* epoch from the lease break */
1483+
__u16 oplock_epoch; /* epoch from the lease break */
14841484
__u32 oplock_level; /* oplock/lease level from the lease break */
14851485
int count;
14861486
spinlock_t file_info_lock; /* protects four flag/count fields above */
@@ -1577,7 +1577,7 @@ struct cifsInodeInfo {
15771577
spinlock_t open_file_lock; /* protects openFileList */
15781578
__u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
15791579
unsigned int oplock; /* oplock/lease level we have */
1580-
unsigned int epoch; /* used to track lease state changes */
1580+
__u16 epoch; /* used to track lease state changes */
15811581
#define CIFS_INODE_PENDING_OPLOCK_BREAK (0) /* oplock break in progress */
15821582
#define CIFS_INODE_PENDING_WRITERS (1) /* Writes in progress */
15831583
#define CIFS_INODE_FLAG_UNUSED (2) /* Unused flag */

fs/smb/client/smb1ops.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ coalesce_t2(char *second_buf, struct smb_hdr *target_hdr)
377377
static void
378378
cifs_downgrade_oplock(struct TCP_Server_Info *server,
379379
struct cifsInodeInfo *cinode, __u32 oplock,
380-
unsigned int epoch, bool *purge_cache)
380+
__u16 epoch, bool *purge_cache)
381381
{
382382
cifs_set_oplock_level(cinode, oplock);
383383
}

fs/smb/client/smb2ops.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -3904,22 +3904,22 @@ static long smb3_fallocate(struct file *file, struct cifs_tcon *tcon, int mode,
39043904
static void
39053905
smb2_downgrade_oplock(struct TCP_Server_Info *server,
39063906
struct cifsInodeInfo *cinode, __u32 oplock,
3907-
unsigned int epoch, bool *purge_cache)
3907+
__u16 epoch, bool *purge_cache)
39083908
{
39093909
server->ops->set_oplock_level(cinode, oplock, 0, NULL);
39103910
}
39113911

39123912
static void
39133913
smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
3914-
unsigned int epoch, bool *purge_cache);
3914+
__u16 epoch, bool *purge_cache);
39153915

39163916
static void
39173917
smb3_downgrade_oplock(struct TCP_Server_Info *server,
39183918
struct cifsInodeInfo *cinode, __u32 oplock,
3919-
unsigned int epoch, bool *purge_cache)
3919+
__u16 epoch, bool *purge_cache)
39203920
{
39213921
unsigned int old_state = cinode->oplock;
3922-
unsigned int old_epoch = cinode->epoch;
3922+
__u16 old_epoch = cinode->epoch;
39233923
unsigned int new_state;
39243924

39253925
if (epoch > old_epoch) {
@@ -3939,7 +3939,7 @@ smb3_downgrade_oplock(struct TCP_Server_Info *server,
39393939

39403940
static void
39413941
smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
3942-
unsigned int epoch, bool *purge_cache)
3942+
__u16 epoch, bool *purge_cache)
39433943
{
39443944
oplock &= 0xFF;
39453945
cinode->lease_granted = false;
@@ -3963,7 +3963,7 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
39633963

39643964
static void
39653965
smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
3966-
unsigned int epoch, bool *purge_cache)
3966+
__u16 epoch, bool *purge_cache)
39673967
{
39683968
char message[5] = {0};
39693969
unsigned int new_oplock = 0;
@@ -4000,7 +4000,7 @@ smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
40004000

40014001
static void
40024002
smb3_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
4003-
unsigned int epoch, bool *purge_cache)
4003+
__u16 epoch, bool *purge_cache)
40044004
{
40054005
unsigned int old_oplock = cinode->oplock;
40064006

@@ -4114,7 +4114,7 @@ smb3_create_lease_buf(u8 *lease_key, u8 oplock)
41144114
}
41154115

41164116
static __u8
4117-
smb2_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key)
4117+
smb2_parse_lease_buf(void *buf, __u16 *epoch, char *lease_key)
41184118
{
41194119
struct create_lease *lc = (struct create_lease *)buf;
41204120

@@ -4125,7 +4125,7 @@ smb2_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key)
41254125
}
41264126

41274127
static __u8
4128-
smb3_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key)
4128+
smb3_parse_lease_buf(void *buf, __u16 *epoch, char *lease_key)
41294129
{
41304130
struct create_lease_v2 *lc = (struct create_lease_v2 *)buf;
41314131

fs/smb/client/smb2pdu.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
23292329

23302330
int smb2_parse_contexts(struct TCP_Server_Info *server,
23312331
struct kvec *rsp_iov,
2332-
unsigned int *epoch,
2332+
__u16 *epoch,
23332333
char *lease_key, __u8 *oplock,
23342334
struct smb2_file_all_info *buf,
23352335
struct create_posix_rsp *posix)

fs/smb/client/smb2proto.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ extern enum securityEnum smb2_select_sectype(struct TCP_Server_Info *,
283283
enum securityEnum);
284284
int smb2_parse_contexts(struct TCP_Server_Info *server,
285285
struct kvec *rsp_iov,
286-
unsigned int *epoch,
286+
__u16 *epoch,
287287
char *lease_key, __u8 *oplock,
288288
struct smb2_file_all_info *buf,
289289
struct create_posix_rsp *posix);

0 commit comments

Comments
 (0)