All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Dahl <adahl@sgi.com>
To: xfs@oss.sgi.com
Cc: Andrew Dahl <adahl@sgi.com>
Subject: [patch 1/2] xfs: xfs_tosspages() bug
Date: Thu, 08 Nov 2012 16:23:16 -0600	[thread overview]
Message-ID: <20121108222315.626928496@sgi.com> (raw)
In-Reply-To: 20121108222315.505370321@sgi.com

[-- Attachment #1: xfs_fix_tosspages_tossing_all_pages --]
[-- Type: text/plain, Size: 1638 bytes --]

xfs_tosspages() takes a closed interval as an argument, take 
this into account when rounding down to the last byte of the
last complete page. If the request consists of a single 
partial page, there will be nothing to toss. 

Signed-off-by: Andrew Dahl <adahl@sgi.com>

---

Index: xfs/fs/xfs/xfs_fs_subr.c
===================================================================
--- xfs.orig/fs/xfs/xfs_fs_subr.c
+++ xfs/fs/xfs/xfs_fs_subr.c
@@ -32,9 +32,17 @@ xfs_tosspages(
 	xfs_off_t	last,
 	int		fiopt)
 {
-	/* can't toss partial tail pages, so mask them out */
-	last &= ~(PAGE_SIZE - 1);
-	truncate_inode_pages_range(VFS_I(ip)->i_mapping, first, last - 1);
+	/*
+	 * Can't toss partial tail pages, so mask them out.  If the only
+	 * page to toss was a partial tail, there will be nothing left
+	 * to do.
+	 */
+	if (last != -1) {
+	        last = ((last + 1) & PAGE_MASK) - 1;
+	        if (last < first)
+	                return;
+	}
+	truncate_inode_pages_range(VFS_I(ip)->i_mapping, first, last);
 }
 
 int
Index: xfs/fs/xfs/xfs_vnodeops.c
===================================================================
--- xfs.orig/fs/xfs/xfs_vnodeops.c
+++ xfs/fs/xfs/xfs_vnodeops.c
@@ -2172,7 +2172,7 @@ xfs_change_file_space(
 	switch (cmd) {
 	case XFS_IOC_ZERO_RANGE:
 		prealloc_type |= XFS_BMAPI_CONVERT;
-		xfs_tosspages(ip, startoffset, startoffset + bf->l_len, 0);
+		xfs_tosspages(ip, startoffset, bf->l_len ? startoffset + llen : -1, 0);
 		/* FALLTHRU */
 	case XFS_IOC_RESVSP:
 	case XFS_IOC_RESVSP64:



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

  reply	other threads:[~2012-11-08 22:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-08 22:23 [patch 0/2] xfs: xfs_tosspages() bug adahl
2012-11-08 22:23 ` Andrew Dahl [this message]
2012-11-08 23:06   ` [patch 1/2] " Dave Chinner
2012-11-08 23:46     ` Ben Myers
2012-11-09  1:05       ` Dave Chinner
2012-11-09 17:32         ` Ben Myers
2012-11-08 22:23 ` [patch 2/2] xfstests: xfs_tosspages() test addition Andrew Dahl
2012-11-08 23:27   ` Dave Chinner
2012-11-13  1:13     ` [patch 2/2 V2] " Andrew Dahl
2012-11-14 18:00       ` Mark Tinguely
2012-11-14 18:35         ` Andrew Dahl
2012-11-14 18:57           ` [patch 2/2 V3] " Andrew Dahl
2012-11-14 20:34             ` Dave Chinner
2012-11-20 15:31             ` Mark Tinguely
2012-11-09  1:12   ` xfs_quota -x -c 'report -u /dev/sde5' shows the duplicate result yyq
2012-11-09  1:24     ` Dave Chinner
2012-11-09  3:27       ` yyq
2012-11-09  5:39         ` Dave Chinner
     [not found]           ` <509CA82F.7030103@eisoo.com>
2012-11-09  7:01             ` Dave Chinner

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=20121108222315.626928496@sgi.com \
    --to=adahl@sgi.com \
    --cc=xfs@oss.sgi.com \
    /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.