]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: switch AT_NO_ATTR_SYNC to AT_STATX_DONT_SYNC
authorXiubo Li <xiubli@redhat.com>
Mon, 11 Apr 2022 02:22:00 +0000 (10:22 +0800)
committerXiubo Li <xiubli@redhat.com>
Wed, 15 Jun 2022 01:49:14 +0000 (09:49 +0800)
The glibc has defined its own STATX SYNC related flags:

  define AT_STATX_SYNC_TYPE    0x6000
  define AT_STATX_SYNC_AS_STAT 0x0000
  define AT_STATX_FORCE_SYNC   0x2000
  define AT_STATX_DONT_SYNC    0x4000

Just switch to use the standard ones.

Fixes: https://tracker.ceph.com/issues/55253
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit 4654f9350cb1285859f58e1bc0abdcc9e141f879)

src/client/Client.cc
src/client/Client.h
src/client/hypertable/CephBroker.cc
src/include/cephfs/ceph_ll_client.h
src/include/cephfs/libcephfs.h
src/pybind/cephfs/cephfs.pyx
src/test/libcephfs/test.cc
src/tools/cephfs_mirror/PeerReplayer.cc

index 33253ed10c0d1ae5e726e367ee39a1f157d3277b..2f9dafd034bb7c76bd20df30c8d88ed8aad7ef5e 100644 (file)
@@ -7964,11 +7964,11 @@ unsigned Client::statx_to_mask(unsigned int flags, unsigned int want)
 {
   unsigned mask = 0;
 
-  /* if NO_ATTR_SYNC is set, then we don't need any -- just use what's in cache */
-  if (flags & AT_NO_ATTR_SYNC)
+  /* if AT_STATX_DONT_SYNC is set, then we don't need any -- just use what's in cache */
+  if (flags & AT_STATX_DONT_SYNC)
     goto out;
 
-  /* Always set PIN to distinguish from AT_NO_ATTR_SYNC case */
+  /* Always set PIN to distinguish from AT_STATX_DONT_SYNC case */
   mask |= CEPH_CAP_PIN;
   if (want & (CEPH_STATX_MODE|CEPH_STATX_UID|CEPH_STATX_GID|CEPH_STATX_BTIME|CEPH_STATX_CTIME|CEPH_STATX_VERSION))
     mask |= CEPH_CAP_AUTH_SHARED;
@@ -8096,7 +8096,7 @@ void Client::fill_statx(Inode *in, unsigned int mask, struct ceph_statx *stx)
   memset(stx, 0, sizeof(struct ceph_statx));
 
   /*
-   * If mask is 0, then the caller set AT_NO_ATTR_SYNC. Reset the mask
+   * If mask is 0, then the caller set AT_STATX_DONT_SYNC. Reset the mask
    * so that all bits are set.
    */
   if (!mask)
index 84fc15d3fe87968bfac04aa0402b848763e8ac97..63fc742added2f54fe534f0f575d9786e62eed94 100644 (file)
@@ -344,7 +344,7 @@ public:
    * If @a cb returns a negative error code, stop and return that.
    */
   int readdir_r_cb(dir_result_t *dirp, add_dirent_cb_t cb, void *p,
-                  unsigned want=0, unsigned flags=AT_NO_ATTR_SYNC,
+                  unsigned want=0, unsigned flags=AT_STATX_DONT_SYNC,
                   bool getref=false);
 
   struct dirent * readdir(dir_result_t *d);
index d3f283a0b070b0613c5c32c8ee4666e82fba8e6f..596e722871f1bb761287db401993f16022ef5064 100644 (file)
@@ -388,7 +388,7 @@ int CephBroker::rmdir_recursive(const char *directory) {
   int r;
   if ((r = ceph_opendir(cmount, directory, &dirp)) < 0)
     return r; //failed to open
-  while ((r = ceph_readdirplus_r(cmount, dirp, &de, &stx, CEPH_STATX_INO, AT_NO_ATTR_SYNC, NULL)) > 0) {
+  while ((r = ceph_readdirplus_r(cmount, dirp, &de, &stx, CEPH_STATX_INO, AT_STATX_DONT_SYNC, NULL)) > 0) {
     String new_dir = de.d_name;
     if(!(new_dir.compare(".")==0 || new_dir.compare("..")==0)) {
       new_dir = directory;
index 5bc693846b971671ee88c0a4f88e1d9ffc12f76a..2f2f6e696fcef1386f834f514c8e32aef90eae7a 100644 (file)
@@ -92,15 +92,18 @@ struct ceph_statx {
 /*
  * Compatibility macros until these defines make their way into glibc
  */
-#ifndef AT_NO_ATTR_SYNC
-#define AT_NO_ATTR_SYNC                0x4000 /* Don't sync attributes with the server */
+#ifndef AT_STATX_DONT_SYNC
+#define AT_STATX_SYNC_TYPE     0x6000
+#define AT_STATX_SYNC_AS_STAT  0x0000
+#define AT_STATX_FORCE_SYNC    0x2000
+#define AT_STATX_DONT_SYNC     0x4000 /* Don't sync attributes with the server */
 #endif
 
 /*
  * The statx interfaces only allow these flags. In order to allow us to add
  * others in the future, we disallow setting any that aren't recognized.
  */
-#define CEPH_REQ_FLAG_MASK             (AT_SYMLINK_NOFOLLOW|AT_NO_ATTR_SYNC)
+#define CEPH_REQ_FLAG_MASK             (AT_SYMLINK_NOFOLLOW|AT_STATX_DONT_SYNC)
 
 /* fallocate mode flags */
 #ifndef FALLOC_FL_KEEP_SIZE
index a348a5b6c00675c1de2379599b7b187c18406a89..344d763e8d87b94a2ebf4956da65c51a59396681 100644 (file)
@@ -852,7 +852,7 @@ int ceph_rename(struct ceph_mount_info *cmount, const char *from, const char *to
  * @param fd the file descriptor of the file to get statistics of.
  * @param stx the ceph_statx struct that will be filled in with the file's statistics.
  * @param want bitfield of CEPH_STATX_* flags showing designed attributes
- * @param flags bitfield that can be used to set AT_* modifier flags (only AT_NO_ATTR_SYNC and AT_SYMLINK_NOFOLLOW)
+ * @param flags bitfield that can be used to set AT_* modifier flags (AT_STATX_SYNC_AS_STAT, AT_STATX_FORCE_SYNC, AT_STATX_DONT_SYNC and AT_SYMLINK_NOFOLLOW)
  * @returns 0 on success or negative error code on failure.
  */
 int ceph_fstatx(struct ceph_mount_info *cmount, int fd, struct ceph_statx *stx,
@@ -866,7 +866,7 @@ int ceph_fstatx(struct ceph_mount_info *cmount, int fd, struct ceph_statx *stx,
  * @param relpath to the file/directory to get statistics of
  * @param stx the ceph_statx struct that will be filled in with the file's statistics.
  * @param want bitfield of CEPH_STATX_* flags showing designed attributes
- * @param flags bitfield that can be used to set AT_* modifier flags (only AT_NO_ATTR_SYNC and AT_SYMLINK_NOFOLLOW)
+ * @param flags bitfield that can be used to set AT_* modifier flags (AT_STATX_SYNC_AS_STAT, AT_STATX_FORCE_SYNC, AT_STATX_DONT_SYNC and AT_SYMLINK_NOFOLLOW)
  * @returns 0 on success or negative error code on failure.
  */
 int ceph_statxat(struct ceph_mount_info *cmount, int dirfd, const char *relpath,
@@ -879,7 +879,7 @@ int ceph_statxat(struct ceph_mount_info *cmount, int dirfd, const char *relpath,
  * @param path the file or directory to get the statistics of.
  * @param stx the ceph_statx struct that will be filled in with the file's statistics.
  * @param want bitfield of CEPH_STATX_* flags showing designed attributes
- * @param flags bitfield that can be used to set AT_* modifier flags (only AT_NO_ATTR_SYNC and AT_SYMLINK_NOFOLLOW)
+ * @param flags bitfield that can be used to set AT_* modifier flags (AT_STATX_SYNC_AS_STAT, AT_STATX_FORCE_SYNC, AT_STATX_DONT_SYNC and AT_SYMLINK_NOFOLLOW)
  * @returns 0 on success or negative error code on failure.
  */
 int ceph_statx(struct ceph_mount_info *cmount, const char *path, struct ceph_statx *stx,
index 96125ba2e43698c0dc13a7d22bc5c0071040a317..8d687851ffa8e7dc4da5bc3f82a742e9e07878f2 100644 (file)
@@ -22,8 +22,11 @@ import os
 import time
 from typing import Any, Dict, Optional
 
-AT_NO_ATTR_SYNC = 0x4000
-AT_SYMLINK_NOFOLLOW = 0x100
+AT_SYMLINK_NOFOLLOW = 0x0100
+AT_STATX_SYNC_TYPE  = 0x6000
+AT_STATX_SYNC_AS_STAT = 0x0000
+AT_STATX_FORCE_SYNC = 0x2000
+AT_STATX_DONT_SYNC = 0x4000
 cdef int AT_SYMLINK_NOFOLLOW_CDEF = AT_SYMLINK_NOFOLLOW
 CEPH_STATX_BASIC_STATS = 0x7ff
 cdef int CEPH_STATX_BASIC_STATS_CDEF = CEPH_STATX_BASIC_STATS
@@ -1941,7 +1944,7 @@ cdef class LibCephFS(object):
 
         :param path: the file or directory to get the statistics of.
         :param mask: want bitfield of CEPH_STATX_* flags showing designed attributes.
-        :param flag: bitfield that can be used to set AT_* modifier flags (only AT_NO_ATTR_SYNC and AT_SYMLINK_NOFOLLOW)
+        :param flag: bitfield that can be used to set AT_* modifier flags (AT_STATX_SYNC_AS_STAT, AT_STATX_FORCE_SYNC, AT_STATX_DONT_SYNC and AT_SYMLINK_NOFOLLOW)
         """
 
         self.require_state("mounted")
index 75b66798e24086765c20060ab8927b1875c3722c..585fae104dea452f3572331e66bb77f9b8f8ebff 100644 (file)
@@ -470,7 +470,7 @@ TEST(LibCephFS, DirLs) {
     struct dirent rdent;
     struct ceph_statx stx;
     int len = ceph_readdirplus_r(cmount, ls_dir, &rdent, &stx,
-                                CEPH_STATX_SIZE, AT_NO_ATTR_SYNC, NULL);
+                                CEPH_STATX_SIZE, AT_STATX_DONT_SYNC, NULL);
     if (len == 0)
       break;
     ASSERT_EQ(len, 1);
@@ -1811,13 +1811,13 @@ TEST(LibCephFS, LazyStatx) {
 
   /*
    * Now sleep, do a chmod on the first client and the see whether we get a
-   * different ctime with a statx that uses AT_NO_ATTR_SYNC
+   * different ctime with a statx that uses AT_STATX_DONT_SYNC
    */
   sleep(1);
   stx.stx_mode = 0644;
   ASSERT_EQ(ceph_ll_setattr(cmount1, file1, &stx, CEPH_SETATTR_MODE, perms1), 0);
 
-  ASSERT_EQ(ceph_ll_getattr(cmount2, file2, &stx, CEPH_STATX_CTIME, AT_NO_ATTR_SYNC, perms2), 0);
+  ASSERT_EQ(ceph_ll_getattr(cmount2, file2, &stx, CEPH_STATX_CTIME, AT_STATX_DONT_SYNC, perms2), 0);
   ASSERT_TRUE(stx.stx_mask & CEPH_STATX_CTIME);
   ASSERT_TRUE(stx.stx_ctime.tv_sec == old_ctime.tv_sec &&
              stx.stx_ctime.tv_nsec == old_ctime.tv_nsec);
index d5ab7a215a143c7302e6db8cef11be2a80ff7320..064f2bd4d4f935b1dc59086b7b8f0e8b29d79a53 100644 (file)
@@ -761,7 +761,7 @@ int PeerReplayer::cleanup_remote_dir(const std::string &dir_root,
   int r = ceph_statxat(m_remote_mount, fh.r_fd_dir_root, epath.c_str(), &tstx,
                        CEPH_STATX_MODE | CEPH_STATX_UID | CEPH_STATX_GID |
                        CEPH_STATX_SIZE | CEPH_STATX_ATIME | CEPH_STATX_MTIME,
-                       AT_NO_ATTR_SYNC | AT_SYMLINK_NOFOLLOW);
+                       AT_STATX_DONT_SYNC | AT_SYMLINK_NOFOLLOW);
   if (r < 0) {
     derr << ": failed to stat remote directory=" << epath << ": "
          << cpp_strerror(r) << dendl;
@@ -794,7 +794,7 @@ int PeerReplayer::cleanup_remote_dir(const std::string &dir_root,
       struct dirent de;
       while (true) {
         r = ceph_readdirplus_r(m_remote_mount, entry.dirp, &de, &stx,
-                               CEPH_STATX_MODE, AT_NO_ATTR_SYNC | AT_SYMLINK_NOFOLLOW, NULL);
+                               CEPH_STATX_MODE, AT_STATX_DONT_SYNC | AT_SYMLINK_NOFOLLOW, NULL);
         if (r < 0) {
           derr << ": failed to read remote directory=" << entry.epath << dendl;
           break;
@@ -880,7 +880,7 @@ int PeerReplayer::should_sync_entry(const std::string &epath, const struct ceph_
   int r = ceph_statxat(fh.p_mnt, fh.p_fd, epath.c_str(), &pstx,
                        CEPH_STATX_MODE | CEPH_STATX_UID | CEPH_STATX_GID |
                        CEPH_STATX_SIZE | CEPH_STATX_CTIME | CEPH_STATX_MTIME,
-                       AT_NO_ATTR_SYNC | AT_SYMLINK_NOFOLLOW);
+                       AT_STATX_DONT_SYNC | AT_SYMLINK_NOFOLLOW);
   if (r < 0 && r != -ENOENT && r != -ENOTDIR) {
     derr << ": failed to stat prev entry= " << epath << ": " << cpp_strerror(r)
          << dendl;
@@ -974,7 +974,7 @@ int PeerReplayer::propagate_deleted_entries(const std::string &dir_root,
       struct ceph_statx pstx;
       auto dpath = entry_path(epath, d_name);
       r = ceph_statxat(fh.p_mnt, fh.p_fd, dpath.c_str(), &pstx,
-                       CEPH_STATX_MODE, AT_NO_ATTR_SYNC | AT_SYMLINK_NOFOLLOW);
+                       CEPH_STATX_MODE, AT_STATX_DONT_SYNC | AT_SYMLINK_NOFOLLOW);
       if (r < 0) {
         derr << ": failed to stat (prev) directory=" << dpath << ": "
              << cpp_strerror(r) << dendl;
@@ -988,7 +988,7 @@ int PeerReplayer::propagate_deleted_entries(const std::string &dir_root,
 
       struct ceph_statx cstx;
       r = ceph_statxat(m_local_mount, fh.c_fd, dpath.c_str(), &cstx,
-                       CEPH_STATX_MODE, AT_NO_ATTR_SYNC | AT_SYMLINK_NOFOLLOW);
+                       CEPH_STATX_MODE, AT_STATX_DONT_SYNC | AT_SYMLINK_NOFOLLOW);
       if (r < 0 && r != -ENOENT) {
         derr << ": failed to stat local (cur) directory=" << dpath << ": "
              << cpp_strerror(r) << dendl;
@@ -1169,7 +1169,7 @@ int PeerReplayer::do_synchronize(const std::string &dir_root, const Snapshot &cu
   r = ceph_fstatx(m_local_mount, fh.c_fd, &tstx,
                   CEPH_STATX_MODE | CEPH_STATX_UID | CEPH_STATX_GID |
                   CEPH_STATX_SIZE | CEPH_STATX_ATIME | CEPH_STATX_MTIME,
-                  AT_NO_ATTR_SYNC | AT_SYMLINK_NOFOLLOW);
+                  AT_STATX_DONT_SYNC | AT_SYMLINK_NOFOLLOW);
   if (r < 0) {
     derr << ": failed to stat snap=" << current.first << ": " << cpp_strerror(r)
          << dendl;
@@ -1214,7 +1214,7 @@ int PeerReplayer::do_synchronize(const std::string &dir_root, const Snapshot &cu
         r = ceph_readdirplus_r(m_local_mount, entry.dirp, &de, &stx,
                                CEPH_STATX_MODE | CEPH_STATX_UID | CEPH_STATX_GID |
                                CEPH_STATX_SIZE | CEPH_STATX_ATIME | CEPH_STATX_MTIME,
-                               AT_NO_ATTR_SYNC | AT_SYMLINK_NOFOLLOW, NULL);
+                               AT_STATX_DONT_SYNC | AT_SYMLINK_NOFOLLOW, NULL);
         if (r < 0) {
           derr << ": failed to local read directory=" << entry.epath << dendl;
           break;