#include <sys/ioctl.h>
#include <linux/fs.h>
-#ifdef HAVE_FIEMAP_H
-#include <linux/fiemap.h>
-#endif
+#include "include/fiemap.h"
#ifndef __CYGWIN__
# include <sys/xattr.h>
return false;
}
-#ifdef HAVE_FIEMAP_H
static int do_fiemap(int fd, off_t start, size_t len, struct fiemap **pfiemap)
{
struct fiemap *fiemap = NULL;
free(fiemap);
return ret;
}
-#else
-static int do_fiemap(int fd, off_t start, size_t len, struct fiemap **pfiemap)
-{
- return -ENOTSUP;
-}
-#endif
int FileStore::statfs(struct statfs *buf)
{
if (fd < 0)
return -errno;
+ // fiemap?
+ struct fiemap *fiemap;
+ int r = do_fiemap(fd, 0, 1, &fiemap);
+ if (r == -EOPNOTSUPP) {
+ dout(0) << "mount FIEMAP ioctl is NOT supported" << dendl;
+ ioctl_fiemap = false;
+ } else {
+ dout(0) << "mount FIEMAP ioctl is supported" << dendl;
+ ioctl_fiemap = true;
+ }
+
struct statfs st;
- int r = ::fstatfs(fd, &st);
+ r = ::fstatfs(fd, &st);
if (r < 0)
return -errno;
return r;
}
-#ifdef HAVE_FIEMAP_H
int FileStore::fiemap(coll_t cid, const sobject_t& oid,
uint64_t offset, size_t len,
bufferlist& bl)
{
+
+ if (!ioctl_fiemap) {
+ map<off_t, size_t> m;
+ m[offset] = len;
+ ::encode(m, bl);
+ return 0;
+ }
+
+
char fn[PATH_MAX];
struct fiemap *fiemap = NULL;
map<off_t, size_t> extmap;
free(fiemap);
return r;
}
-#else
-int FileStore::fiemap(coll_t cid, const sobject_t& oid,
- uint64_t offset, size_t len,
- bufferlist& bl)
-{
- map<off_t, size_t> m;
- m[offset] = len;
- ::encode(m, bl);
- return 0;
-}
-#endif
int FileStore::_remove(coll_t cid, const sobject_t& oid)
bool btrfs_snap_destroy;
bool btrfs_snap_create_async;
bool btrfs_wait_sync;
+ bool ioctl_fiemap;
int fsid_fd, op_fd;
int basedir_fd, current_fd;
btrfs_snap_destroy(false),
btrfs_snap_create_async(false),
btrfs_wait_sync(false),
+ ioctl_fiemap(false),
fsid_fd(-1), op_fd(-1),
attrs(this), fake_attrs(false),
collections(this), fake_collections(false),