]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add ceph_ll_sync_inode 21109/head
authorJeff Layton <jlayton@redhat.com>
Wed, 14 Mar 2018 16:25:36 +0000 (12:25 -0400)
committerPrashant D <pdhange@redhat.com>
Wed, 28 Mar 2018 22:40:35 +0000 (18:40 -0400)
Ganesha's NFS SETATTR requests are expected to be synchronous, but
libcephfs can cache attribute changes if the client has the right caps.
An fsync after changing the attributes would flush the caps back to the
MDS, but we may not have an Fh in the context of a SETATTR request.

Add a way to sync a specific Inode, even when we don't have easy access
to a Fh.

Tracker: http://tracker.ceph.com/issues/23291
Signed-off-by: Jeff Layton <jlayton@redhat.com>
(cherry picked from commit 78628a5fde277927126d4d6e5d2957e7e6d42fb1)

src/client/Client.cc
src/client/Client.h
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 1fd435839490a2d240a7a4d207d292aa45871559..ccbe64a01c0432330877a25b333688ec074fece4 100644 (file)
@@ -12879,6 +12879,19 @@ int Client::ll_fsync(Fh *fh, bool syncdataonly)
   return r;
 }
 
+int Client::ll_sync_inode(Inode *in, bool syncdataonly)
+{
+  Mutex::Locker lock(client_lock);
+  ldout(cct, 3) << "ll_sync_inode " << *in << " " << dendl;
+  tout(cct) << "ll_sync_inode" << std::endl;
+  tout(cct) << (unsigned long)in << std::endl;
+
+  if (unmounting)
+    return -ENOTCONN;
+
+  return _fsync(in, syncdataonly);
+}
+
 #ifdef FALLOC_FL_PUNCH_HOLE
 
 int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length)
index 0d7cd787bad13ec4ee5c6256d1ec6c271441d0ce..6c131182b8a4c698d277b194d8c7dfd30e07fd22 100644 (file)
@@ -1221,6 +1221,7 @@ public:
   loff_t ll_lseek(Fh *fh, loff_t offset, int whence);
   int ll_flush(Fh *fh);
   int ll_fsync(Fh *fh, bool syncdataonly);
+  int ll_sync_inode(Inode *in, bool syncdataonly);
   int ll_fallocate(Fh *fh, int mode, loff_t offset, loff_t length);
   int ll_release(Fh *fh);
   int ll_getlk(Fh *fh, struct flock *fl, uint64_t owner);
index 0a48c80c9c569074a98b5c3d2d14576cb0102aa3..b6c0f706a419dd8209e9c4bcbd0e9d02f8288c14 100644 (file)
@@ -1473,6 +1473,8 @@ int ceph_ll_read(struct ceph_mount_info *cmount, struct Fh* filehandle,
                 int64_t off, uint64_t len, char* buf);
 int ceph_ll_fsync(struct ceph_mount_info *cmount, struct Fh *fh,
                  int syncdataonly);
+int ceph_ll_sync_inode(struct ceph_mount_info *cmount, struct Inode *in,
+                 int syncdataonly);
 int ceph_ll_write(struct ceph_mount_info *cmount, struct Fh* filehandle,
                  int64_t off, uint64_t len, const char *data);
 int64_t ceph_ll_readv(struct ceph_mount_info *cmount, struct Fh *fh,
index cb7a0131782f90d6c74980c6bcac613b9584a6ed..f3fa5a97b2efb9c80d6fb079ec916153e19d9966 100644 (file)
@@ -1539,6 +1539,12 @@ extern "C" int ceph_ll_fsync(class ceph_mount_info *cmount,
   return (cmount->get_client()->ll_fsync(fh, syncdataonly));
 }
 
+extern "C" int ceph_ll_sync_inode(class ceph_mount_info *cmount,
+                            Inode *in, int syncdataonly)
+{
+  return (cmount->get_client()->ll_sync_inode(in, syncdataonly));
+}
+
 extern "C" off_t ceph_ll_lseek(class ceph_mount_info *cmount,
                                Fh *fh, off_t offset, int whence)
 {