From cddb600db6b9412cb1180a62bad99e08da6a2728 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 14 Oct 2008 13:05:30 -0700 Subject: [PATCH] filestore: fix btrfs version detection --- src/os/FileStore.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 688959e839edd..c60c26ff60cfc 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -398,8 +398,11 @@ int FileStore::mount() // get epoch sprintf(fn, "%s/commit_op_seq", basedir.c_str()); fd = ::open(fn, O_RDONLY); - ::read(fd, &op_seq, sizeof(op_seq)); - ::close(fd); + if (fd >= 0) { + ::read(fd, &op_seq, sizeof(op_seq)); + ::close(fd); + } else + op_seq = 0; dout(5) << "mount op_seq is " << op_seq << dendl; // journal @@ -425,12 +428,11 @@ int FileStore::mount() btrfs_trans_start_end = true; // trans start/end interface r = apply_transaction(empty, 0); if (r == 0) { - dout(0) << "mount detected btrfs" << dendl; - - // do we have WAIT_FOR_SYNC and CLONE_RANGE? - r = ::ioctl(fd, BTRFS_IOC_CLONE_RANGE, 0); // pass in a BAD POINTER ... - assert(r < 0); - if (errno == -EFAULT) { + // do we have the shiny new ioctls: WAIT_FOR_SYNC and CLONE_RANGE? + int fd = ::open(basedir.c_str(), O_RDONLY); + r = ::ioctl(fd, BTRFS_IOC_WAIT_FOR_SYNC); + ::close(fd); + if (r == 0) { dout(0) << "mount detected shiny new btrfs" << dendl; btrfs = 2; } else { -- 2.39.5