linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Christoph Hellwig <hch@infradead.org>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Al Viro <viro@zeniv.linux.org.uk>,
	Ira Weiny <ira.weiny@intel.com>
Cc: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Subject: [PATCH v3 1/4] fs/sysv: Use the offset_in_page() helper
Date: Thu, 19 Jan 2023 16:32:29 +0100	[thread overview]
Message-ID: <20230119153232.29750-2-fmdefrancesco@gmail.com> (raw)
In-Reply-To: <20230119153232.29750-1-fmdefrancesco@gmail.com>

Use the offset_in_page() helper because it is more suitable than doing
explicit subtractions between pointers to directory entries and kernel
virtual addresses of mapped pages.

Cc: Ira Weiny <ira.weiny@intel.com>
Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
---
 fs/sysv/dir.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index 88e38cd8f5c9..685379bc9d64 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -206,8 +206,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
 	return -EINVAL;
 
 got_it:
-	pos = page_offset(page) +
-			(char*)de - (char*)page_address(page);
+	pos = page_offset(page) + offset_in_page(de);
 	lock_page(page);
 	err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE);
 	if (err)
@@ -230,8 +229,7 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode)
 int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page)
 {
 	struct inode *inode = page->mapping->host;
-	char *kaddr = (char*)page_address(page);
-	loff_t pos = page_offset(page) + (char *)de - kaddr;
+	loff_t pos = page_offset(page) + offset_in_page(de);
 	int err;
 
 	lock_page(page);
@@ -328,8 +326,7 @@ void sysv_set_link(struct sysv_dir_entry *de, struct page *page,
 	struct inode *inode)
 {
 	struct inode *dir = page->mapping->host;
-	loff_t pos = page_offset(page) +
-			(char *)de-(char*)page_address(page);
+	loff_t pos = page_offset(page) + offset_in_page(de);
 	int err;
 
 	lock_page(page);
-- 
2.39.0


  reply	other threads:[~2023-01-19 15:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19 15:32 [PATCH v3 0/4] fs/sysv: Replace kmap() with kmap_local_page() Fabio M. De Francesco
2023-01-19 15:32 ` Fabio M. De Francesco [this message]
2023-01-19 15:32 ` [PATCH v3 2/4] fs/sysv: Change the signature of dir_get_page() Fabio M. De Francesco
2023-01-19 15:32 ` [PATCH v3 3/4] fs/sysv: Use dir_put_page() in sysv_rename() Fabio M. De Francesco
2023-01-19 15:32 ` [PATCH v3 4/4] fs/sysv: Replace kmap() with kmap_local_page() Fabio M. De Francesco
2023-01-20  0:54   ` Al Viro
2023-01-20  4:21   ` Al Viro
2023-01-20  4:28     ` Matthew Wilcox
2023-01-20  4:45       ` Al Viro
2023-01-20  4:54         ` Matthew Wilcox
2023-01-20  5:07           ` Al Viro
2023-01-20  5:56             ` Al Viro
2023-01-20  7:17               ` Helge Deller
2023-01-21  8:05                 ` Ira Weiny
2023-01-21 10:57                   ` Helge Deller
2023-01-21 19:26                   ` Al Viro
2023-01-23 17:14               ` Fabio M. De Francesco
2023-01-24 20:16                 ` Ira Weiny
2023-01-23 17:03     ` Fabio M. De Francesco

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230119153232.29750-2-fmdefrancesco@gmail.com \
    --to=fmdefrancesco@gmail.com \
    --cc=hch@infradead.org \
    --cc=ira.weiny@intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).