Skip to content

Commit a987c7c

Browse files
iamreadytootorvalds
authored andcommitted
ocfs2: fix ocfs2_sync_file() if filesystem is readonly
If filesystem is readonly, there is no need to flush drive's caches or force any uncommitted transactions. [[email protected]: return -EROFS, not 0] Signed-off-by: Younger Liu <[email protected]> Cc: Joel Becker <[email protected]> Cc: Mark Fasheh <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 79040ca commit a987c7c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/ocfs2/file.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ static int ocfs2_sync_file(struct file *file, loff_t start, loff_t end,
185185
file->f_path.dentry->d_name.name,
186186
(unsigned long long)datasync);
187187

188+
if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
189+
return -EROFS;
190+
188191
err = filemap_write_and_wait_range(inode->i_mapping, start, end);
189192
if (err)
190193
return err;

0 commit comments

Comments
 (0)