CIFS: Implement cifs_strict_fsync
Invalidate inode mapping if we don't have at least Level II oplock in cifs_strict_fsync. Also remove filemap_write_and_wait call from cifs_fsync because it is previously called from vfs_fsync_range. Add file operations' structures for strict cache mode. Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Pavel Shilovsky <piastryyy@gmail.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
@@ -1528,27 +1528,47 @@ static int cifs_write_end(struct file *file, struct address_space *mapping,
|
||||
return rc;
|
||||
}
|
||||
|
||||
int cifs_fsync(struct file *file, int datasync)
|
||||
int cifs_strict_fsync(struct file *file, int datasync)
|
||||
{
|
||||
int xid;
|
||||
int rc = 0;
|
||||
struct cifsTconInfo *tcon;
|
||||
struct cifsFileInfo *smbfile = file->private_data;
|
||||
struct inode *inode = file->f_path.dentry->d_inode;
|
||||
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
|
||||
|
||||
xid = GetXid();
|
||||
|
||||
cFYI(1, "Sync file - name: %s datasync: 0x%x",
|
||||
file->f_path.dentry->d_name.name, datasync);
|
||||
|
||||
rc = filemap_write_and_wait(inode->i_mapping);
|
||||
if (rc == 0) {
|
||||
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
|
||||
if (!CIFS_I(inode)->clientCanCacheRead)
|
||||
cifs_invalidate_mapping(inode);
|
||||
|
||||
tcon = tlink_tcon(smbfile->tlink);
|
||||
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
|
||||
rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
|
||||
}
|
||||
tcon = tlink_tcon(smbfile->tlink);
|
||||
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
|
||||
rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
|
||||
|
||||
FreeXid(xid);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int cifs_fsync(struct file *file, int datasync)
|
||||
{
|
||||
int xid;
|
||||
int rc = 0;
|
||||
struct cifsTconInfo *tcon;
|
||||
struct cifsFileInfo *smbfile = file->private_data;
|
||||
struct cifs_sb_info *cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
|
||||
|
||||
xid = GetXid();
|
||||
|
||||
cFYI(1, "Sync file - name: %s datasync: 0x%x",
|
||||
file->f_path.dentry->d_name.name, datasync);
|
||||
|
||||
tcon = tlink_tcon(smbfile->tlink);
|
||||
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
|
||||
rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
|
||||
|
||||
FreeXid(xid);
|
||||
return rc;
|
||||
|
Reference in New Issue
Block a user