Allow O_NONBLOCK to be noted in the netfs_io_request struct. Also add a
flag, NETFS_RREQ_BLOCKED to record if we did block.
Signed-off-by: David Howells <[email protected]>
cc: Jeff Layton <[email protected]>
cc: [email protected]
cc: [email protected]
cc: [email protected]
---
fs/netfs/objects.c | 2 ++
include/linux/netfs.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c
index 85f428fc52e6..e41f9fc9bdd2 100644
--- a/fs/netfs/objects.c
+++ b/fs/netfs/objects.c
@@ -37,6 +37,8 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping,
INIT_LIST_HEAD(&rreq->subrequests);
refcount_set(&rreq->ref, 1);
__set_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags);
+ if (file && file->f_flags & O_NONBLOCK)
+ __set_bit(NETFS_RREQ_NONBLOCK, &rreq->flags);
if (rreq->netfs_ops->init_request) {
ret = rreq->netfs_ops->init_request(rreq, file);
if (ret < 0) {
diff --git a/include/linux/netfs.h b/include/linux/netfs.h
index 282511090ead..b92e982ac4a0 100644
--- a/include/linux/netfs.h
+++ b/include/linux/netfs.h
@@ -205,6 +205,8 @@ struct netfs_io_request {
#define NETFS_RREQ_DONT_UNLOCK_FOLIOS 3 /* Don't unlock the folios on completion */
#define NETFS_RREQ_FAILED 4 /* The request failed */
#define NETFS_RREQ_IN_PROGRESS 5 /* Unlocked when the request completes */
+#define NETFS_RREQ_NONBLOCK 6 /* Don't block if possible (O_NONBLOCK) */
+#define NETFS_RREQ_BLOCKED 7 /* We blocked */
const struct netfs_request_ops *netfs_ops;
};
On Fri, 2023-10-13 at 16:56 +0100, David Howells wrote:
> Allow O_NONBLOCK to be noted in the netfs_io_request struct. Also add a
> flag, NETFS_RREQ_BLOCKED to record if we did block.
>
> Signed-off-by: David Howells <[email protected]>
> cc: Jeff Layton <[email protected]>
> cc: [email protected]
> cc: [email protected]
> cc: [email protected]
> ---
> fs/netfs/objects.c | 2 ++
> include/linux/netfs.h | 2 ++
> 2 files changed, 4 insertions(+)
>
> diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c
> index 85f428fc52e6..e41f9fc9bdd2 100644
> --- a/fs/netfs/objects.c
> +++ b/fs/netfs/objects.c
> @@ -37,6 +37,8 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping,
> INIT_LIST_HEAD(&rreq->subrequests);
> refcount_set(&rreq->ref, 1);
> __set_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags);
> + if (file && file->f_flags & O_NONBLOCK)
> + __set_bit(NETFS_RREQ_NONBLOCK, &rreq->flags);
> if (rreq->netfs_ops->init_request) {
> ret = rreq->netfs_ops->init_request(rreq, file);
> if (ret < 0) {
> diff --git a/include/linux/netfs.h b/include/linux/netfs.h
> index 282511090ead..b92e982ac4a0 100644
> --- a/include/linux/netfs.h
> +++ b/include/linux/netfs.h
> @@ -205,6 +205,8 @@ struct netfs_io_request {
> #define NETFS_RREQ_DONT_UNLOCK_FOLIOS 3 /* Don't unlock the folios on completion */
> #define NETFS_RREQ_FAILED 4 /* The request failed */
> #define NETFS_RREQ_IN_PROGRESS 5 /* Unlocked when the request completes */
> +#define NETFS_RREQ_NONBLOCK 6 /* Don't block if possible (O_NONBLOCK) */
> +#define NETFS_RREQ_BLOCKED 7 /* We blocked */
> const struct netfs_request_ops *netfs_ops;
> };
>
>
I'd prefer to see this patch squashed in with the first patches that
actually check for these flags. I can't look at this patch alone and
tell how it'll be used.
--
Jeff Layton <[email protected]>