Skip to content

Commit

Permalink
cifsd: use notify_change in set_file_basic_info()
Browse files Browse the repository at this point in the history
Use notify_change with inode_lock instead of updating inode directly.
notify_change() will use ->setattr of local filesystem and this patch
improve issue with fuse driver.

Reported-by: Marios Makassikis <mmakassikis@freebox.fr>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
  • Loading branch information
namjaejeon committed Feb 25, 2021
1 parent 614056f commit 5e92912
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -5708,14 +5708,9 @@ static int set_file_basic_info(struct ksmbd_file *fp,
attrs.ia_valid |= ATTR_CTIME;

if (attrs.ia_valid) {
#if ((LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)) && \
(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 37))) || \
(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0))
struct dentry *dentry = filp->f_path.dentry;
struct inode *inode = d_inode(dentry);
#else
struct inode *inode = FP_INODE(fp);
#endif

if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
return -EACCES;

Expand All @@ -5729,8 +5724,21 @@ static int set_file_basic_info(struct ksmbd_file *fp,
if (rc)
return -EINVAL;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 21)
inode_lock(inode);
setattr_copy(inode, &attrs);
attrs.ia_valid &= ~ATTR_CTIME;
rc = notify_change(dentry, &attrs, NULL);
inode_unlock(inode);
#else
mutex_lock(&inode->i_mutex);
setattr_copy(inode, &attrs);
mark_inode_dirty(inode);
attrs.ia_valid &= ~ATTR_CTIME;
rc = notify_change(dentry, &attrs, NULL);
mutex_unlock(&inode->i_mutex);
#endif
if (rc)
return -EINVAL;
}
return 0;
}
Expand Down

0 comments on commit 5e92912

Please sign in to comment.