linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] netfs, afs, erofs, cifs: Don't use certain internal folio_*() functions
@ 2024-01-09 18:01 David Howells
  2024-01-09 18:01 ` [PATCH 1/4] netfs: " David Howells
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: David Howells @ 2024-01-09 18:01 UTC (permalink / raw)
  To: Christian Brauner, Jeff Layton, Gao Xiang, Dominique Martinet
  Cc: David Howells, Steve French, Matthew Wilcox, Marc Dionne,
	Paulo Alcantara, Shyam Prasad N, Tom Talpey, Eric Van Hensbergen,
	Ilya Dryomov, linux-cachefs, linux-afs, linux-cifs, linux-nfs,
	ceph-devel, v9fs, linux-erofs, linux-fsdevel, linux-mm, netdev,
	linux-kernel

Hi Christian, Willy,

Here are some patches that replace the use of folio_index(),
folio_mapping() and folio_file_mapping() in some filesystem code.  I'll add
them to my netfs-lib branch.

David

David Howells (4):
  netfs: Don't use certain internal folio_*() functions
  afs: Don't use certain internal folio_*() functions
  erofs: Don't use certain internal folio_*() functions
  cifs: Don't use certain internal folio_*() functions

 fs/afs/dir.c              | 10 +++++-----
 fs/erofs/fscache.c        |  6 +++---
 fs/netfs/buffered_read.c  | 12 ++++++------
 fs/netfs/buffered_write.c | 10 +++++-----
 fs/netfs/io.c             |  2 +-
 fs/netfs/misc.c           |  2 +-
 fs/smb/client/file.c      | 10 +++++-----
 7 files changed, 26 insertions(+), 26 deletions(-)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] netfs: Don't use certain internal folio_*() functions
  2024-01-09 18:01 [PATCH 0/4] netfs, afs, erofs, cifs: Don't use certain internal folio_*() functions David Howells
@ 2024-01-09 18:01 ` David Howells
  2024-01-09 18:41   ` Jeff Layton
  2024-01-10 17:25   ` John Stoffel
  2024-01-09 18:01 ` [PATCH 2/4] afs: " David Howells
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 9+ messages in thread
From: David Howells @ 2024-01-09 18:01 UTC (permalink / raw)
  To: Christian Brauner, Jeff Layton, Gao Xiang, Dominique Martinet
  Cc: David Howells, Steve French, Matthew Wilcox, Marc Dionne,
	Paulo Alcantara, Shyam Prasad N, Tom Talpey, Eric Van Hensbergen,
	Ilya Dryomov, linux-cachefs, linux-afs, linux-cifs, linux-nfs,
	ceph-devel, v9fs, linux-erofs, linux-fsdevel, linux-mm, netdev,
	linux-kernel

Filesystems should not be using folio->index not folio_index(folio) and
folio->mapping, not folio_mapping() or folio_file_mapping() in filesystem
code.

Change this automagically with:

perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/netfs/*.c
perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/netfs/*.c
perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/netfs/*.c

Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: linux-afs@lists.infradead.org
cc: linux-cachefs@redhat.com
cc: linux-cifs@vger.kernel.org
cc: linux-erofs@lists.ozlabs.org
cc: linux-fsdevel@vger.kernel.org
---
 fs/netfs/buffered_read.c  | 12 ++++++------
 fs/netfs/buffered_write.c | 10 +++++-----
 fs/netfs/io.c             |  2 +-
 fs/netfs/misc.c           |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c
index a59e7b2edaac..3298c29b5548 100644
--- a/fs/netfs/buffered_read.c
+++ b/fs/netfs/buffered_read.c
@@ -101,7 +101,7 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq)
 		}
 
 		if (!test_bit(NETFS_RREQ_DONT_UNLOCK_FOLIOS, &rreq->flags)) {
-			if (folio_index(folio) == rreq->no_unlock_folio &&
+			if (folio->index == rreq->no_unlock_folio &&
 			    test_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags))
 				_debug("no unlock");
 			else
@@ -246,13 +246,13 @@ EXPORT_SYMBOL(netfs_readahead);
  */
 int netfs_read_folio(struct file *file, struct folio *folio)
 {
-	struct address_space *mapping = folio_file_mapping(folio);
+	struct address_space *mapping = folio->mapping;
 	struct netfs_io_request *rreq;
 	struct netfs_inode *ctx = netfs_inode(mapping->host);
 	struct folio *sink = NULL;
 	int ret;
 
-	_enter("%lx", folio_index(folio));
+	_enter("%lx", folio->index);
 
 	rreq = netfs_alloc_request(mapping, file,
 				   folio_file_pos(folio), folio_size(folio),
@@ -460,7 +460,7 @@ int netfs_write_begin(struct netfs_inode *ctx,
 		ret = PTR_ERR(rreq);
 		goto error;
 	}
-	rreq->no_unlock_folio	= folio_index(folio);
+	rreq->no_unlock_folio	= folio->index;
 	__set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
 
 	ret = netfs_begin_cache_read(rreq, ctx);
@@ -518,7 +518,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,
 			     size_t offset, size_t len)
 {
 	struct netfs_io_request *rreq;
-	struct address_space *mapping = folio_file_mapping(folio);
+	struct address_space *mapping = folio->mapping;
 	struct netfs_inode *ctx = netfs_inode(mapping->host);
 	unsigned long long start = folio_pos(folio);
 	size_t flen = folio_size(folio);
@@ -535,7 +535,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,
 		goto error;
 	}
 
-	rreq->no_unlock_folio = folio_index(folio);
+	rreq->no_unlock_folio = folio->index;
 	__set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
 	ret = netfs_begin_cache_read(rreq, ctx);
 	if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS)
diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c
index de517ca70d91..3afb1a0f92d1 100644
--- a/fs/netfs/buffered_write.c
+++ b/fs/netfs/buffered_write.c
@@ -343,7 +343,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
 			break;
 		default:
 			WARN(true, "Unexpected modify type %u ix=%lx\n",
-			     howto, folio_index(folio));
+			     howto, folio->index);
 			ret = -EIO;
 			goto error_folio_unlock;
 		}
@@ -648,7 +648,7 @@ static void netfs_pages_written_back(struct netfs_io_request *wreq)
 	xas_for_each(&xas, folio, last) {
 		WARN(!folio_test_writeback(folio),
 		     "bad %zx @%llx page %lx %lx\n",
-		     wreq->len, wreq->start, folio_index(folio), last);
+		     wreq->len, wreq->start, folio->index, last);
 
 		if ((finfo = netfs_folio_info(folio))) {
 			/* Streaming writes cannot be redirtied whilst under
@@ -795,7 +795,7 @@ static void netfs_extend_writeback(struct address_space *mapping,
 				continue;
 			if (xa_is_value(folio))
 				break;
-			if (folio_index(folio) != index) {
+			if (folio->index != index) {
 				xas_reset(xas);
 				break;
 			}
@@ -901,7 +901,7 @@ static ssize_t netfs_write_back_from_locked_folio(struct address_space *mapping,
 	long count = wbc->nr_to_write;
 	int ret;
 
-	_enter(",%lx,%llx-%llx,%u", folio_index(folio), start, end, caching);
+	_enter(",%lx,%llx-%llx,%u", folio->index, start, end, caching);
 
 	wreq = netfs_alloc_request(mapping, NULL, start, folio_size(folio),
 				   NETFS_WRITEBACK);
@@ -1047,7 +1047,7 @@ static ssize_t netfs_writepages_begin(struct address_space *mapping,
 
 	start = folio_pos(folio); /* May regress with THPs */
 
-	_debug("wback %lx", folio_index(folio));
+	_debug("wback %lx", folio->index);
 
 	/* At this point we hold neither the i_pages lock nor the page lock:
 	 * the page may be truncated or invalidated (changing page->mapping to
diff --git a/fs/netfs/io.c b/fs/netfs/io.c
index 4309edf33862..e8ff1e61ce79 100644
--- a/fs/netfs/io.c
+++ b/fs/netfs/io.c
@@ -124,7 +124,7 @@ static void netfs_rreq_unmark_after_write(struct netfs_io_request *rreq,
 			/* We might have multiple writes from the same huge
 			 * folio, but we mustn't unlock a folio more than once.
 			 */
-			if (have_unlocked && folio_index(folio) <= unlocked)
+			if (have_unlocked && folio->index <= unlocked)
 				continue;
 			unlocked = folio_next_index(folio) - 1;
 			trace_netfs_folio(folio, netfs_folio_trace_end_copy);
diff --git a/fs/netfs/misc.c b/fs/netfs/misc.c
index 0e3af37fc924..90051ced8e2a 100644
--- a/fs/netfs/misc.c
+++ b/fs/netfs/misc.c
@@ -180,7 +180,7 @@ void netfs_invalidate_folio(struct folio *folio, size_t offset, size_t length)
 	struct netfs_folio *finfo = NULL;
 	size_t flen = folio_size(folio);
 
-	_enter("{%lx},%zx,%zx", folio_index(folio), offset, length);
+	_enter("{%lx},%zx,%zx", folio->index, offset, length);
 
 	folio_wait_fscache(folio);
 


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] afs: Don't use certain internal folio_*() functions
  2024-01-09 18:01 [PATCH 0/4] netfs, afs, erofs, cifs: Don't use certain internal folio_*() functions David Howells
  2024-01-09 18:01 ` [PATCH 1/4] netfs: " David Howells
