]> git.apps.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:46:59 +0000 (09:46 +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 ccc9f66bb9c08ea2bd6f9f4d43b14312e38ae102..3513de3518b3a5263f57407bd256fe6d5b4ae955 100644 (file)
@@ -7903,11 +7903,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;
@@ -8035,7 +8035,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 43263a1cdfadcfe1f5e6f6f957d8e4859d68f39c..57c18289f0acc1c664c6b1778bae69c2da01d733 100644 (file)
@@ -343,7 +343,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 78731db218d6823fa001aeb5bb201f28050f675c..53cccc8504014a949bf02ecc4b4b8509346e415f 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)
 
 /* delegation recalls */
 typedef void (*ceph_deleg_cb_t)(Fh *fh, void *priv);
index 4e20549dc385f95890ddfa7f33a763f02f2450af..185d5e40e04b155e05957374b80095826b229677 100644 (file)
@@ -851,7 +851,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,
@@ -865,7 +865,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,
@@ -878,7 +878,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 493b3a2c77636807881fd9f4cc9ff278d014b8af..3535a39644aef0b44130bfc44c24a1d8f6b5f7e7 100644 (file)
@@ -21,8 +21,11 @@ from datetime import datetime
 import os
 import time
 
-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
@@ -1939,7 +1942,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 8208029bbae2dd01da665e8c6610f01fa8db9aff..c41569152baffaf6d897b9182e9e48829bf42435 100644 (file)
@@ -467,7 +467,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);
@@ -1808,13 +1808,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 44796cb4973af0f5ba07b9c8b9740d9c6a5f01ea..aaf97b8684c479fe1a5213fa6479f04051b044cd 100644 (file)
@@ -759,7 +759,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;
@@ -792,7 +792,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;
@@ -878,7 +878,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;
@@ -972,7 +972,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;
@@ -986,7 +986,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;
@@ -1167,7 +1167,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;
@@ -1212,7 +1212,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;