cifs: create a helper to find a writeable handle py path name
Subsystems (2)
PATCH 1/2 cifs: create a helper to find a writeable handle py path name
rename() takes a path for old_file and in SMB2 we used to just create a compound for create(old_path)/rename/close().
If we already have a writable handle we can avoid the create() and close() altogether and just use the existing handle.
For this situation, as we avoid doing the create()
we also avoid triggering an oplock break for the existing handle.
--- fs/cifs/cifsproto.h | 2 ++ fs/cifs/file.c | 35 ++++++++++++++++++++++ fs/cifs/smb2inode.c | 83 +++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 96 insertions(+), 24 deletions(-)
fs/cifs/cifsproto.h +2 -0
@@ -137,6 +137,8 @@ extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *, bool);extern int cifs_get_writable_file (struct cifsInodeInfo *cifs_inode,bool fsuid_only,struct cifsFileInfo **ret_file); +extern int cifs_get_writable_path (struct cifs_tcon *tcon,const char *name, +struct cifsFileInfo **ret_file);extern struct cifsFileInfo *find_readable_file (struct cifsInodeInfo *,bool );extern unsigned int smbCalcSize (void *buf,struct TCP_Server_Info *server); extern int decode_negTokenInit(unsigned char *security_blob, int length,
fs/cifs/file.c +35 -0
@@ -1980,6 +1980,41 @@ find_writable_file(struct cifsInodeInfo *cifs_inode, bool fsuid_only)return cfile; } +int +cifs_get_writable_path (struct cifs_tcon *tcon,const char *name, +struct cifsFileInfo **ret_file) +{ +struct list_head *tmp; +struct cifsFileInfo *cfile; +struct cifsInodeInfo *cinode; +char *full_path; + + *ret_file =NULL ; + +spin_lock (&tcon->open_file_lock); +list_for_each (tmp, &tcon->openFileList) { + cfile = list_entry(tmp, struct cifsFileInfo, + tlist); + full_path =build_path_from_dentry (cfile->dentry); +if (full_path ==NULL ) { +spin_unlock (&tcon->open_file_lock); +return -ENOMEM ; + } +if (strcmp (full_path, name)) { +kfree (full_path); +continue ; + } +kfree (full_path); + + cinode =CIFS_I (d_inode (cfile->dentry)); +spin_unlock (&tcon->open_file_lock); +return cifs_get_writable_file (cinode,0 , ret_file); + } + +spin_unlock (&tcon->open_file_lock); +return -ENOENT ; +} +static int cifs_partialpagewrite (struct page *page,unsigned from,unsigned to) {struct address_space *mapping = page->mapping;
fs/cifs/smb2inode.c +59 -24
195 lines not on this page · raw message
Signature · 1 line
2.13.6
PATCH 2/2 cifs: fix incorrect error return in build_unc_path_to_root
--- fs/cifs/connect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/connect.c +1 -1
@@ -4232,7 +4232,7 @@ build_unc_path_to_root(const struct smb_vol *vol,unsigned int unc_len =strnlen (vol->UNC,MAX_TREE_SIZE +1 );if (unc_len >MAX_TREE_SIZE ) -return -EINVAL ; +return ERR_PTR (-EINVAL ); full_path =kmalloc (unc_len + pplen +1 ,GFP_KERNEL );if (full_path ==NULL )
Signature · 1 line
2.13.6
Re: [PATCH 2/2] cifs: fix incorrect error return in build_unc_path_to_root
Do you have a simple repro for this one that would lead us to want to cc:stable
Quoted 22 lines · Ronnie Sahlberg
Signed-off-by Ronnie Sahlberg <[email protected]>--- fs/cifs/connect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/connect.c +1
-2@@ -4232,7 +4232,7 @@ build_unc_path_to_root(const struct smb_vol *vol,unsigned int unc_len =strnlen (vol->UNC,MAX_TREE_SIZE +1 );if (unc_len >MAX_TREE_SIZE ) -return -EINVAL ; +return ERR_PTR (-EINVAL ); full_path =kmalloc (unc_len + pplen +1 ,GFP_KERNEL );if (full_path ==NULL ) --2.13.6
Signature · 3 lines
Thanks, Steve
ronnie sahlberg
reviewerRe: [PATCH 2/2] cifs: fix incorrect error return in build_unc_path_to_root
Quoted 2 lines · Steve French
Do you have a simple repro for this one that would lead us to want to cc:stable
I don't have a reproducer.
Quoted 30 lines · Ronnie Sahlberg
Quoted 20 lines
Signed-off-by Ronnie Sahlberg <[email protected]>--- fs/cifs/connect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/connect.c +1
-2@@ -4232,7 +4232,7 @@ build_unc_path_to_root(const struct smb_vol *vol,unsigned int unc_len =strnlen (vol->UNC,MAX_TREE_SIZE +1 );if (unc_len >MAX_TREE_SIZE ) -return -EINVAL ; +return ERR_PTR (-EINVAL ); full_path =kmalloc (unc_len + pplen +1 ,GFP_KERNEL );if (full_path ==NULL ) --Quoted 2 lines
2.13.6
--
Thanks,Steve
Re: [PATCH 2/2] cifs: fix incorrect error return in build_unc_path_to_root
In reply to Ronnie SahlbergI fixed this in an earlier patch of yours
Quoted 22 lines · Ronnie Sahlberg
Signed-off-by Ronnie Sahlberg <[email protected]>--- fs/cifs/connect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/connect.c +1
-2@@ -4232,7 +4232,7 @@ build_unc_path_to_root(const struct smb_vol *vol,unsigned int unc_len =strnlen (vol->UNC,MAX_TREE_SIZE +1 );if (unc_len >MAX_TREE_SIZE ) -return -EINVAL ; +return ERR_PTR (-EINVAL ); full_path =kmalloc (unc_len + pplen +1 ,GFP_KERNEL );if (full_path ==NULL ) --2.13.6
Signature · 3 lines
Thanks, Steve