libceph: add CEPH_OSD_OP_ASSERT_VER support
authorJeff Layton <jlayton@kernel.org>
Thu, 25 Aug 2022 13:31:05 +0000 (09:31 -0400)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 24 Aug 2023 09:24:35 +0000 (11:24 +0200)
...and record the user_version in the reply in a new field in
ceph_osd_request, so we can populate the assert_ver appropriately.
Shuffle the fields a bit too so that the new field fits in an
existing hole on x86_64.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-and-tested-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: Milind Changire <mchangir@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
include/linux/ceph/osd_client.h
include/linux/ceph/rados.h
net/ceph/osd_client.c

index 8f5d2b5..bf98239 100644 (file)
@@ -198,6 +198,9 @@ struct ceph_osd_req_op {
                        u32 src_fadvise_flags;
                        struct ceph_osd_data osd_data;
                } copy_from;
+               struct {
+                       u64 ver;
+               } assert_ver;
        };
 };
 
@@ -252,6 +255,7 @@ struct ceph_osd_request {
        struct ceph_osd_client *r_osdc;
        struct kref       r_kref;
        bool              r_mempool;
+       bool              r_linger;           /* don't resend on failure */
        struct completion r_completion;       /* private to osd_client.c */
        ceph_osdc_callback_t r_callback;
 
@@ -264,9 +268,9 @@ struct ceph_osd_request {
        struct ceph_snap_context *r_snapc;    /* for writes */
        struct timespec64 r_mtime;            /* ditto */
        u64 r_data_offset;                    /* ditto */
-       bool r_linger;                        /* don't resend on failure */
 
        /* internal */
+       u64 r_version;                        /* data version sent in reply */
        unsigned long r_stamp;                /* jiffies, send or check time */
        unsigned long r_start_stamp;          /* jiffies */
        ktime_t r_start_latency;              /* ktime_t */
index 43a7a15..73c3efb 100644 (file)
@@ -524,6 +524,10 @@ struct ceph_osd_op {
                        __le64 cookie;
                } __attribute__ ((packed)) notify;
                struct {
+                       __le64 unused;
+                       __le64 ver;
+               } __attribute__ ((packed)) assert_ver;
+               struct {
                        __le64 offset, length;
                        __le64 src_offset;
                } __attribute__ ((packed)) clonerange;
index 684faf8..7f159e4 100644 (file)
@@ -1048,6 +1048,10 @@ static u32 osd_req_encode_op(struct ceph_osd_op *dst,
                dst->copy_from.src_fadvise_flags =
                        cpu_to_le32(src->copy_from.src_fadvise_flags);
                break;
+       case CEPH_OSD_OP_ASSERT_VER:
+               dst->assert_ver.unused = cpu_to_le64(0);
+               dst->assert_ver.ver = cpu_to_le64(src->assert_ver.ver);
+               break;
        default:
                pr_err("unsupported osd opcode %s\n",
                        ceph_osd_op_name(src->op));
@@ -3859,6 +3863,7 @@ static void handle_reply(struct ceph_osd *osd, struct ceph_msg *msg)
         * one (type of) reply back.
         */
        WARN_ON(!(m.flags & CEPH_OSD_FLAG_ONDISK));
+       req->r_version = m.user_version;
        req->r_result = m.result ?: data_len;
        finish_request(req);
        mutex_unlock(&osd->lock);