All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marco Stornelli <marco.stornelli@gmail.com>
To: Matthew Wilcox <matthew@wil.cx>
Cc: Linux FS Devel <linux-fsdevel@vger.kernel.org>,
	Benjamin LaHaise <bcrl@kvack.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Jan Harkes <jaharkes@cs.cmu.edu>,
	coda@cs.cmu.edu, linux-kernel@vger.kernel.org,
	linux-aio@kvack.org, codalist@coda.cs.cmu.edu,
	Jan Kara <jack@suse.cz>
Subject: Re: [PATCH 2/4] fsfreeze: added new file_start_write_killable
Date: Fri, 26 Apr 2013 15:44:50 +0200	[thread overview]
Message-ID: <517A84D2.9040500@gmail.com> (raw)
In-Reply-To: <20130426120640.GA20612@parisc-linux.org>

Hi,

Il 26/04/2013 14:06, Matthew Wilcox ha scritto:
> On Fri, Apr 26, 2013 at 10:50:52AM +0200, Marco Stornelli wrote:
>> Replace file_start_write with file_start_write_killable where
>> possible.
>
> I feel like I'm missing context here.  Possibly because you only cc'd me
> on patch 2/4.  In particular, file_start_write doesn't exist upstream,
> so I'm not sure what it's for.  But returning 1 for non-regular files
> looks dodgy:

The patch series is based on -next due to several changes done by Al 
about fsfreeze. file_start_write_killable returns 1 because it's mainly 
a wrapper of __st_start_write. __sb_start_write returns 1 when 
everything is ok, 0 when the lock can't be gotten (we are using the 
trylock version) and _now_ a value < 0 when something happens (i.e. -EINTR).

>
>> +static inline int file_start_write_killable(struct file *file)
>> +{
>> +	if (!S_ISREG(file_inode(file)->i_mode))
>> +		return 1;
>> +	return sb_start_write_killable(file_inode(file)->i_sb);
>> +}
>
>> +++ b/fs/aio.c
>> @@ -1103,8 +1103,11 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
>>   	if (iocb->ki_pos < 0)
>>   		return -EINVAL;
>>
>> -	if (rw == WRITE)
>> -		file_start_write(file);
>> +	if (rw == WRITE) {
>> +		ret = file_start_write_killable(file);
>> +		if (ret < 0)
>> +			return ret;
>> +	}
>>   	do {
>
> So ... it's OK to do this write to pipes/directories/devices/... ?  Or is
> that check always taken care of elsewhere?  If so, why do we need this
> check?  I'm confused.  None of the callers check for the 'ret == 1' case,
> so I'm sure there's something wrong here, I just can't tell what it is.
>

See above.

>> +++ b/fs/read_write.c
>> @@ -438,17 +438,19 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
>>   	ret = rw_verify_area(WRITE, file, pos, count);
>>   	if (ret >= 0) {
>>   		count = ret;
>> -		file_start_write(file);
>> -		if (file->f_op->write)
>> -			ret = file->f_op->write(file, buf, count, pos);
>> -		else
>> -			ret = do_sync_write(file, buf, count, pos);
>> +		ret = file_start_write_killable(file);
>>   		if (ret > 0) {
>> -			fsnotify_modify(file);
>> -			add_wchar(current, ret);
>> +			if (file->f_op->write)
>> +				ret = file->f_op->write(file, buf, count, pos);
>> +			else
>> +				ret = do_sync_write(file, buf, count, pos);
>> +			if (ret > 0) {
>> +				fsnotify_modify(file);
>> +				add_wchar(current, ret);
>> +			}
>> +			inc_syscw(current);
>> +			file_end_write(file);
>>   		}
>> -		inc_syscw(current);
>> -		file_end_write(file);
>>   	}
>>
>>   	return ret;
>
> I don't like it that you've increased the indentation here.  Better to do
> a preliminary patch which just converts to our normal style with gotos.  ie:
>

Ok, I can change the style here, no problem.

Marco

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to majordomo@kvack.org.  For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a>

WARNING: multiple messages have this Message-ID (diff)
From: Marco Stornelli <marco.stornelli@gmail.com>
To: Matthew Wilcox <matthew@wil.cx>
Cc: Linux FS Devel <linux-fsdevel@vger.kernel.org>,
	Benjamin LaHaise <bcrl@kvack.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Jan Harkes <jaharkes@cs.cmu.edu>,
	coda@cs.cmu.edu, linux-kernel@vger.kernel.org,
	linux-aio@kvack.org, codalist@TELEMANN.coda.cs.cmu.edu,
	Jan Kara <jack@suse.cz>
Subject: Re: [PATCH 2/4] fsfreeze: added new file_start_write_killable
Date: Fri, 26 Apr 2013 15:44:50 +0200	[thread overview]
Message-ID: <517A84D2.9040500@gmail.com> (raw)
In-Reply-To: <20130426120640.GA20612@parisc-linux.org>

Hi,

Il 26/04/2013 14:06, Matthew Wilcox ha scritto:
> On Fri, Apr 26, 2013 at 10:50:52AM +0200, Marco Stornelli wrote:
>> Replace file_start_write with file_start_write_killable where
>> possible.
>
> I feel like I'm missing context here.  Possibly because you only cc'd me
> on patch 2/4.  In particular, file_start_write doesn't exist upstream,
> so I'm not sure what it's for.  But returning 1 for non-regular files
> looks dodgy:

The patch series is based on -next due to several changes done by Al 
about fsfreeze. file_start_write_killable returns 1 because it's mainly 
a wrapper of __st_start_write. __sb_start_write returns 1 when 
everything is ok, 0 when the lock can't be gotten (we are using the 
trylock version) and _now_ a value < 0 when something happens (i.e. -EINTR).