@ 2024-01-09 18:01 ` David Howells
  2024-01-09 18:01 ` [PATCH 3/4] erofs: " David Howells
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2024-01-09 18:01 UTC (permalink / raw)
  To: Christian Brauner, Jeff Layton, Gao Xiang, Dominique Martinet
  Cc: David Howells, Steve French, Matthew Wilcox, Marc Dionne,
	Paulo Alcantara, Shyam Prasad N, Tom Talpey, Eric Van Hensbergen,
	Ilya Dryomov, linux-cachefs, linux-afs, linux-cifs, linux-nfs,
	ceph-devel, v9fs, linux-erofs, linux-fsdevel, linux-mm, netdev,
	linux-kernel

Filesystems should not be using folio->index not folio_index(folio) and
folio->mapping, not folio_mapping() or folio_file_mapping() in filesystem
code.

Change this automagically with:

perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/afs/*.c
perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/afs/*.c
perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/afs/*.c

Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
---
 fs/afs/dir.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 5219182e52e1..35f7da6963fa 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -124,7 +124,7 @@ static void afs_dir_read_cleanup(struct afs_read *req)
 		if (xas_retry(&xas, folio))
 			continue;
 		BUG_ON(xa_is_value(folio));
-		ASSERTCMP(folio_file_mapping(folio), ==, mapping);
+		ASSERTCMP(folio->mapping, ==, mapping);
 
 		folio_put(folio);
 	}
@@ -202,12 +202,12 @@ static void afs_dir_dump(struct afs_vnode *dvnode, struct afs_read *req)
 		if (xas_retry(&xas, folio))
 			continue;
 
-		BUG_ON(folio_file_mapping(folio) != mapping);
+		BUG_ON(folio->mapping != mapping);
 
 		size = min_t(loff_t, folio_size(folio), req->actual_len - folio_pos(folio));
 		for (offset = 0; offset < size; offset += sizeof(*block)) {
 			block = kmap_local_folio(folio, offset);
-			pr_warn("[%02lx] %32phN\n", folio_index(folio) + offset, block);
+			pr_warn("[%02lx] %32phN\n", folio->index + offset, block);
 			kunmap_local(block);
 		}
 	}
@@ -233,7 +233,7 @@ static int afs_dir_check(struct afs_vnode *dvnode, struct afs_read *req)
 		if (xas_retry(&xas, folio))
 			continue;
 
-		BUG_ON(folio_file_mapping(folio) != mapping);
+		BUG_ON(folio->mapping != mapping);
 
 		if (!afs_dir_check_folio(dvnode, folio, req->actual_len)) {
 			afs_dir_dump(dvnode, req);
@@ -2014,7 +2014,7 @@ static bool afs_dir_release_folio(struct folio *folio, gfp_t gfp_flags)
 {
 	struct afs_vnode *dvnode = AFS_FS_I(folio_inode(folio));
 
-	_enter("{{%llx:%llu}[%lu]}", dvnode->fid.vid, dvnode->fid.vnode, folio_index(folio));
+	_enter("{{%llx:%llu}[%lu]}", dvnode->fid.vid, dvnode->fid.vnode, folio->index);
 
 	folio_detach_private(folio);
 


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] erofs: Don't use certain internal folio_*() functions
  2024-01-09 18:01 [PATCH 0/4] netfs, afs, erofs, cifs: Don't use certain internal folio_*() functions David Howells
  2024-01-09 18:01 ` [PATCH 1/4] netfs: " David Howells
  2024-01-09 18:01 ` [PATCH 2/4] afs: " David Howells
@ 2024-01-09 18:01 ` David Howells
  2024-01-09 18:11   ` Gao Xiang
  2024-01-09 18:01 ` [PATCH 4/4] cifs: " David Howells
  2024-01-09 18:42 ` [PATCH 0/4] netfs, afs, erofs, " Jeff Layton
  4 siblings, 1 reply; 9+ messages in thread
From: David Howells @ 2024-01-09 18:01 UTC (permalink / raw)
  To: Christian Brauner, Jeff Layton, Gao Xiang, Dominique Martinet
  Cc: David Howells, Steve French, Matthew Wilcox, Marc Dionne,
	Paulo Alcantara, Shyam Prasad N, Tom Talpey, Eric Van Hensbergen,
	Ilya Dryomov, linux-cachefs, linux-afs, linux-cifs, linux-nfs,
	ceph-devel, v9fs, linux-erofs, linux-fsdevel, linux-mm, netdev,
	linux-kernel, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu

Filesystems should not be using folio->index not folio_index(folio) and
folio->mapping, not folio_mapping() or folio_file_mapping() in filesystem
code.

Change this automagically with:

perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/erofs/*.c
perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/erofs/*.c
perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/erofs/*.c

Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Gao Xiang <xiang@kernel.org>
cc: Chao Yu <chao@kernel.org>
cc: Yue Hu <huyue2@coolpad.com>
cc: Jeffle Xu <jefflexu@linux.alibaba.com>
cc: linux-erofs@lists.ozlabs.org
cc: linux-fsdevel@vger.kernel.org
---
 fs/erofs/fscache.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 87ff35bff8d5..bc12030393b2 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -165,10 +165,10 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie,
 static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
 {
 	int ret;
-	struct erofs_fscache *ctx = folio_mapping(folio)->host->i_private;
+	struct erofs_fscache *ctx = folio->mapping->host->i_private;
 	struct erofs_fscache_request *req;
 
-	req = erofs_fscache_req_alloc(folio_mapping(folio),
+	req = erofs_fscache_req_alloc(folio->mapping,
 				folio_pos(folio), folio_size(folio));
 	if (IS_ERR(req)) {
 		folio_unlock(folio);
@@ -276,7 +276,7 @@ static int erofs_fscache_read_folio(struct file *file, struct folio *folio)
 	struct erofs_fscache_request *req;
 	int ret;
 
-	req = erofs_fscache_req_alloc(folio_mapping(folio),
+	req = erofs_fscache_req_alloc(folio->mapping,
 			folio_pos(folio), folio_size(folio));
 	if (IS_ERR(req)) {
 		folio_unlock(folio);


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] cifs: Don't use certain internal folio_*() functions
  2024-01-09 18:01 [PATCH 0/4] netfs, afs, erofs, cifs: Don't use certain internal folio_*() functions David Howells
                   ` (2 preceding siblings ...)
  2024-01-09 18:01 ` [PATCH 3/4] erofs: " David Howells
@ 2024-01-09 18:01 ` David Howells
  2024-01-09 18:42 ` [PATCH 0/4] netfs, afs, erofs, " Jeff Layton
  4 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2024-01-09 18:01 UTC (permalink / raw)
  To: Christian Brauner, Jeff Layton, Gao Xiang, Dominique Martinet
  Cc: David Howells, Steve French, Matthew Wilcox, Marc Dionne,
	Paulo Alcantara, Shyam Prasad N, Tom Talpey, Eric Van Hensbergen,
	Ilya Dryomov, linux-cachefs, linux-afs, linux-cifs, linux-nfs,
	ceph-devel, v9fs, linux-erofs, linux-fsdevel, linux-mm, netdev,
	linux-kernel, Steve French, Ronnie Sahlberg

Filesystems should not be using folio->index not folio_index(folio) and
folio->mapping, not folio_mapping() or folio_file_mapping() in filesystem
code.

Change this automagically with:

perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/smb/client/*.c
perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/smb/client/*.c
perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/smb/client/*.c

Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: Steve French <sfrench@samba.org>
cc: Paulo Alcantara <pc@manguebit.com>
cc: Ronnie Sahlberg <lsahlber@redhat.com>
cc: Shyam Prasad N <sprasad@microsoft.com>
cc: Tom Talpey <tom@talpey.com>
cc: linux-cifs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
---
 fs/smb/client/file.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index b02b7f0a47dc..253e06a7875e 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -87,7 +87,7 @@ void cifs_pages_written_back(struct inode *inode, loff_t start, unsigned int len
 			continue;
 		if (!folio_test_writeback(folio)) {
 			WARN_ONCE(1, "bad %x @%llx page %lx %lx\n",
-				  len, start, folio_index(folio), end);
+				  len, start, folio->index, end);
 			continue;
 		}
 
@@ -120,7 +120,7 @@ void cifs_pages_write_failed(struct inode *inode, loff_t start, unsigned int len
 			continue;
 		if (!folio_test_writeback(folio)) {
 			WARN_ONCE(1, "bad %x @%llx page %lx %lx\n",
-				  len, start, folio_index(folio), end);
+				  len, start, folio->index, end);
 			continue;
 		}
 
@@ -151,7 +151,7 @@ void cifs_pages_write_redirty(struct inode *inode, loff_t start, unsigned int le
 	xas_for_each(&xas, folio, end) {
 		if (!folio_test_writeback(folio)) {
 			WARN_ONCE(1, "bad %x @%llx page %lx %lx\n",
-				  len, start, folio_index(folio), end);
+				  len, start, folio->index, end);
 			continue;
 		}
 
@@ -2649,7 +2649,7 @@ static void cifs_extend_writeback(struct address_space *mapping,
 				continue;
 			if (xa_is_value(folio))
 				break;
-			if (folio_index(folio) != index)
+			if (folio->index != index)
 				break;
 			if (!folio_try_get_rcu(folio)) {
 				xas_reset(&xas);
@@ -2899,7 +2899,7 @@ static int cifs_writepages_region(struct address_space *mapping,
 					goto skip_write;
 			}
 
-			if (folio_mapping(folio) != mapping ||
+			if (folio->mapping != mapping ||
 			    !folio_test_dirty(folio)) {
 				start += folio_size(folio);
 				folio_unlock(folio);


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] erofs: Don't use certain internal folio_*() functions
  2024-01-09 18:01 ` [PATCH 3/4] erofs: " David Howells
@ 2024-01-09 18:11   ` Gao Xiang
  0 siblings, 0 replies; 9+ messages in thread
From: Gao Xiang @ 2024-01-09 18:11 UTC (permalink / raw)
  To: David Howells, Christian Brauner, Jeff Layton, Dominique Martinet
  Cc: Steve French, Matthew Wilcox, Marc Dionne, Paulo Alcantara,
	Shyam Prasad N, Tom Talpey, Eric Van Hensbergen, Ilya Dryomov,
	linux-cachefs, linux-afs, linux-cifs, linux-nfs, ceph-devel,
	v9fs, linux-erofs, linux-fsdevel, linux-mm, netdev, linux-kernel,
	Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu



On 2024/1/10 02:01, David Howells wrote:
> Filesystems should not be using folio->index not folio_index(folio) and
> folio->mapping, not folio_mapping() or folio_file_mapping() in filesystem
> code.
> 
> Change this automagically with:
> 
> perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/erofs/*.c
> perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/erofs/*.c
> perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/erofs/*.c
> 
> Reported-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Gao Xiang <xiang@kernel.org>
> cc: Chao Yu <chao@kernel.org>
> cc: Yue Hu <huyue2@coolpad.com>
> cc: Jeffle Xu <jefflexu@linux.alibaba.com>
> cc: linux-erofs@lists.ozlabs.org
> cc: linux-fsdevel@vger.kernel.org

Thank you, David!

Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>

(I've asked Jingbo to find some free slot to refine
  this part for later compressed data adaption.  Yet that
  is another separate story.  The patch looks good to me.)

Thanks,
Gao Xiang

> ---
>   fs/erofs/fscache.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
> index 87ff35bff8d5..bc12030393b2 100644
> --- a/fs/erofs/fscache.c
> +++ b/fs/erofs/fscache.c
> @@ -165,10 +165,10 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie,
>   static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
>   {
>   	int ret;
> -	struct erofs_fscache *ctx = folio_mapping(folio)->host->i_private;
> +	struct erofs_fscache *ctx = folio->mapping->host->i_private;
>   	struct erofs_fscache_request *req;
>   
> -	req = erofs_fscache_req_alloc(folio_mapping(folio),
> +	req = erofs_fscache_req_alloc(folio->mapping,
>   				folio_pos(folio), folio_size(folio));
>   	if (IS_ERR(req)) {
>   		folio_unlock(folio);
> @@ -276,7 +276,7 @@ static int erofs_fscache_read_folio(struct file *file, struct folio *folio)
>   	struct erofs_fscache_request *req;
>   	int ret;
>   
> -	req = erofs_fscache_req_alloc(folio_mapping(folio),
> +	req = erofs_fscache_req_alloc(folio->mapping,
>   			folio_pos(folio), folio_size(folio));
>   	if (IS_ERR(req)) {
>   		folio_unlock(folio);
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] netfs: Don't use certain internal folio_*() functions
  2024-01-09 18:01 ` [PATCH 1/4] netfs: " David Howells
@ 2024-01-09 18:41   ` Jeff Layton
  2024-01-10 17:25   ` John Stoffel
  1 sibling, 0 replies; 9+ messages in thread
From: Jeff Layton @ 2024-01-09 18:41 UTC (permalink / raw)
  To: David Howells, Christian Brauner, Gao Xiang, Dominique Martinet
  Cc: Steve French, Matthew Wilcox, Marc Dionne, Paulo Alcantara,
	Shyam Prasad N, Tom Talpey, Eric Van Hensbergen, Ilya Dryomov,
	linux-cachefs, linux-afs, linux-cifs, linux-nfs, ceph-devel,
	v9fs, linux-erofs, linux-fsdevel, linux-mm, netdev, linux-kernel

On Tue, 2024-01-09 at 18:01 +0000, David Howells wrote:
> Filesystems should not be using folio->index not folio_index(folio) and
> folio->mapping, not folio_mapping() or folio_file_mapping() in filesystem
> code.
> 

nit: Awkwardly worded sentence above. The first part sounds wrong too:

"Filesystems should not be using folio->index not folio_index(folio)"

I'm guessing you mean:

"Filesystems should be using folio->index, not folio_index(folio) since
they know that it's in the pagecache."

> Change this automagically with:
> 
> perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/netfs/*.c
> perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/netfs/*.c
> perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/netfs/*.c

FWIW, coccinelle is really much nicer for this sort of thing.

> Reported-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Jeff Layton <jlayton@kernel.org>
> cc: linux-afs@lists.infradead.org
> cc: linux-cachefs@redhat.com
> cc: linux-cifs@vger.kernel.org
> cc: linux-erofs@lists.ozlabs.org
> cc: linux-fsdevel@vger.kernel.org
> ---
>  fs/netfs/buffered_read.c  | 12 ++++++------
>  fs/netfs/buffered_write.c | 10 +++++-----
>  fs/netfs/io.c             |  2 +-
>  fs/netfs/misc.c           |  2 +-
>  4 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c
> index a59e7b2edaac..3298c29b5548 100644
> --- a/fs/netfs/buffered_read.c
> +++ b/fs/netfs/buffered_read.c
> @@ -101,7 +101,7 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq)
>  		}
>  
>  		if (!test_bit(NETFS_RREQ_DONT_UNLOCK_FOLIOS, &rreq->flags)) {
> -			if (folio_index(folio) == rreq->no_unlock_folio &&
> +			if (folio->index == rreq->no_unlock_folio &&
>  			    test_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags))
>  				_debug("no unlock");
>  			else
> @@ -246,13 +246,13 @@ EXPORT_SYMBOL(netfs_readahead);
>   */
>  int netfs_read_folio(struct file *file, struct folio *folio)
>  {
> -	struct address_space *mapping = folio_file_mapping(folio);
> +	struct address_space *mapping = folio->mapping;
>  	struct netfs_io_request *rreq;
>  	struct netfs_inode *ctx = netfs_inode(mapping->host);
>  	struct folio *sink = NULL;
>  	int ret;
>  
> -	_enter("%lx", folio_index(folio));
> +	_enter("%lx", folio->index);
>  
>  	rreq = netfs_alloc_request(mapping, file,
>  				   folio_file_pos(folio), folio_size(folio),
> @@ -460,7 +460,7 @@ int netfs_write_begin(struct netfs_inode *ctx,
>  		ret = PTR_ERR(rreq);
>  		goto error;
>  	}
> -	rreq->no_unlock_folio	= folio_index(folio);
> +	rreq->no_unlock_folio	= folio->index;
>  	__set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
>  
>  	ret = netfs_begin_cache_read(rreq, ctx);
> @@ -518,7 +518,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,
>  			     size_t offset, size_t len)
>  {
>  	struct netfs_io_request *rreq;
> -	struct address_space *mapping = folio_file_mapping(folio);
> +	struct address_space *mapping = folio->mapping;
>  	struct netfs_inode *ctx = netfs_inode(mapping->host);
>  	unsigned long long start = folio_pos(folio);
>  	size_t flen = folio_size(folio);
> @@ -535,7 +535,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,
>  		goto error;
>  	}
>  
> -	rreq->no_unlock_folio = folio_index(folio);
> +	rreq->no_unlock_folio = folio->index;
>  	__set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
>  	ret = netfs_begin_cache_read(rreq, ctx);
>  	if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS)
> diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c
> index de517ca70d91..3afb1a0f92d1 100644
> --- a/fs/netfs/buffered_write.c
> +++ b/fs/netfs/buffered_write.c
> @@ -343,7 +343,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
>  			break;
>  		default:
>  			WARN(true, "Unexpected modify type %u ix=%lx\n",
> -			     howto, folio_index(folio));
> +			     howto, folio->index);
>  			ret = -EIO;
>  			goto error_folio_unlock;
>  		}
> @@ -648,7 +648,7 @@ static void netfs_pages_written_back(struct netfs_io_request *wreq)
>  	xas_for_each(&xas, folio, last) {
>  		WARN(!folio_test_writeback(folio),
>  		     "bad %zx @%llx page %lx %lx\n",
> -		     wreq->len, wreq->start, folio_index(folio), last);
> +		     wreq->len, wreq->start, folio->index, last);
>  
>  		if ((finfo = netfs_folio_info(folio))) {
>  			/* Streaming writes cannot be redirtied whilst under
> @@ -795,7 +795,7 @@ static void netfs_extend_writeback(struct address_space *mapping,
>  				continue;
>  			if (xa_is_value(folio))
>  				break;
> -			if (folio_index(folio) != index) {
> +			if (folio->index != index) {
>  				xas_reset(xas);
>  				break;
>  			}
> @@ -901,7 +901,7 @@ static ssize_t netfs_write_back_from_locked_folio(struct address_space *mapping,
>  	long count = wbc->nr_to_write;
>  	int ret;
>  
> -	_enter(",%lx,%llx-%llx,%u", folio_index(folio), start, end, caching);
> +	_enter(",%lx,%llx-%llx,%u", folio->index, start, end, caching);
>  
>  	wreq = netfs_alloc_request(mapping, NULL, start, folio_size(folio),
>  				   NETFS_WRITEBACK);
> @@ -1047,7 +1047,7 @@ static ssize_t netfs_writepages_begin(struct address_space *mapping,
>  
>  	start = folio_pos(folio); /* May regress with THPs */
>  
> -	_debug("wback %lx", folio_index(folio));
> +	_debug("wback %lx", folio->index);
>  
>  	/* At this point we hold neither the i_pages lock nor the page lock:
>  	 * the page may be truncated or invalidated (changing page->mapping to
> diff --git a/fs/netfs/io.c b/fs/netfs/io.c
> index 4309edf33862..e8ff1e61ce79 100644
> --- a/fs/netfs/io.c
> +++ b/fs/netfs/io.c
> @@ -124,7 +124,7 @@ static void netfs_rreq_unmark_after_write(struct netfs_io_request *rreq,
>  			/* We might have multiple writes from the same huge
>  			 * folio, but we mustn't unlock a folio more than once.
>  			 */
> -			if (have_unlocked && folio_index(folio) <= unlocked)
> +			if (have_unlocked && folio->index <= unlocked)
>  				continue;
>  			unlocked = folio_next_index(folio) - 1;
>  			trace_netfs_folio(folio, netfs_folio_trace_end_copy);
> diff --git a/fs/netfs/misc.c b/fs/netfs/misc.c
> index 0e3af37fc924..90051ced8e2a 100644
> --- a/fs/netfs/misc.c
> +++ b/fs/netfs/misc.c
> @@ -180,7 +180,7 @@ void netfs_invalidate_folio(struct folio *folio, size_t offset, size_t length)
>  	struct netfs_folio *finfo = NULL;
>  	size_t flen = folio_size(folio);
>  
> -	_enter("{%lx},%zx,%zx", folio_index(folio), offset, length);
> +	_enter("{%lx},%zx,%zx", folio->index, offset, length);
>  
>  	folio_wait_fscache(folio);
>  
> 

Patch seems fine otherwise:

Reviewed-by: Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] netfs, afs, erofs, cifs: Don't use certain internal folio_*() functions
  2024-01-09 18:01 [PATCH 0/4] netfs, afs, erofs, cifs: Don't use certain internal folio_*() functions David Howells
                   ` (3 preceding siblings ...)
  2024-01-09 18:01 ` [PATCH 4/4] cifs: " David Howells
@ 2024-01-09 18:42 ` Jeff Layton
  4 siblings, 0 replies; 9+ messages in thread
From: Jeff Layton @ 2024-01-09 18:42 UTC (permalink / raw)
  To: David Howells, Christian Brauner, Gao Xiang, Dominique Martinet
  Cc: Steve French, Matthew Wilcox, Marc Dionne, Paulo Alcantara,
	Shyam Prasad N, Tom Talpey, Eric Van Hensbergen, Ilya Dryomov,
	linux-cachefs, linux-afs, linux-cifs, linux-nfs, ceph-devel,
	v9fs, linux-erofs, linux-fsdevel, linux-mm, netdev, linux-kernel

On Tue, 2024-01-09 at 18:01 +0000, David Howells wrote:
> Hi Christian, Willy,
> 
> Here are some patches that replace the use of folio_index(),
> folio_mapping() and folio_file_mapping() in some filesystem code.  I'll add
> them to my netfs-lib branch.
> 
> David
> 
> David Howells (4):
>   netfs: Don't use certain internal folio_*() functions
>   afs: Don't use certain internal folio_*() functions
>   erofs: Don't use certain internal folio_*() functions
>   cifs: Don't use certain internal folio_*() functions
> 
>  fs/afs/dir.c              | 10 +++++-----
>  fs/erofs/fscache.c        |  6 +++---
>  fs/netfs/buffered_read.c  | 12 ++++++------
>  fs/netfs/buffered_write.c | 10 +++++-----
>  fs/netfs/io.c             |  2 +-
>  fs/netfs/misc.c           |  2 +-
>  fs/smb/client/file.c      | 10 +++++-----
>  7 files changed, 26 insertions(+), 26 deletions(-)
> 

Looks like a fairly straightforward cleanup. Aside from the changelog
comments on patch #1:

Reviewed-by: Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] netfs: Don't use certain internal folio_*() functions
  2024-01-09 18:01 ` [PATCH 1/4] netfs: " David Howells
  2024-01-09 18:41   ` Jeff Layton
@ 2024-01-10 17:25   ` John Stoffel
  1 sibling, 0 replies; 9+ messages in thread
