linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Jan Kara <jack@suse.cz>
Cc: Christian Brauner <brauner@kernel.org>,
	Theodore Ts'o <tytso@mit.edu>,
	Andreas Dilger <adilger.kernel@dilger.ca>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-ext4@vger.kernel.org
Subject: Re: [PATCH v2 42/92] ext4: convert to ctime accessor functions
Date: Thu, 06 Jul 2023 09:10:17 -0400	[thread overview]
Message-ID: <5290be64ba87d01938c578f49443ce41f9be5e77.camel@kernel.org> (raw)
In-Reply-To: <20230706123643.3pumra5f4fthz3qq@quack3>

On Thu, 2023-07-06 at 14:36 +0200, Jan Kara wrote:
> On Wed 05-07-23 15:01:07, Jeff Layton wrote:
> > In later patches, we're going to change how the inode's ctime field is
> > used. Switch to using accessor functions instead of raw accesses of
> > inode->i_ctime.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> 
> Some comment below:
> 
> > diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> > index 0a2d55faa095..d502b930431b 100644
> > --- a/fs/ext4/ext4.h
> > +++ b/fs/ext4/ext4.h
> > @@ -3823,6 +3823,27 @@ static inline int ext4_buffer_uptodate(struct buffer_head *bh)
> >  	return buffer_uptodate(bh);
> >  }
> >  
> > +static inline void ext4_inode_set_ctime(struct inode *inode, struct ext4_inode *raw_inode)
> > +{
> > +	struct timespec64 ctime = inode_get_ctime(inode);
> > +
> > +	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_ctime_extra)) {
> > +		raw_inode->i_ctime = cpu_to_le32(ctime.tv_sec);
> > +		raw_inode->i_ctime_extra = ext4_encode_extra_time(&ctime);
> > +	} else {
> > +		raw_inode->i_ctime = cpu_to_le32(clamp_t(int32_t, ctime.tv_sec, S32_MIN, S32_MAX));
> > +	}
> > +}
> > +
> > +static inline void ext4_inode_get_ctime(struct inode *inode, const struct ext4_inode *raw_inode)
> > +{
> > +	struct timespec64 ctime = { .tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime) };
> > +
> > +	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_ctime_extra))
> > +		ext4_decode_extra_time(&ctime, raw_inode->i_ctime_extra);
> > +	inode_set_ctime(inode, ctime.tv_sec, ctime.tv_nsec);
> > +}
> > +
> 
> This duplication is kind of unpleasant. I was looking into it for a while
> and I think we can rather do some initial cleanup (attached patch 1) and
> then your conversion patch would not need to duplicate the conversion code
> (see attached patch 2).
> 
> 	
> 

Thanks Jan. That looks fine at first glance. I'll plan to drop my ext4
patch and replace it with these.

Cheers,
-- 
Jeff Layton <jlayton@kernel.org>

      reply	other threads:[~2023-07-06 13:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230705185755.579053-1-jlayton@kernel.org>
     [not found] ` <20230705190309.579783-1-jlayton@kernel.org>
2023-07-05 19:01   ` [PATCH v2 41/92] ext2: convert to ctime accessor functions Jeff Layton
2023-07-06 11:03     ` Jan Kara
2023-07-05 19:01   ` [PATCH v2 42/92] ext4: " Jeff Layton
2023-07-06 12:36     ` Jan Kara
2023-07-06 13:10       ` Jeff Layton [this message]

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=5290be64ba87d01938c578f49443ce41f9be5e77.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=adilger.kernel@dilger.ca \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --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).