Skip to content

Commit 037e1ba

Browse files
decarvSteve French
authored andcommitted
smb: client: use ParentLeaseKey in cifs_do_create
Implement ParentLeaseKey logic in cifs_do_create() by looking up the parent cfid, copying its lease key into the fid struct, and setting the appropriate lease flag. Fixes: f047390 ("CIFS: Add create lease v2 context for SMB3") Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 0f220d3 commit 037e1ba

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

fs/smb/client/dir.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "fs_context.h"
2424
#include "cifs_ioctl.h"
2525
#include "fscache.h"
26+
#include "cached_dir.h"
2627

2728
static void
2829
renew_parental_timestamps(struct dentry *direntry)
@@ -190,6 +191,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
190191
struct TCP_Server_Info *server = tcon->ses->server;
191192
struct cifs_open_parms oparms;
192193
int rdwr_for_fscache = 0;
194+
__le32 lease_flags = 0;
193195

194196
*oplock = 0;
195197
if (tcon->ses->server->oplocks)
@@ -312,6 +314,26 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
312314
create_options |= CREATE_OPTION_READONLY;
313315

314316
retry_open:
317+
if (tcon->cfids && direntry->d_parent && server->dialect >= SMB30_PROT_ID) {
318+
struct cached_fid *parent_cfid;
319+
320+
spin_lock(&tcon->cfids->cfid_list_lock);
321+
list_for_each_entry(parent_cfid, &tcon->cfids->entries, entry) {
322+
if (parent_cfid->dentry == direntry->d_parent) {
323+
cifs_dbg(FYI, "found a parent cached file handle\n");
324+
if (parent_cfid->has_lease && parent_cfid->time) {
325+
lease_flags
326+
|= SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET_LE;
327+
memcpy(fid->parent_lease_key,
328+
parent_cfid->fid.lease_key,
329+
SMB2_LEASE_KEY_SIZE);
330+
}
331+
break;
332+
}
333+
}
334+
spin_unlock(&tcon->cfids->cfid_list_lock);
335+
}
336+
315337
oparms = (struct cifs_open_parms) {
316338
.tcon = tcon,
317339
.cifs_sb = cifs_sb,
@@ -320,6 +342,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
320342
.disposition = disposition,
321343
.path = full_path,
322344
.fid = fid,
345+
.lease_flags = lease_flags,
323346
.mode = mode,
324347
};
325348
rc = server->ops->open(xid, &oparms, oplock, buf);

0 commit comments

Comments
 (0)