[PATCH] Don't pass offset == 0 && endbyte == 0 to do_sync_file_range()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If user is specifying offset == 0 and nbytes == 1, current code uses
wbc->start == 0 && wbc->end == 0 to flush the range.

However, wbc->start == 0 && wbc->end == 0 is special range, not 0th page.
[If wbc->sync_mode == WB_SYNC_NODE, it uses prev offset.  Otherwise it
uses whole of file.]

It may confuse user, so, don't export that behavior to userland.

Signed-off-by: OGAWA Hirofumi <[email protected]>
---

 fs/sync.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff -puN fs/sync.c~sync_file_range-fix fs/sync.c
--- linux-2.6/fs/sync.c~sync_file_range-fix	2006-04-02 06:20:52.000000000 +0900
+++ linux-2.6-hirofumi/fs/sync.c	2006-04-02 06:20:52.000000000 +0900
@@ -101,8 +101,14 @@ asmlinkage long sys_sync_file_range(int 
 
 	if (nbytes == 0)
 		endbyte = -1;
-	else
-		endbyte--;		/* inclusive */
+	else {
+		/*
+		 * wbc->start == 0 && wbc->end == 0 is a special range,
+		 * so this avoids using it.
+		 */
+		if (endbyte > 1)
+			endbyte--;		/* inclusive */
+	}
 
 	ret = -EBADF;
 	file = fget_light(fd, &fput_needed);
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux