linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: [PATCH 3/4] Btrfs: fix wrong max_to_defrag in btrfs_defrag_file()
Date: Fri, 02 Sep 2011 15:56:55 +0800	[thread overview]
Message-ID: <4E608C47.6060308@cn.fujitsu.com> (raw)
In-Reply-To: <4E608C29.10307@cn.fujitsu.com>

It's off-by-one, and thus we may skip the last page while defragmenting.

An example case:

  # create /mnt/file with 2 4K file extents
  # btrfs fi defrag /mnt/file
  # sync
  # filefrag /mnt/file
  /mnt/file: 2 extents found

So it's not defragmented.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 fs/btrfs/ioctl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 6f2b257..57aa5b7 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1046,7 +1046,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
 		i = range->start >> PAGE_CACHE_SHIFT;
 	}
 	if (!max_to_defrag)
-		max_to_defrag = last_index - 1;
+		max_to_defrag = last_index;
 
 	while (i <= last_index && defrag_count < max_to_defrag) {
 		/*
-- 
1.7.3.1

  parent reply	other threads:[~2011-09-02  7:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-02  7:56 [PATCH 1/4] Btrfs: fix defragmentation regression Li Zefan
2011-09-02  7:56 ` [PATCH 2/4] Btrfs: use i_size_read() in btrfs_defrag_file() Li Zefan
2011-09-22 10:58   ` David Sterba
2011-09-02  7:56 ` Li Zefan [this message]
2011-09-22 10:42   ` [PATCH 3/4] Btrfs: fix wrong max_to_defrag " David Sterba
2011-09-02  7:57 ` [PATCH 4/4] Btrfs: honor extent thresh during defragmentation Li Zefan
2011-09-02  8:42 ` [PATCH 1/4] Btrfs: fix defragmentation regression Christoph Hellwig
2011-10-18  8:48   ` Dan Merillat
2011-10-18  8:52     ` Li Zefan

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=4E608C47.6060308@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).