aboutsummaryrefslogtreecommitdiffstats
path: root/disk-io.c
diff options
context:
space:
mode:
authorAnand Jain <Anand.Jain@oracle.com>2014-01-13 21:14:55 +0800
committerChris Mason <clm@fb.com>2014-01-31 08:22:26 -0800
commitf920dbce8d8161fff30e3e75ebfc71e978d9bea4 (patch)
tree2ca6561e3cd88062c327281d83c758f588055e60 /disk-io.c
parentb2e99e1819d967828edf149db5a203e59a40e379 (diff)
downloadbtrfs-progs-f920dbce8d8161fff30e3e75ebfc71e978d9bea4.tar.gz
btrfs-progs-f920dbce8d8161fff30e3e75ebfc71e978d9bea4.tar.xz
btrfs-progs-f920dbce8d8161fff30e3e75ebfc71e978d9bea4.zip
btrfs-progs: btrfsck operations should be exclusive
this patch will make btrfsck operations to open disk in exclusive mode, so that mount will fail when btrfsck is running Signed-off-by: Anand Jain <Anand.Jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'disk-io.c')
-rw-r--r--disk-io.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/disk-io.c b/disk-io.c
index 8009b94..e4550bd 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1057,6 +1057,7 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
struct btrfs_fs_devices *fs_devices = NULL;
struct extent_buffer *eb;
int ret;
+ int oflags;
if (sb_bytenr == 0)
sb_bytenr = BTRFS_SUPER_INFO_OFFSET;
@@ -1080,9 +1081,14 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
fs_info->fs_devices = fs_devices;
if (flags & OPEN_CTREE_WRITES)
- ret = btrfs_open_devices(fs_devices, O_RDWR);
+ oflags = O_RDWR;
else
- ret = btrfs_open_devices(fs_devices, O_RDONLY);
+ oflags = O_RDONLY;
+
+ if (flags & OPEN_CTREE_EXCLUSIVE)
+ oflags |= O_EXCL;
+
+ ret = btrfs_open_devices(fs_devices, oflags);
if (ret)
goto out_devices;