Skip to contentSkip to conversation

fs: RWF_NOWAIT should imply IOCB_NOIO

PATCH In review Jens Axboe 2 participants 2 messages Aug 11, 2020 VFS

lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

PATCH 1/1 fs: RWF_NOWAIT should imply IOCB_NOIO

With the change allowing read-ahead for IOCB_NOWAIT, we changed the RWF_NOWAIT semantics of only doing cached reads. Since we know have IOCB_NOIO to manage that specific side of it, just make RWF_NOWAIT imply IOCB_NOIO as well to restore the previous behavior.

Fixes 2e85abf053b9 ("mm: allow read-ahead with IOCB_NOWAIT set")

---

This was a known change with the buffered async read change, but we didn't have IOCB_NOIO until late in 5.8. Now that bases are synced, make the change to make RWF_NOWAIT behave like past kernels.

include/linux/fs.h +1 -1
index bd7ec3eaeed0..f1cca4bfdd7b 100644
@@ -3293,7 +3293,7 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)
 	if (flags & RWF_NOWAIT) {
 		if (!(ki->ki_filp->f_mode & FMODE_NOWAIT))
 			return -EOPNOTSUPP;
-		kiocb_flags |= IOCB_NOWAIT;
+		kiocb_flags |= IOCB_NOWAIT | IOCB_NOIO;
 	}
 	if (flags & RWF_HIPRI)
 		kiocb_flags |= IOCB_HIPRI;
Signature · 1 line
Jens Axboe
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Jens Axboe

With the change allowing read-ahead for IOCB_NOWAIT, we changed the RWF_NOWAIT semantics of only doing cached reads. Since we know have IOCB_NOIO to manage that specific side of it, just make RWF_NOWAIT imply IOCB_NOIO as well to restore the previous behavior.

Fixes 2e85abf053b9 ("mm: allow read-ahead with IOCB_NOWAIT set")

---

This was a known change with the buffered async read change, but we didn't have IOCB_NOIO until late in 5.8. Now that bases are synced, make the change to make RWF_NOWAIT behave like past kernels.

include/linux/fs.h +0 -0
index bd7ec3eaeed0..f1cca4bfdd7b 100644

include/linux/fs.h static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags) · line 3299

Quoted 8 lines
include/linux/fs.h +1 -1
@@ -3293,7 +3293,7 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)
 	if (flags & RWF_NOWAIT) {
 		if (!(ki->ki_filp->f_mode & FMODE_NOWAIT))
 			return -EOPNOTSUPP;
-		kiocb_flags |= IOCB_NOWAIT;
+		kiocb_flags |= IOCB_NOWAIT | IOCB_NOIO;
 	}
 	if (flags & RWF_HIPRI)
 		kiocb_flags |= IOCB_HIPRI;

Looks good.

Signature · 2 lines
Dave Chinner
[email protected]