From: John Stoffel @ 2024-01-10 17:25 UTC (permalink / raw)
  To: David Howells
  Cc: Christian Brauner, Jeff Layton, Gao Xiang, Dominique Martinet,
	Steve French, Matthew Wilcox, Marc Dionne, Paulo Alcantara,
	Shyam Prasad N, Tom Talpey, Eric Van Hensbergen, Ilya Dryomov,
	linux-cachefs, linux-afs, linux-cifs, linux-nfs, ceph-devel,
	v9fs, linux-erofs, linux-fsdevel, linux-mm, netdev, linux-kernel

>>>>> "David" == David Howells <dhowells@redhat.com> writes:

> Filesystems should not be using folio->index not folio_index(folio)
                     ^^^

I think you have an extra 'not' in all four patch comments. 

> and folio-> mapping, not folio_mapping() or folio_file_mapping() in
> filesystem code.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-01-10 17:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-09 18:01 [PATCH 0/4] netfs, afs, erofs, cifs: Don't use certain internal folio_*() functions David Howells
2024-01-09 18:01 ` [PATCH 1/4] netfs: " David Howells
2024-01-09 18:41   ` Jeff Layton
2024-01-10 17:25   ` John Stoffel
2024-01-09 18:01 ` [PATCH 2/4] afs: " David Howells
2024-01-09 18:01 ` [PATCH 3/4] erofs: " David Howells
2024-01-09 18:11   ` Gao Xiang
2024-01-09 18:01 ` [PATCH 4/4] cifs: " David Howells
2024-01-09 18:42 ` [PATCH 0/4] netfs, afs, erofs, " Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).