coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[coreutils] Re: Feature: add ocfs2 reflink to cp(1)


From: Joel Becker
Subject: [coreutils] Re: Feature: add ocfs2 reflink to cp(1)
Date: Wed, 7 Apr 2010 18:53:49 -0700
User-agent: Mutt/1.5.20 (2009-06-14)

On Sun, Apr 04, 2010 at 11:44:48PM +0800, jeff.liu wrote:
> +/* This function detects whether the source and destination files
> +   are all resides on OCFS2.  If true, then perform the OCFS2 reflink
> +   operation.  Otherwise, performing btrfs clone operation.  */
> +static inline bool
> +is_ocfs2_file (int dst_fd, int src_fd)
> +{
> +#if HAVE_FSTATFS && HAVE_STRUCT_STATFS_F_TYPE && defined __linux__
> +  struct statfs statfsbuf1;
> +  struct statfs statfsbuf2;
> +
> +  return (fstatfs (src_fd, &statfsbuf1) == 0
> +          && statfsbuf1.f_type == S_MAGIC_OCFS2
> +          && fstatfs (dst_fd, &statfsbuf2) == 0
> +          && statfsbuf2.f_type == S_MAGIC_OCFS2);
> +#else
> +  (void) dst_fd;
> +  (void) src_fd;
> +  return false;
> +#endif
> +}

        I don't know that the correct behavior is btrfs' when ocfs2 is
not detected.

> +/* Perform the OCFS2 CoW reflink operation if possible.
> +   We do not attempt to preserve security attributes for a reference
> +   counted link.  Instead, let 'x->preserve_xxxx' to process them if
> +   they are the user expected.
> +   Upon success, return 0, Otherwise, return -1 and set errno.  */
> +static inline int
> +reflink_file (char const *src_name, char const *dst_name,
> +              int src_fd, bool *new_dst)
> +{
> +#ifdef __linux__
> +# ifndef REFLINK_ATTR_NONE
> +#  define REFLINK_ATTR_NONE 0
> +# endif

        If '-p' was specified, you should honor it with
REFLINK_ATTR_PRESERVE.

Joel

-- 

"Conservative, n.  A statesman who is enamoured of existing evils,
 as distinguished from the Liberal, who wishes to replace them
 with others."
        - Ambrose Bierce, The Devil's Dictionary

Joel Becker
Principal Software Developer
Oracle
E-mail: address@hidden
Phone: (650) 506-8127




reply via email to

[Prev in Thread] Current Thread [Next in Thread]