Commit ab618349 authored by Mark Fasheh's avatar Mark Fasheh

Allow dedupe on xfs (experimental)

There are patches out for review which add dedupe support to xfs via the
extent_same ioctl. We only need to relax the check for a dedupe fs in order
to dedupe on xfs.
Signed-off-by: 's avatarMark Fasheh <mfasheh@suse.de>
parent 6330ba23
......@@ -60,23 +60,6 @@ int lookup_btrfs_subvolid(int fd, uint64_t *subvolid)
return 0;
}
int check_file_btrfs(int fd, int *btrfs)
{
int ret;
struct statfs fs;
*btrfs = 0;
ret = fstatfs(fd, &fs);
if (ret)
return errno;
if (fs.f_type == BTRFS_SUPER_MAGIC)
*btrfs = 1;
return ret;
}
static uint64_t get_btrfs_fsid(fsid_t in_statfs_fsid, uint64_t subvolid,
fsid_t *out_fsid)
{
......
......@@ -16,7 +16,6 @@
#ifndef __BTRFS_UTIL__
#define __BTRFS_UTIL__
int check_file_btrfs(int fd, int *btrfs);
int lookup_btrfs_subvolid(int fd, uint64_t *rootid);
/*
* Figure out if we're btrfs. If we are, get the fsid. Otherwise
......
......@@ -31,6 +31,8 @@
#include <linux/limits.h>
#include <linux/fiemap.h>
#include <inttypes.h>
#include <linux/magic.h>
#include <sys/statfs.h>
#include <glib.h>
......@@ -44,6 +46,11 @@
#include "d_tree.h"
#include "dbfile.h"
/* This is not in linux/magic.h */
#ifndef XFS_SB_MAGIC
#define XFS_SB_MAGIC 0x58465342 /* 'XFSB' */
#endif
static char path[PATH_MAX] = { 0, };
static char *pathp = path;
static char *path_max = &path[PATH_MAX - 1];
......@@ -186,9 +193,9 @@ static int __add_file(const char *name, struct stat *st,
{
int ret;
int fd;
int on_btrfs = 0;
struct filerec *file;
uint64_t subvolid;
struct statfs fs;
if (S_ISDIR(st->st_mode))
goto out;
......@@ -219,21 +226,24 @@ static int __add_file(const char *name, struct stat *st,
goto out;
}
ret = check_file_btrfs(fd, &on_btrfs);
ret = fstatfs(fd, &fs);
if (ret) {
close(fd);
fprintf(stderr, "Skip file \"%s\" due to errors\n", name);
fprintf(stderr, "Error %d: %s while doing fs stat on \"%s\". "
"Skipping.\n", ret, strerror(ret), name);
goto out;
}
if (run_dedupe && !on_btrfs) {
if (run_dedupe &&
((fs.f_type != BTRFS_SUPER_MAGIC &&
fs.f_type != XFS_SB_MAGIC))) {
close(fd);
fprintf(stderr, "\"%s\": Can only dedupe files on btrfs\n",
name);
fprintf(stderr, "\"%s\": Can only dedupe files on btrfs or xfs "
"(experimental)\n", name);
return ENOSYS;
}
if (on_btrfs) {
if (fs.f_type == BTRFS_SUPER_MAGIC) {
/*
* Inodes between subvolumes on a btrfs file system
* can have the same i_ino. Get the subvolume id of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment