Skip to contentSkip to conversation

btrfs: remove trivial nowait check

PATCH In review [email protected] 2 participants 2 messages Feb 1, 2020 – Feb 6, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: remove trivial nowait check

From: chenqiwu <[email protected]>

Remove trivial nowait check for btrfs_file_write_iter(), since buffered writes will return -EINVAL if IOCB_NOWAIT passed in the follow-up function generic_write_checks().

---
 fs/btrfs/file.c | 4 ----
 1 file changed, 4 deletions(-)
fs/btrfs/file.c +0 -4
index a16da27..320af95 100644
@@ -1896,10 +1896,6 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
 	loff_t oldsize;
 	int clean_page = 0;
 
-	if (!(iocb->ki_flags & IOCB_DIRECT) &&
-	    (iocb->ki_flags & IOCB_NOWAIT))
-		return -EOPNOTSUPP;
-
 	if (iocb->ki_flags & IOCB_NOWAIT) {
 		if (!inode_trylock(inode))
 			return -EAGAIN;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 16 lines · On Sat, Feb 01, 2020 at 11:51:33AM +0800, [email protected] wrote:

From: chenqiwu <[email protected]>

Remove trivial nowait check for btrfs_file_write_iter(), since buffered writes will return -EINVAL if IOCB_NOWAIT passed in the follow-up function generic_write_checks().

---
 fs/btrfs/file.c | 4 ----
 1 file changed, 4 deletions(-)
fs/btrfs/file.c +0 -0
index a16da27..320af95 100644

fs/btrfs/file.c static ssize_t btrfs_file_write_iter(struct kiocb *iocb, · line 1901

Quoted 6 lines
fs/btrfs/file.c +0 -3
@@ -1896,10 +1896,6 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
 	loff_t oldsize;
 	int clean_page = 0;
 
-	if (!(iocb->ki_flags & IOCB_DIRECT) &&
-	    (iocb->ki_flags & IOCB_NOWAIT))
-		return -EOPNOTSUPP;

This returns a different error code for the condition than generic_write_checks, and is checked without the inode lock. I'm not sure if we should remove it, it's a fast-fail path for buffered+nowait, that probably does not happen that often.