From: Jan Kara <jack@suse.cz>
To: Nick Piggin <npiggin@suse.de>
Cc: Al Viro <viro@ZenIV.linux.org.uk>,
Christoph Hellwig <hch@infradead.org>, Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org
Subject: Re: [patch 1/5] fs: truncate introduce new sequence
Date: Wed, 9 Dec 2009 15:38:23 +0100 [thread overview]
Message-ID: <20091209143823.GA7044@quack.suse.cz> (raw)
In-Reply-To: <20091208083832.GA19823@wotan.suse.de>
Hi,
On Tue 08-12-09 09:38:32, Nick Piggin wrote:
> Changes: avoid .truncate_kludge_to_be_killed hack by implementing additional
> fs helper functions that do not call vmtruncate.
>
> So far have converted ext2 and fat, tested with fsx-linux and the recent
> writev truncate bug tester. The reset of the patches that were already
> made are pretty simple to convert but I will likely prefer to send those
> via their maintainers after this initial set is agreed and merged.
>
> The new helpers, *_newtrunc, are a bit ugly, but we can do a rename back
> to the old names after all support for old sequence is removed.
Yeah. I'm not sure what Al dislikes about the original temporary hack.
Maybe he's afraid that the hack will last longer than we'd like... What I
dislike about this approach is that we'll have to change every filesystem
in several places also in the second patch. Anyway I'd like to get this
change merged and I don't care too much about details of the intermediate
period...
> --
> Introduce a new truncate calling sequence into fs/mm subsystems. Rather than
> setattr > vmtruncate > truncate, have filesystems call their truncate sequence
> from ->setattr if filesystem specific operations are required. vmtruncate is
> deprecated, and truncate_pagecache and inode_newsize_ok helpers introduced
> previously should be used.
>
> simple_setattr is introduced for simple in-ram filesystems to implement
> the new truncate sequence. Eventually all filesystems should be converted
> to implement a setattr, and the default code in notify_change should go
> away.
>
> simple_setsize is also introduced to perform just the ATTR_SIZE portion
> of simple_setattr (ie. changing i_size and trimming pagecache).
>
> To implement the new truncate sequence:
> - filesystem specific manipulations (eg freeing blocks) must be done in
> the setattr method rather than ->truncate.
> - vmtruncate can not be used by core code to trim blocks past i_size in
> the event of write failure after allocation, so this must be performed
> in the fs code.
> - convert usage of helpers block_write_begin, nobh_write_begin,
> cont_write_begin, and *blockdev_direct_IO* to use _newtrunc postfixed
> variants. These avoid calling vmtruncate to trim blocks (see previous).
> - inode_setattr should not be used. generic_setattr is a new function
> to be used to copy simple attributes into the generic inode.
> - make use of the better opportunity to handle errors with the new sequence.
>
> Big problem with the previous calling sequence: the filesystem is not called
> until i_size has already changed. This means it is not allowed to fail the
> call, and also it does not know what the previous i_size was. Also, generic
> code calling vmtruncate to truncate allocated blocks in case of error had
> no good way to return a meaningful error (or, for example, atomically handle
> block deallocation).
>
> Cc: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Nick Piggin <npiggin@suse.de>
The patch looks fine except for a typo below.
Acked-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/vfs.txt | 7 +-
> fs/attr.c | 50 ++++++++++++---
> fs/buffer.c | 123 ++++++++++++++++++++++++++++++--------
> fs/direct-io.c | 85 ++++++++++++++++----------
> fs/libfs.c | 83 +++++++++++++++++++++++++
> include/linux/buffer_head.h | 9 ++
> include/linux/fs.h | 36 ++++++++++-
> mm/truncate.c | 10 +--
> 8 files changed, 328 insertions(+), 75 deletions(-)
>
> Index: linux-2.6/Documentation/filesystems/vfs.txt
> ===================================================================
> --- linux-2.6.orig/Documentation/filesystems/vfs.txt
> +++ linux-2.6/Documentation/filesystems/vfs.txt
> @@ -401,11 +401,16 @@ otherwise noted.
> started might not be in the page cache at the end of the
> walk).
>
> - truncate: called by the VFS to change the size of a file. The
> + truncate: Deprecated. This will not be called if ->setsize is defined.
> + Called by the VFS to change the size of a file. The
> i_size field of the inode is set to the desired size by the
> VFS before this method is called. This method is called by
> the truncate(2) system call and related functionality.
>
> + Note: ->truncate and vmtruncate are deprecated. Do not add new
> + instances/calls of these. Filesystems shoud be converted to do their
^^^^^ should
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
prev parent reply other threads:[~2009-12-09 16:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-08 8:38 [patch 1/5] fs: truncate introduce new sequence Nick Piggin
2009-12-08 8:39 ` [patch 2/5] fs: convert simple fs to new truncate Nick Piggin
2009-12-09 14:39 ` Jan Kara
2009-12-10 5:15 ` Nick Piggin
2009-12-10 8:44 ` Boaz Harrosh
2009-12-10 7:57 ` Nick Piggin
2009-12-08 8:41 ` [patch 3/5] tmpfs: convert to use the new truncate convention Nick Piggin
2009-12-09 14:45 ` Jan Kara
2009-12-10 0:48 ` Nick Piggin
2009-12-08 8:42 ` [patch 4/5] ext2: " Nick Piggin
2009-12-09 14:57 ` Jan Kara
2009-12-10 1:11 ` Nick Piggin
2009-12-10 10:20 ` Jan Kara
2009-12-08 8:43 ` [patch 5/5] fat: " Nick Piggin
2009-12-09 15:08 ` Jan Kara
2009-12-09 14:38 ` Jan Kara [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=20091209143823.GA7044@quack.suse.cz \
--to=jack@suse.cz \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=npiggin@suse.de \
--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).