public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: don't return 0 if generic_segment_checks() find nothing to write
@ 2013-04-12 15:48 Jeff Liu
  2013-04-16 18:26 ` Ben Myers
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Liu @ 2013-04-12 15:48 UTC (permalink / raw)
  To: xfs@oss.sgi.com

From: Jie Liu <jeff.liu@oracle.com>

At xfs_file_aio_write(), we just return 0 which means a successfully operation if the ocount
is evaluated to 0 at generic_segment_checks().  Generally, it'll occurred if the specified
write count is 0 from the user space.  However, for example, if the given offset is over the
maximum file size limitation although nothing would be written into the file, in this case,
the underlying file system should detect this issue and return a proper errno instead.
Hence, the beginning pre-checking up against ocount would conceal some real cause and confuse
the user space program maybe.

To fix it, we can delay the write count verification until xfs_file_aio_write_checks() is done.

This test is performed on 32-bit system without CONFIG_LBADF is enabled.
Before patching:
xfs_io -f -c "pwrite 17592186040320 0" /storage/test_file
wrote 0/0 bytes at offset 17592186040320
0.000000 bytes, 0 ops; 0.0000 sec (0.000000 bytes/sec and 0.0000 ops/sec)

After patching:
xfs_io -f -c "pwrite 17592186040320 0" /storage/test_file
pwrite64: File too large

Signed-off-by: Jie Liu <jeff.liu@oracle.com>

---
 fs/xfs/xfs_file.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index f03bf1a..f8a933e 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -671,6 +671,9 @@ xfs_file_dio_aio_write(
 	if (ret)
 		goto out;
 
+	if (ocount == 0)
+		goto out;
+
 	if (mapping->nrpages) {
 		ret = -filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
 						    pos, -1);
@@ -725,6 +728,9 @@ xfs_file_buffered_aio_write(
 	if (ret)
 		goto out;
 
+	if (ocount == 0)
+		goto out;
+
 	/* We can write back this queue in page reclaim */
 	current->backing_dev_info = mapping->backing_dev_info;
 
@@ -772,9 +778,6 @@ xfs_file_aio_write(
 	if (ret)
 		return ret;
 
-	if (ocount == 0)
-		return 0;
-
 	sb_start_write(inode->i_sb);
 
 	if (XFS_FORCED_SHUTDOWN(ip->i_mount)) {
-- 
1.7.9.5

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: don't return 0 if generic_segment_checks() find nothing to write
  2013-04-12 15:48 [PATCH] xfs: don't return 0 if generic_segment_checks() find nothing to write Jeff Liu
@ 2013-04-16 18:26 ` Ben Myers
  2013-04-16 18:35   ` Jeff Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Myers @ 2013-04-16 18:26 UTC (permalink / raw)
  To: Jeff Liu; +Cc: xfs@oss.sgi.com

Hey Jeff,

On Fri, Apr 12, 2013 at 11:48:28PM +0800, Jeff Liu wrote:
> From: Jie Liu <jeff.liu@oracle.com>
> 
> At xfs_file_aio_write(), we just return 0 which means a successfully operation if the ocount
> is evaluated to 0 at generic_segment_checks().  Generally, it'll occurred if the specified
> write count is 0 from the user space.  However, for example, if the given offset is over the
> maximum file size limitation although nothing would be written into the file, in this case,
> the underlying file system should detect this issue and return a proper errno instead.
> Hence, the beginning pre-checking up against ocount would conceal some real cause and confuse
> the user space program maybe.
> 
> To fix it, we can delay the write count verification until xfs_file_aio_write_checks() is done.

Could you wrap these around 72 columns or so in the future?  Don't worry
about reposting this one unless something technical comes up.

Thanks,
	Ben

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: don't return 0 if generic_segment_checks() find nothing to write
  2013-04-16 18:26 ` Ben Myers
@ 2013-04-16 18:35   ` Jeff Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Liu @ 2013-04-16 18:35 UTC (permalink / raw)
  To: Ben Myers; +Cc: xfs@oss.sgi.com

Hi Ben,

On 04/17/2013 02:26 AM, Ben Myers wrote:
> Hey Jeff,
> 
> On Fri, Apr 12, 2013 at 11:48:28PM +0800, Jeff Liu wrote:
>> From: Jie Liu <jeff.liu@oracle.com>
>>
>> At xfs_file_aio_write(), we just return 0 which means a successfully operation if the ocount
>> is evaluated to 0 at generic_segment_checks().  Generally, it'll occurred if the specified
>> write count is 0 from the user space.  However, for example, if the given offset is over the
>> maximum file size limitation although nothing would be written into the file, in this case,
>> the underlying file system should detect this issue and return a proper errno instead.
>> Hence, the beginning pre-checking up against ocount would conceal some real cause and confuse
>> the user space program maybe.
>>
>> To fix it, we can delay the write count verification until xfs_file_aio_write_checks() is done.
> 
> Could you wrap these around 72 columns or so in the future?  Don't worry
> about reposting this one unless something technical comes up.
Sure, I'll take care of the patch format in the future.

Thanks,
-Jeff

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-16 18:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-12 15:48 [PATCH] xfs: don't return 0 if generic_segment_checks() find nothing to write Jeff Liu
2013-04-16 18:26 ` Ben Myers
2013-04-16 18:35   ` Jeff Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox