Skip to content

Commit cf5371a

Browse files
committed
smb3: fix performance regression with setting mtime
There are cases when we don't want to send the SMB2 flush operation (e.g. when user specifies mount parm "nostrictsync") and it can be a very expensive operation on the server. In most cases in order to set mtime, we simply need to flush (write) the dirtry pages from the client and send the writes to the server not also send a flush protocol operation to the server. Fixes: aa08185 ("cifs: flush before set-info if we have writeable handles") CC: Stable <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 864138c commit cf5371a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

fs/cifs/inode.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,25 +2528,26 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
25282528

25292529
/*
25302530
* Attempt to flush data before changing attributes. We need to do
2531-
* this for ATTR_SIZE and ATTR_MTIME for sure, and if we change the
2532-
* ownership or mode then we may also need to do this. Here, we take
2533-
* the safe way out and just do the flush on all setattr requests. If
2534-
* the flush returns error, store it to report later and continue.
2531+
* this for ATTR_SIZE and ATTR_MTIME. If the flush of the data
2532+
* returns error, store it to report later and continue.
25352533
*
25362534
* BB: This should be smarter. Why bother flushing pages that
25372535
* will be truncated anyway? Also, should we error out here if
2538-
* the flush returns error?
2536+
* the flush returns error? Do we need to check for ATTR_MTIME_SET flag?
25392537
*/
2540-
rc = filemap_write_and_wait(inode->i_mapping);
2541-
if (is_interrupt_error(rc)) {
2542-
rc = -ERESTARTSYS;
2543-
goto cifs_setattr_exit;
2538+
if (attrs->ia_valid & (ATTR_MTIME | ATTR_SIZE | ATTR_CTIME)) {
2539+
rc = filemap_write_and_wait(inode->i_mapping);
2540+
if (is_interrupt_error(rc)) {
2541+
rc = -ERESTARTSYS;
2542+
goto cifs_setattr_exit;
2543+
}
2544+
mapping_set_error(inode->i_mapping, rc);
25442545
}
25452546

2546-
mapping_set_error(inode->i_mapping, rc);
25472547
rc = 0;
25482548

2549-
if (attrs->ia_valid & ATTR_MTIME) {
2549+
if ((attrs->ia_valid & ATTR_MTIME) &&
2550+
!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) {
25502551
rc = cifs_get_writable_file(cifsInode, FIND_WR_ANY, &wfile);
25512552
if (!rc) {
25522553
tcon = tlink_tcon(wfile->tlink);

0 commit comments

Comments
 (0)