diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2012-11-22 12:57:33 -0800 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2012-11-22 12:57:33 -0800 |
commit | 3110e5ca4237a5542e7e06067d2a9b3c28da05c7 (patch) | |
tree | 937304a1d435a88ba849952a833cf5e899763b59 | |
parent | a0e8452a09327547d5f60673e07046aeff1b51d8 (diff) | |
parent | 55081c2bea0a918946dab1805334c73b8d01cd47 (diff) | |
download | ceph-3110e5ca4237a5542e7e06067d2a9b3c28da05c7.tar.gz |
Merge remote-tracking branch 'origin/next' into next
-rw-r--r-- | src/common/sync_filesystem.h | 6 | ||||
-rw-r--r-- | src/crush/CrushWrapper.cc | 25 | ||||
-rw-r--r-- | src/crush/CrushWrapper.h | 9 | ||||
-rw-r--r-- | src/os/FileStore.cc | 10 |
4 files changed, 50 insertions, 0 deletions
diff --git a/src/common/sync_filesystem.h b/src/common/sync_filesystem.h index 3ad8c9e928d..dc90b890c93 100644 --- a/src/common/sync_filesystem.h +++ b/src/common/sync_filesystem.h @@ -16,6 +16,7 @@ #define CEPH_SYNC_FILESYSTEM_H #include <unistd.h> +#include <syscall.h> #ifndef __CYGWIN__ # ifndef DARWIN @@ -35,6 +36,11 @@ inline int sync_filesystem(int fd) return 0; #endif +#ifdef SYS_syncfs + if (syscall(SYS_syncfs, fd) == 0) + return 0; +#endif + #ifdef BTRFS_IOC_SYNC if (::ioctl(fd, BTRFS_IOC_SYNC) == 0) return 0; diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 8d33839bbb7..475c8c105e9 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -20,6 +20,25 @@ void CrushWrapper::find_roots(set<int>& roots) const } } +bool CrushWrapper::subtree_contains(int root, int item) const +{ + if (root == item) + return true; + + if (root >= 0) + return false; // root is a leaf + + const crush_bucket *b = get_bucket(root); + if (!b) + return false; + + for (unsigned j=0; j<b->size; j++) { + if (subtree_contains(b->items[j], item)) + return true; + } + return false; +} + int CrushWrapper::remove_item(CephContext *cct, int item) { @@ -230,6 +249,12 @@ int CrushWrapper::insert_item(CephContext *cct, int item, float weight, string n return -EINVAL; } + // check that we aren't creating a cycle. + if (subtree_contains(id, cur)) { + ldout(cct, 1) << "insert_item item " << cur << " already exists beneath " << id << dendl; + return -EINVAL; + } + crush_bucket *b = get_bucket(id); assert(b); diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index e8120931103..5ea68b9a83d 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -212,6 +212,15 @@ public: void find_roots(set<int>& roots) const; /** + * see if an item is contained within a subtree + * + * @param root haystack + * @param item needle + * @return true if the item is located beneath the given node + */ + bool subtree_contains(int root, int item) const; + + /** * see if item is located where we think it is * * This verifies that the given item is located at a particular diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index b8f01c2e1ac..1d6797c2b32 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -25,6 +25,7 @@ #if defined(__linux__) #include <linux/fs.h> +#include <syscall.h> #endif #include <iostream> @@ -1227,8 +1228,17 @@ int FileStore::_detect_fs() dout(0) << "mount syncfs(2) syscall supported by glibc BUT NOT the kernel" << dendl; } #else +#ifdef SYS_syncfs + if (syscall(SYS_syncfs, fd) == 0) { + dout(0) << "mount syscall(SYS_syncfs, fd) fully supported" << dendl; + have_syncfs = true; + } else { + dout(0) << "mount syscall(SYS_syncfs, fd) supported by libc BUT NOT the kernel" << dendl; + } +#else dout(0) << "mount syncfs(2) syscall not support by glibc" << dendl; #endif +#endif if (!have_syncfs) { if (btrfs) { dout(0) << "mount no syncfs(2), but the btrfs SYNC ioctl will suffice" << dendl; |