[PATCH 03/10] fuse2fs: close filesystem from op_destroy

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

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

Close the filesystem from op_destroy so that we know the block device
has been closed before the umount call completes.

Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
---
 misc/fuse2fs.c |   24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)


diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 25d32a69729362..ec3d684085d975 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -675,6 +675,20 @@ static int check_inum_access(struct fuse2fs *ff, ext2_ino_t ino, int mask)
 	return -EACCES;
 }
 
+static void close_fs(struct fuse2fs *ff)
+{
+	errcode_t err;
+
+	if (!ff->fs)
+		return;
+
+	err = ext2fs_close(ff->fs);
+	if (err)
+		err_printf(ff, "%s\n", error_message(err));
+
+	ff->fs = NULL;
+}
+
 static void op_destroy(void *p EXT2FS_ATTR((unused)))
 {
 	struct fuse_context *ctxt = fuse_get_context();
@@ -717,7 +731,10 @@ static void op_destroy(void *p EXT2FS_ATTR((unused)))
 		char uuid[UUID_STR_SIZE];
 
 		uuid_unparse(fs->super->s_uuid, uuid);
+		close_fs(ff);
 		log_printf(ff, "%s %s.\n", _("unmounting filesystem"), uuid);
+	} else {
+		close_fs(ff);
 	}
 }
 
@@ -4723,12 +4740,7 @@ int main(int argc, char *argv[])
  _("Mount failed while opening filesystem.  Check dmesg(1) for details."));
 		fflush(orig_stderr);
 	}
-	if (fctx.fs) {
-		err = ext2fs_close(fctx.fs);
-		if (err)
-			com_err(argv[0], err, "while closing fs");
-		fctx.fs = NULL;
-	}
+	close_fs(&fctx);
 	if (fctx.device)
 		free(fctx.device);
 	fuse_opt_free_args(&args);





[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux