[Ocfs2-tools-devel] [PATCH 1/3] tunefs.ocfs2: Don't use the I/O cache in unlocked or online operations.

Joel Becker joel.becker at oracle.com
Fri Jun 12 20:18:42 PDT 2009


It's not safe to cache disk blocks when the filesystem may be live
elsewhere.  So if we're running any of the "special" operations, ones
that get the special error codes (SKIPCLUSTER, PERFORM_ONLINE, etc),
we'll run without the cache.

Because ocfs2ne runs the special operations first, then closes the
filesystem and repoens it before trying regular operations, we know that
regular operations will get the cache if they can safely lock the
filesystem.

Signed-off-by: Joel Becker <joel.becker at oracle.com>
---
 tunefs.ocfs2/libocfs2ne.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/tunefs.ocfs2/libocfs2ne.c b/tunefs.ocfs2/libocfs2ne.c
index c5362db..fb800cb 100644
--- a/tunefs.ocfs2/libocfs2ne.c
+++ b/tunefs.ocfs2/libocfs2ne.c
@@ -1370,10 +1370,18 @@ errcode_t tunefs_open(const char *device, int flags,
 	/*
 	 * We will use block cache in io.  Now, whether the cluster is
 	 * locked or the volume is mount local, in both situation we can
-	 * safely use cache.  If io_init_cache failed, we will go on the
-	 * tunefs work without the io_cache, so there is no check here.
+	 * safely use cache.  If we're not locked
+	 * (tunefs_special_errorp(err) != 0), we can't safely use it.
+	 * If this tunefs run has both special and regular operations,
+	 * ocfs2ne will retry with the regular arguments and will get
+	 * the cache for the regular operations.
+	 *
+	 * If io_init_cache failed, we will go do the work without the
+	 * io_cache, so there is no check for failure here.
 	 */
-	io_init_cache(fs->fs_io, ocfs2_extent_recs_per_eb(fs->fs_blocksize));
+	if (!err)
+		io_init_cache(fs->fs_io,
+			      ocfs2_extent_recs_per_eb(fs->fs_blocksize));
 
 	/*
 	 * SKIPCLUSTER operations don't check the journals - they couldn't
-- 
1.6.3.1




More information about the Ocfs2-tools-devel mailing list