>
>> +static inline int file_start_write_killable(struct file *file)
>> +{
>> +	if (!S_ISREG(file_inode(file)->i_mode))
>> +		return 1;
>> +	return sb_start_write_killable(file_inode(file)->i_sb);
>> +}
>
>> +++ b/fs/aio.c
>> @@ -1103,8 +1103,11 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
>>   	if (iocb->ki_pos < 0)
>>   		return -EINVAL;
>>
>> -	if (rw == WRITE)
>> -		file_start_write(file);
>> +	if (rw == WRITE) {
>> +		ret = file_start_write_killable(file);
>> +		if (ret < 0)
>> +			return ret;
>> +	}
>>   	do {
>
> So ... it's OK to do this write to pipes/directories/devices/... ?  Or is
> that check always taken care of elsewhere?  If so, why do we need this
> check?  I'm confused.  None of the callers check for the 'ret == 1' case,
> so I'm sure there's something wrong here, I just can't tell what it is.
>

See above.

>> +++ b/fs/read_write.c
>> @@ -438,17 +438,19 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
>>   	ret = rw_verify_area(WRITE, file, pos, count);
>>   	if (ret >= 0) {
>>   		count = ret;
>> -		file_start_write(file);
>> -		if (file->f_op->write)
>> -			ret = file->f_op->write(file, buf, count, pos);
>> -		else
>> -			ret = do_sync_write(file, buf, count, pos);
>> +		ret = file_start_write_killable(file);
>>   		if (ret > 0) {
>> -			fsnotify_modify(file);
>> -			add_wchar(current, ret);
>> +			if (file->f_op->write)
>> +				ret = file->f_op->write(file, buf, count, pos);
>> +			else
>> +				ret = do_sync_write(file, buf, count, pos);
>> +			if (ret > 0) {
>> +				fsnotify_modify(file);
>> +				add_wchar(current, ret);
>> +			}
>> +			inc_syscw(current);
>> +			file_end_write(file);
>>   		}
>> -		inc_syscw(current);
>> -		file_end_write(file);
>>   	}
>>
>>   	return ret;
>
> I don't like it that you've increased the indentation here.  Better to do
> a preliminary patch which just converts to our normal style with gotos.  ie:
>

Ok, I can change the style here, no problem.

Marco

  reply	other threads:[~2013-04-26 13:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-26  8:50 [PATCH 2/4] fsfreeze: added new file_start_write_killable Marco Stornelli
2013-04-26  8:50 ` Marco Stornelli
2013-04-26 12:06 ` Matthew Wilcox
2013-04-26 12:06   ` Matthew Wilcox
2013-04-26 13:44   ` Marco Stornelli [this message]
2013-04-26 13:44     ` Marco Stornelli
  -- strict thread matches above, loose matches on Subject: below --
2013-05-04  6:50 Marco Stornelli
2013-05-04  6:50 ` Marco Stornelli
2013-07-04 16:16 Gmail
2013-07-04 16:16 ` Gmail

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=517A84D2.9040500@gmail.com \
    --to=marco.stornelli@gmail.com \
    --cc=bcrl@kvack.org \
    --cc=coda@cs.cmu.edu \
    --cc=codalist@coda.cs.cmu.edu \
    --cc=jack@suse.cz \
    --cc=jaharkes@cs.cmu.edu \
    --cc=linux-aio@kvack.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.