Whamcloud - gitweb
LU-15748 osc: fallocate interop for 2.14 clients 98/47098/4
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Wed, 20 Apr 2022 09:07:53 +0000 (05:07 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 28 Apr 2022 16:01:09 +0000 (16:01 +0000)
fallocate() start and end are passed in o_size and o_blocks
on the wire.  Clients 2.15.0 and newer should always set
the OBD_MD_FLSIZE and OBD_MD_FLBLOCKS valid flags, but some
older client versions did not.  We permit older clients to
not set these flags, checking their version by proxy using
the missing OBD_CONNECT_TRUNCLOCK to imply 2.14.0 or older.

Test-Parameters: serverversion=2.14.0 testlist=sanity env=SANITY_EXCEPT="64h 103e"
Fixes: 2f496148c31d ("LU-15551 Return EOPNOTSUPP instead of EPROTO")
Fixes: 163870abfb7c ("LU-14382 mdt: implement fallocate in MDC/MDT")
Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Change-Id: I1ea47854f40d54297bceb03ad32b24737efa4ae7
Reviewed-on: https://review.whamcloud.com/47098
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_idl.h
lustre/mdt/mdt_io.c
lustre/ofd/ofd_dev.c

index e58dc92..0162137 100644 (file)
@@ -753,8 +753,10 @@ struct ptlrpc_body_v2 {
 #define OBD_CONNECT_ACL                  0x80ULL /*access control lists */
 #define OBD_CONNECT_XATTR               0x100ULL /*client use extended attr */
 #define OBD_CONNECT_LARGE_ACL          0x200ULL /* more than 32 ACL entries */
-/* was OBD_CONNECT_TRUNCLOCK           0x400ULL *locks on server for punch */
-#define OBD_CONNECT_TRANSNO             0x800ULL /*replay sends init transno */
+/* was OBD_CONNECT_TRUNCLOCK           0x400ULL *locks on server for punch */
+/* temporary reuse until 2.21.53 to indicate pre-2.15 client, see LU-15478 */
+#define OBD_CONNECT_OLD_FALLOC         0x400ULL /* missing o_valid flags */
+#define OBD_CONNECT_TRANSNO            0x800ULL /*replay sends init transno */
 #define OBD_CONNECT_IBITS             0x1000ULL /* not checked in 2.11+ */
 #define OBD_CONNECT_BARRIER           0x2000ULL /* write barrier. Resevered to
                                                  * avoid use on client.
index b417838..3892589 100644 (file)
@@ -950,15 +950,33 @@ int mdt_fallocate_hdl(struct tgt_session_info *tsi)
                RETURN(err_serious(-ENOMEM));
 
        /*
+        * fallocate() start and end are passed in o_size and o_blocks
+        * on the wire.  Clients 2.15.0 and newer should always set
+        * the OBD_MD_FLSIZE and OBD_MD_FLBLOCKS valid flags, but some
+        * older client versions did not.  We permit older clients to
+        * not set these flags, checking their version by proxy using
+        * the lack of OBD_CONNECT_TRUNCLOCK to imply 2.14.0 and older.
+        *
+        * Return -EOPNOTSUPP to also work with older clients not
+        * supporting newer server modes.
+        *
         * fallocate start and end are passed in o_size, o_blocks
         * on the wire.
         */
        if ((oa->o_valid & (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) !=
-           (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS))
-               RETURN(err_serious(-EPROTO));
+           (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 21, 53, 0)
+           && (tgt_conn_flags(tsi) & OBD_CONNECT_OLD_FALLOC)
+#endif
+           )
+               RETURN(-EOPNOTSUPP);
 
        start = oa->o_size;
        end = oa->o_blocks;
+       /* client should already limit len >= 0 */
+       if (start >= end)
+               RETURN(-EINVAL);
+
        mode = oa->o_falloc_mode;
 
        CDEBUG(D_INODE,
index 7fcb5ac..c9bcd40 100644 (file)
@@ -1985,17 +1985,30 @@ static int ofd_fallocate_hdl(struct tgt_session_info *tsi)
                RETURN(err_serious(-ENOMEM));
 
        /*
-        * fallocate start and end are passed in o_size, o_blocks
-        * on the wire.
-        * Return -EOPNOTSUPP to also handle older clients not
-        * supporting newer server modes
+        * fallocate() start and end are passed in o_size and o_blocks
+        * on the wire.  Clients 2.15.0 and newer should always set
+        * the OBD_MD_FLSIZE and OBD_MD_FLBLOCKS valid flags, but some
+        * older client versions did not.  We permit older clients to
+        * not set these flags, checking their version by proxy using
+        * the lack of OBD_CONNECT_TRUNCLOCK to imply 2.14.0 and older.
+        *
+        * Return -EOPNOTSUPP to also work with older clients not
+        * supporting newer server modes.
         */
        if ((oa->o_valid & (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) !=
-           (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS))
+           (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 21, 53, 0)
+           && (tgt_conn_flags(tsi) & OBD_CONNECT_OLD_FALLOC)
+#endif
+           )
                RETURN(-EOPNOTSUPP);
 
        start = oa->o_size;
        end = oa->o_blocks;
+       /* client should already limit len >= 0 */
+       if (start >= end)
+               RETURN(-EINVAL);
+
        mode = oa->o_falloc_mode;
        /*
         * mode == 0 (which is standard prealloc) and PUNCH is supported