xfs
[Top] [All Lists]

Re: [PATCH v5 1/10] fs: Add new flag(FALLOC_FL_COLLAPSE_RANGE) for fallo

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: [PATCH v5 1/10] fs: Add new flag(FALLOC_FL_COLLAPSE_RANGE) for fallocate
From: Hugh Dickins <hughd@xxxxxxxxxx>
Date: Tue, 25 Feb 2014 15:41:20 -0800 (PST)
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Theodore Ts'o <tytso@xxxxxxx>, Namjae Jeon <linkinjeon@xxxxxxxxx>, viro@xxxxxxxxxxxxxxxxxx, bpm@xxxxxxx, adilger.kernel@xxxxxxxxx, jack@xxxxxxx, mtk.manpages@xxxxxxxxx, lczerner@xxxxxxxxxx, linux-fsdevel@xxxxxxxxxxxxxxx, xfs@xxxxxxxxxxx, linux-ext4@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx, Namjae Jeon <namjae.jeon@xxxxxxxxxxx>, Ashish Sangwan <a.sangwan@xxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version:content-type; bh=gGZ/EAwJz6axSCTVTvZ5pWis1cMt7vGvK1zXGw9UOsA=; b=f/U9sG45bvMojSZvglfUxY3WwNfl4e3F5F4A09oDZ+owrSFFOXjPFE8D0MQsidE+kv ZQNyVMg8zfSydkuuXP52KFq+xwXb5Uzig0K1jdB1ZcKk7LynWmsZvs+wp8MXCsFAmXoX VOR7mKm8yIX7cUEWMUcqBnZnL+OuCeB8DbVfeaGfut7JV09JlAnd/s/mTtfoKL7bKdMg ekC2g7HXEQfTAKg93vC0nyotnyv2IkRDP3MCOknoNKItgx/9Kozvq66rbocUJZgplzZ6 4GUQ82Bklfv7IZLLsUgqdmfSER11Ue3zMcec5wbzRs0jV1OCB5fO+glHVL4+EXQY4IQY RtRA==
In-reply-to: <20140223213606.GE4317@dastard>
References: <1392741464-20029-1-git-send-email-linkinjeon@xxxxxxxxx> <20140222140625.GD26637@xxxxxxxxx> <20140223213606.GE4317@dastard>
User-agent: Alpine 2.11 (LSU 23 2013-08-11)
On Mon, 24 Feb 2014, Dave Chinner wrote:
> On Sat, Feb 22, 2014 at 09:06:25AM -0500, Theodore Ts'o wrote:
> > On Wed, Feb 19, 2014 at 01:37:43AM +0900, Namjae Jeon wrote:
> > > + /*
> > > +  * There is no need to overlap collapse range with EOF, in which case
> > > +  * it is effectively a truncate operation
> > > +  */
> > > + if ((mode & FALLOC_FL_COLLAPSE_RANGE) &&
> > > +     (offset + len >= i_size_read(inode)))
> > > +         return -EINVAL;
> > > +
> > 
> > I wonder if we should just translate a collapse range that is
> > equivalent to a truncate operation to, in fact, be a truncate
> > operation?
> 
> Trying to collapse a range that extends beyond EOF, IMO, is likely
> to only happen if the DVR/NLE application is buggy. Hence I think
> that telling the application it is doing something that is likely to
> be wrong is better than silently truncating the file....

I do agree with Ted on this point.  This is not an xfs ioctl added
for one DVR/NLE application, it's a mode of a Linux system call.

We do not usually reject with an error when one system call happens
to ask for something which can already be accomplished another way;
nor nanny our callers.

It seems natural to me that COLLAPSE_RANGE should support beyond EOF;
unless that adds significantly to implementation difficulties?

Actually, is it even correct to fail at EOF?  What if fallocation
with FALLOC_FL_KEEP_SIZE was used earlier, to allocate beyond EOF:
shouldn't it be possible to shift that allocation down, along with
the EOF, rather than leave it behind as a stranded island?

Hugh

<Prev in Thread] Current Thread [Next in Thread>