Skip to content

Commit 787aded

Browse files
Namjae Jeonsmfrench
authored andcommitted
cifs: Allow directIO read/write during cache=strict
Currently cifs have all or nothing approach for directIO operations. cache=strict mode does not allow directIO while cache=none mode performs all the operations as directIO even when user does not specify O_DIRECT flag. This patch enables strict cache mode to honour directIO semantics. Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com> Signed-off-by: Steve French <smfrench@gmail.com>
1 parent d4a029d commit 787aded

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎fs/cifs/dir.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,14 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
497497
goto out;
498498
}
499499

500+
if (file->f_flags & O_DIRECT &&
501+
CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) {
502+
if (CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
503+
file->f_op = &cifs_file_direct_nobrl_ops;
504+
else
505+
file->f_op = &cifs_file_direct_ops;
506+
}
507+
500508
file_info = cifs_new_fileinfo(&fid, file, tlink, oplock);
501509
if (file_info == NULL) {
502510
if (server->ops->close)

‎fs/cifs/file.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,14 @@ int cifs_open(struct inode *inode, struct file *file)
467467
cifs_dbg(FYI, "inode = 0x%p file flags are 0x%x for %s\n",
468468
inode, file->f_flags, full_path);
469469

470+
if (file->f_flags & O_DIRECT &&
471+
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) {
472+
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
473+
file->f_op = &cifs_file_direct_nobrl_ops;
474+
else
475+
file->f_op = &cifs_file_direct_ops;
476+
}
477+
470478
if (server->oplocks)
471479
oplock = REQ_OPLOCK;
472480
else

0 commit comments

Comments
 (0)