From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 08/11] xfs: remove the i_size field in struct xfs_inode
Date: Wed, 14 Dec 2011 09:58:50 +1100 [thread overview]
Message-ID: <20111213225850.GF3179@dastard> (raw)
In-Reply-To: <20111208155918.841972809@bombadil.infradead.org>
On Thu, Dec 08, 2011 at 10:58:03AM -0500, Christoph Hellwig wrote:
> There is no fundamental need to keep an in-memory inode size copy in the
> XFS inode. We already have the on-disk value in the dinode, and the
> separate in-memory copy that we need for regular files only in the
> XFS inode.
>
> Remove the xfs_inode i_size field and change the XFS_ISIZE macro to use
> the VFS inode i_size field for regular fields. Switch code that was
> directly accessing it to either the XFS_ISIZE macro or direct access
> of the VFS i_size if the code is limited to regular files and in
> highlevel code.
Welcome back, XFS_ISIZE() ;)
> This also allows dropping a a big bunch of fairly complicated code in the
> write path which dealt with keeping the xfs_inode i_size uptodate with the
> VFS i_size that is getting updated inside ->write_end.
Excellent - one less round trip on the ILOCK for each extending
write.
> Note that we do not bother resetting the VFS i_size when truncating a file
> that gets freed to zero as there is point in doing so. Just relax the
no point in doing so because
the VFS inode is no longer in
use at this point.
> assert in xfs_ifree to only check the on-disk size instead.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
......
> @@ -3997,11 +3997,8 @@ xfs_bmap_one_block(
> xfs_bmbt_irec_t s; /* internal version of extent */
>
> #ifndef DEBUG
> - if (whichfork == XFS_DATA_FORK) {
> - return S_ISREG(ip->i_d.di_mode) ?
> - (ip->i_size == ip->i_mount->m_sb.sb_blocksize) :
> - (ip->i_d.di_size == ip->i_mount->m_sb.sb_blocksize);
> - }
> + if (whichfork == XFS_DATA_FORK)
> + return XFS_ISIZE(ip) == ip->i_mount->m_sb.sb_blocksize;
> #endif /* !DEBUG */
> if (XFS_IFORK_NEXTENTS(ip, whichfork) != 1)
> return 0;
I thought that this was a small change of logic, and validated that
it was OK to do so, but turns out it is not. I soon noticed that
this was the logic inside XFS_ISIZE(), and that it is all the
ip->i_size to XFS_ISIZE(ip) conversions that change the logic:
> @@ -269,6 +265,18 @@ static inline struct inode *VFS_I(struct
> }
>
> /*
> + * For regular files we only update the on-disk filesize when actually
> + * writing data back to disk. Until then only the copy in the VFS inode
> + * is uptodate.
> + */
> +static inline xfs_fsize_t XFS_ISIZE(struct xfs_inode *ip)
> +{
> + if (S_ISREG(ip->i_d.di_mode))
> + return i_size_read(VFS_I(ip));
> + return ip->i_d.di_size;
> +}
This means we -explicity- only have a separate in-memory size for
regular files which is a significant change of logic. Preivously all
inodes, regardless of type, had both on-disk and in-memory values.
After thinking about this for a bit, the new code actually reflects
the original intent of the i_size/i_d.di_size split. i.e. it was
only necessary to separate the size into in-memory/on-disk pair so
that the on-disk size matched what -data writeback- had completed.
And data writeback can only occur on regular files, so it was only
necessary for regular files. The original implementation didn't
reflect this - it just changed all inodes to have this split.
However, For all other types of inodes, all the size updates are
made directly to i_d.di_size and a logged immediately. In those
cases, we are simultaneously updating i_size, so we don't really
need it at all. e also don't need to touch the inode->i_size,
because the VFS is already maintaining that for use in these
cases....
Ok, I've convinced myself that this is valid, and I haven't seen any
problems in testing, so:
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2011-12-13 22:58 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-08 15:57 [PATCH 00/11] inode shrink and misc updates Christoph Hellwig
2011-12-08 15:57 ` [PATCH 01/11] xfs: remove xfs_itruncate_data Christoph Hellwig
2011-12-13 21:23 ` Dave Chinner
2011-12-08 15:57 ` [PATCH 02/11] xfs: cleanup xfs_iomap_eof_align_last_fsb Christoph Hellwig
2011-12-13 21:25 ` Dave Chinner
2011-12-08 15:57 ` [PATCH 03/11] xfs: remove the unused dm_attrs structure Christoph Hellwig
2011-12-08 15:57 ` [PATCH 04/11] xfs: remove the if_ext_max field in struct xfs_ifork Christoph Hellwig
2011-12-13 21:59 ` Dave Chinner
2011-12-08 15:58 ` [PATCH 05/11] xfs: make i_flags an unsigned long Christoph Hellwig
2012-01-13 19:07 ` Ben Myers
2012-01-24 18:03 ` Christoph Hellwig
2011-12-08 15:58 ` [PATCH 06/11] xfs: replace i_flock with a sleeping bitlock Christoph Hellwig
2011-12-13 22:19 ` Dave Chinner
2011-12-18 18:11 ` Christoph Hellwig
2011-12-08 15:58 ` [PATCH 07/11] xfs: replace i_pin_wait with a bit waitqueue Christoph Hellwig
2011-12-13 22:21 ` Dave Chinner
2011-12-08 15:58 ` [PATCH 08/11] xfs: remove the i_size field in struct xfs_inode Christoph Hellwig
2011-12-13 22:58 ` Dave Chinner [this message]
2011-12-08 15:58 ` [PATCH 09/11] xfs: remove the i_new_size " Christoph Hellwig
2011-12-13 23:16 ` Dave Chinner
2011-12-14 13:30 ` Christoph Hellwig
2011-12-08 15:58 ` [PATCH 10/11] xfs: always return with the iolock held from xfs_file_aio_write_checks Christoph Hellwig
2011-12-13 23:20 ` Dave Chinner
2011-12-14 13:27 ` Christoph Hellwig
2011-12-08 15:58 ` [PATCH 11/11] xfs: cleanup xfs_file_aio_write Christoph Hellwig
2011-12-13 23:28 ` Dave Chinner
-- strict thread matches above, loose matches on Subject: below --
2011-12-18 20:00 [PATCH 00/11] inode shrink and misc updates V2 Christoph Hellwig
2011-12-18 20:00 ` [PATCH 08/11] xfs: remove the i_size field in struct xfs_inode Christoph Hellwig
2012-01-16 18:32 ` Ben Myers
2012-01-16 19:45 ` Ben Myers
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=20111213225850.GF3179@dastard \
--to=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=xfs@oss.sgi.com \
/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