mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 1/4] minixfs: use offset_in_page()
Date: Wed, 13 Dec 2023 00:08:46 +0000	[thread overview]
Message-ID: <20231213000849.2748576-1-viro@zeniv.linux.org.uk> (raw)
In-Reply-To: <20231213000656.GI1674809@ZenIV>

It's cheaper and more idiomatic than subtracting page_address()
of the corresponding page...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/minix/dir.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/minix/dir.c b/fs/minix/dir.c
index 62c313fc9a49..34a5d17f0796 100644
--- a/fs/minix/dir.c
+++ b/fs/minix/dir.c
@@ -268,7 +268,7 @@ int minix_add_link(struct dentry *dentry, struct inode *inode)
 	return -EINVAL;
 
 got_it:
-	pos = page_offset(page) + p - (char *)page_address(page);
+	pos = page_offset(page) + offset_in_page(p);
 	err = minix_prepare_chunk(page, pos, sbi->s_dirsize);
 	if (err)
 		goto out_unlock;
@@ -296,8 +296,7 @@ int minix_add_link(struct dentry *dentry, struct inode *inode)
 int minix_delete_entry(struct minix_dir_entry *de, struct page *page)
 {
 	struct inode *inode = page->mapping->host;
-	char *kaddr = page_address(page);
-	loff_t pos = page_offset(page) + (char*)de - kaddr;
+	loff_t pos = page_offset(page) + offset_in_page(de);
 	struct minix_sb_info *sbi = minix_sb(inode->i_sb);
 	unsigned len = sbi->s_dirsize;
 	int err;
@@ -421,8 +420,7 @@ int minix_set_link(struct minix_dir_entry *de, struct page *page,
 {
 	struct inode *dir = page->mapping->host;
 	struct minix_sb_info *sbi = minix_sb(dir->i_sb);
-	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.2


  reply	other threads:[~2023-12-13  0:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13  0:06 [minixfs] conversion to kmap_local_page() Al Viro
2023-12-13  0:08 ` Al Viro [this message]
2023-12-13  0:08   ` [PATCH 2/4] minixfs: change the signature of dir_get_page() Al Viro
2023-12-14 11:58     ` Fabio M. De Francesco
2023-12-13  0:08   ` [PATCH 3/4] minixfs: Use dir_put_page() in minix_unlink() and minix_rename() Al Viro
2023-12-14 12:02     ` Fabio M. De Francesco
2023-12-13  0:08   ` [PATCH 4/4] minixfs: switch to kmap_local_page() Al Viro
2023-12-14 12:06     ` Fabio M. De Francesco
2023-12-14 11:51   ` [PATCH 1/4] minixfs: use offset_in_page() 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=20231213000849.2748576-1-viro@zeniv.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®