Miao Xie
2014-Feb-27 05:58 UTC
[PATCH 1/3] Btrfs: don't skip the page flush since the enospc is not brought by it
As we know, btrfs flushes the continuous pages as many as possible,
but if all the free spaces are small, we will allocate the spaces by
several times, and if there is something wrong with the space
reservation, it is very likely that some allocations succeed and
the others fail. But the current code doesn't take this case into
account, and set the error flag for the pages though their spaces
are allocated successfully. It introduces a problem that we can not
umount the fs after the above problem happens because we need wait
for the flush of those pages whose spaces are allocated. This patch
fixes the above problem, and makes the btrfs developers happy when
they investigate the problem of the space reservation.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
fs/btrfs/extent_io.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index fbe501d..97595ea 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3198,8 +3198,19 @@ static int __extent_writepage(struct page *page, struct
writeback_control *wbc,
&nr_written);
/* File system has been set read-only */
if (ret) {
- SetPageError(page);
- goto done;
+ /*
+ * Private2 means we allocate the space
+ * for this page successfully, and enospc
+ * error doesn't set the fs to be R/O, so
+ * we can write out the page and needn't
+ * set error flag for this page. If so, we
+ * can prevent the umount task from being
+ * blocked.
+ */
+ if (!(ret == -ENOSPC && PagePrivate2(page))) {
+ SetPageError(page);
+ goto done;
+ }
}
/*
* delalloc_end is already one less than the total
--
1.8.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs"
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html