diff mbox series

netfs: make ops->init_rreq() optional

Message ID 20211228124419.103020-1-jefflexu@linux.alibaba.com
State New
Headers show
Series netfs: make ops->init_rreq() optional | expand

Commit Message

Jingbo Xu Dec. 28, 2021, 12:44 p.m. UTC
Hi, recently I'm developing erofs over fscache for implementing
on-demand read, and erofs also implements an empty .init_rreq()
callback[1].

[1] https://lkml.org/lkml/2021/12/27/224

If folks don't like this cleanup and prefer empty callback in upper fs,
I'm also fine with that.
---
There's already upper fs implementing empty .init_rreq() callback, and
thus make it optional.

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
---
 fs/ceph/addr.c         | 5 -----
 fs/netfs/read_helper.c | 3 ++-
 2 files changed, 2 insertions(+), 6 deletions(-)

Comments

Jeff Layton Jan. 6, 2022, 9:49 p.m. UTC | #1
On Tue, 2021-12-28 at 20:44 +0800, Jeffle Xu wrote:
> Hi, recently I'm developing erofs over fscache for implementing
> on-demand read, and erofs also implements an empty .init_rreq()
> callback[1].
> 
> [1] https://lkml.org/lkml/2021/12/27/224
> 
> If folks don't like this cleanup and prefer empty callback in upper fs,
> I'm also fine with that.
> ---
> There's already upper fs implementing empty .init_rreq() callback, and
> thus make it optional.
> 
> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
> ---
>  fs/ceph/addr.c         | 5 -----
>  fs/netfs/read_helper.c | 3 ++-
>  2 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> index e53c8541f5b2..c3537dfd8c04 100644
> --- a/fs/ceph/addr.c
> +++ b/fs/ceph/addr.c
> @@ -291,10 +291,6 @@ static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
>  	dout("%s: result %d\n", __func__, err);
>  }
>  
> -static void ceph_init_rreq(struct netfs_read_request *rreq, struct file *file)
> -{
> -}
> -
>  static void ceph_readahead_cleanup(struct address_space *mapping, void *priv)
>  {
>  	struct inode *inode = mapping->host;
> @@ -306,7 +302,6 @@ static void ceph_readahead_cleanup(struct address_space *mapping, void *priv)
>  }
>  
>  static const struct netfs_read_request_ops ceph_netfs_read_ops = {
> -	.init_rreq		= ceph_init_rreq,
>  	.is_cache_enabled	= ceph_is_cache_enabled,
>  	.begin_cache_operation	= ceph_begin_cache_operation,
>  	.issue_op		= ceph_netfs_issue_op,
> diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c
> index 75c76cbb27cc..0befb0747c59 100644
> --- a/fs/netfs/read_helper.c
> +++ b/fs/netfs/read_helper.c
> @@ -55,7 +55,8 @@ static struct netfs_read_request *netfs_alloc_read_request(
>  		INIT_WORK(&rreq->work, netfs_rreq_work);
>  		refcount_set(&rreq->usage, 1);
>  		__set_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags);
> -		ops->init_rreq(rreq, file);
> +		if (ops->init_rreq)
> +			ops->init_rreq(rreq, file);
>  		netfs_stat(&netfs_n_rh_rreq);
>  	}
>  

This looks reasonable to me, since ceph doesn't need anything here
anyway.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Jingbo Xu Jan. 13, 2022, 2:54 a.m. UTC | #2
Hi David,

ping...


On 1/7/22 5:49 AM, Jeff Layton wrote:
> 
> This looks reasonable to me, since ceph doesn't need anything here
> anyway.
> 
> Reviewed-by: Jeff Layton <jlayton@kernel.org>
>
David Howells Jan. 13, 2022, 8:10 a.m. UTC | #3
Yep.  My patchset got pulled, so I'll take it now.

David
David Howells Jan. 13, 2022, 8:12 a.m. UTC | #4
Jeffle Xu <jefflexu@linux.alibaba.com> wrote:

> ---
> There's already upper fs implementing empty .init_rreq() callback, and
> thus make it optional.
> 
> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>

Btw, everything after the first "---" line will get stripped by patch
importation, so your S-o-b needs to be above that.

David
diff mbox series

Patch

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index e53c8541f5b2..c3537dfd8c04 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -291,10 +291,6 @@  static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
 	dout("%s: result %d\n", __func__, err);
 }
 
-static void ceph_init_rreq(struct netfs_read_request *rreq, struct file *file)
-{
-}
-
 static void ceph_readahead_cleanup(struct address_space *mapping, void *priv)
 {
 	struct inode *inode = mapping->host;
@@ -306,7 +302,6 @@  static void ceph_readahead_cleanup(struct address_space *mapping, void *priv)
 }
 
 static const struct netfs_read_request_ops ceph_netfs_read_ops = {
-	.init_rreq		= ceph_init_rreq,
 	.is_cache_enabled	= ceph_is_cache_enabled,
 	.begin_cache_operation	= ceph_begin_cache_operation,
 	.issue_op		= ceph_netfs_issue_op,
diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c
index 75c76cbb27cc..0befb0747c59 100644
--- a/fs/netfs/read_helper.c
+++ b/fs/netfs/read_helper.c
@@ -55,7 +55,8 @@  static struct netfs_read_request *netfs_alloc_read_request(
 		INIT_WORK(&rreq->work, netfs_rreq_work);
 		refcount_set(&rreq->usage, 1);
 		__set_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags);
-		ops->init_rreq(rreq, file);
+		if (ops->init_rreq)
+			ops->init_rreq(rreq, file);
 		netfs_stat(&netfs_n_rh_rreq);
 	}