Whamcloud - gitweb
LU-14838 osc: Remove lockless truncate 04/44204/5
authorPatrick Farrell <pfarrell@whamcloud.com>
Fri, 9 Jul 2021 20:13:09 +0000 (16:13 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 28 Jul 2021 02:30:04 +0000 (02:30 +0000)
Lockless truncate does not work and cannot be made to work.

Fundamentally, it has no means of ensuring consistency
across clients because it can't force them all to drop
cached data without locking.

It's been off for years - let's just get rid of it.

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Ia2979fb6b31a61da6d4833e9f463fcd5b6dbd718
Reviewed-on: https://review.whamcloud.com/44204
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
14 files changed:
lustre/include/lustre_osc.h
lustre/include/uapi/linux/lustre/lustre_idl.h
lustre/llite/llite_lib.c
lustre/mdc/lproc_mdc.c
lustre/mdt/mdt_io.c
lustre/ofd/ofd_dev.c
lustre/osc/lproc_osc.c
lustre/osc/osc_io.c
lustre/osc/osc_lock.c
lustre/ptlrpc/wiretest.c
lustre/tests/sanity-sec.sh
lustre/tests/sanityn.sh
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index 464956a..f3ea5f5 100644 (file)
@@ -107,12 +107,10 @@ struct osc_device {
        struct osc_stats {
                uint64_t        os_lockless_writes;    /* by bytes */
                uint64_t        os_lockless_reads;     /* by bytes */
-               uint64_t        os_lockless_truncates; /* by times */
        } od_stats;
 
        /* configuration item(s) */
        time64_t                od_contention_time;
-       int                     od_lockless_truncate;
 };
 
 struct osc_extent;
index f7aa1d9..19cce1c 100644 (file)
@@ -753,7 +753,7 @@ 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 */
-#define OBD_CONNECT_TRUNCLOCK           0x400ULL /*locks on server for punch */
+/* was OBD_CONNECT_TRUNCLOCK           0x400ULL *locks on server for punch */
 #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 */
@@ -885,10 +885,10 @@ struct ptlrpc_body_v2 {
                                OBD_CONNECT_DISP_STRIPE | OBD_CONNECT_LFSCK | \
                                OBD_CONNECT_OPEN_BY_FID | \
                                OBD_CONNECT_DIR_STRIPE | OBD_CONNECT_GRANT | \
-                               OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_SRVLOCK | \
-                               OBD_CONNECT_BULK_MBITS | OBD_CONNECT_CKSUM | \
-                               OBD_CONNECT_MULTIMODRPCS | \
-                               OBD_CONNECT_SUBTREE | OBD_CONNECT_LARGE_ACL | \
+                               OBD_CONNECT_SRVLOCK | OBD_CONNECT_BULK_MBITS |\
+                               OBD_CONNECT_CKSUM |\
+                               OBD_CONNECT_MULTIMODRPCS |\
+                               OBD_CONNECT_SUBTREE | OBD_CONNECT_LARGE_ACL |\
                                OBD_CONNECT_GRANT_PARAM | \
                                OBD_CONNECT_SHORTIO | OBD_CONNECT_FLAGS2)
 
@@ -913,7 +913,7 @@ struct ptlrpc_body_v2 {
 
 #define OST_CONNECT_SUPPORTED  (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \
                                OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \
-                               OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_INDEX | \
+                               OBD_CONNECT_INDEX | \
                                OBD_CONNECT_BRW_SIZE | OBD_CONNECT_CANCELSET | \
                                OBD_CONNECT_AT | LRU_RESIZE_CONNECT_FLAG | \
                                OBD_CONNECT_CKSUM | OBD_CONNECT_VBR | \
index e20a0c7..f29c319 100644 (file)
@@ -304,7 +304,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
        data->ocd_connect_flags = OBD_CONNECT_IBITS    | OBD_CONNECT_NODEVOH  |
                                  OBD_CONNECT_ATTRFID  | OBD_CONNECT_GRANT |
                                  OBD_CONNECT_VERSION  | OBD_CONNECT_BRW_SIZE |
-                                 OBD_CONNECT_SRVLOCK  | OBD_CONNECT_TRUNCLOCK|
+                                 OBD_CONNECT_SRVLOCK  |
                                  OBD_CONNECT_MDS_CAPA | OBD_CONNECT_OSS_CAPA |
                                  OBD_CONNECT_CANCELSET | OBD_CONNECT_FID     |
                                  OBD_CONNECT_AT       | OBD_CONNECT_LOV_V3   |
@@ -519,7 +519,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
        data->ocd_connect_flags = OBD_CONNECT_GRANT | OBD_CONNECT_VERSION |
                                  OBD_CONNECT_REQPORTAL | OBD_CONNECT_BRW_SIZE |
                                  OBD_CONNECT_CANCELSET | OBD_CONNECT_FID |
-                                 OBD_CONNECT_SRVLOCK | OBD_CONNECT_TRUNCLOCK|
+                                 OBD_CONNECT_SRVLOCK |
                                  OBD_CONNECT_AT | OBD_CONNECT_OSS_CAPA |
                                  OBD_CONNECT_VBR | OBD_CONNECT_FULL20 |
                                  OBD_CONNECT_64BITHASH | OBD_CONNECT_MAXBYTES |
index 57e22ca..19c9511 100644 (file)
@@ -559,8 +559,6 @@ static int mdc_stats_seq_show(struct seq_file *seq, void *v)
                   stats->os_lockless_writes);
        seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
                   stats->os_lockless_reads);
-       seq_printf(seq, "lockless_truncate\t\t%llu\n",
-                  stats->os_lockless_truncates);
        return 0;
 }
 
index 7e564d1..0e70c2c 100644 (file)
@@ -882,9 +882,6 @@ int mdt_punch_hdl(struct tgt_session_info *tsi)
 
        ENTRY;
 
-       /* check that we do support OBD_CONNECT_TRUNCLOCK. */
-       BUILD_BUG_ON(!(OST_CONNECT_SUPPORTED & OBD_CONNECT_TRUNCLOCK));
-
        if ((oa->o_valid & (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) !=
            (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS))
                RETURN(err_serious(-EPROTO));
index 5440c05..8b66c31 100644 (file)
@@ -2080,9 +2080,6 @@ static int ofd_punch_hdl(struct tgt_session_info *tsi)
 
        OBD_FAIL_TIMEOUT(OBD_FAIL_OST_PAUSE_PUNCH, cfs_fail_val);
 
-       /* check that we do support OBD_CONNECT_TRUNCLOCK. */
-       BUILD_BUG_ON(!(OST_CONNECT_SUPPORTED & OBD_CONNECT_TRUNCLOCK));
-
        if ((oa->o_valid & (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) !=
            (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS))
                RETURN(err_serious(-EPROTO));
index 5dabe6b..2f28646 100644 (file)
@@ -547,38 +547,6 @@ static ssize_t contention_seconds_store(struct kobject *kobj,
 }
 LUSTRE_RW_ATTR(contention_seconds);
 
-static ssize_t lockless_truncate_show(struct kobject *kobj,
-                                     struct attribute *attr,
-                                     char *buf)
-{
-       struct obd_device *obd = container_of(kobj, struct obd_device,
-                                             obd_kset.kobj);
-       struct osc_device *od = obd2osc_dev(obd);
-
-       return sprintf(buf, "%u\n", od->od_lockless_truncate);
-}
-
-static ssize_t lockless_truncate_store(struct kobject *kobj,
-                                      struct attribute *attr,
-                                      const char *buffer,
-                                      size_t count)
-{
-       struct obd_device *obd = container_of(kobj, struct obd_device,
-                                             obd_kset.kobj);
-       struct osc_device *od = obd2osc_dev(obd);
-       bool val;
-       int rc;
-
-       rc = kstrtobool(buffer, &val);
-       if (rc)
-               return rc;
-
-       od->od_lockless_truncate = val;
-
-       return count;
-}
-LUSTRE_RW_ATTR(lockless_truncate);
-
 static ssize_t destroys_in_flight_show(struct kobject *kobj,
                                       struct attribute *attr,
                                       char *buf)
@@ -898,8 +866,6 @@ static int osc_stats_seq_show(struct seq_file *seq, void *v)
                   stats->os_lockless_writes);
        seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
                   stats->os_lockless_reads);
-       seq_printf(seq, "lockless_truncate\t\t%llu\n",
-                  stats->os_lockless_truncates);
        return 0;
 }
 
@@ -941,7 +907,6 @@ static struct attribute *osc_attrs[] = {
        &lustre_attr_cur_dirty_grant_bytes.attr,
        &lustre_attr_destroys_in_flight.attr,
        &lustre_attr_grant_shrink_interval.attr,
-       &lustre_attr_lockless_truncate.attr,
        &lustre_attr_max_dirty_mb.attr,
        &lustre_attr_max_rpcs_in_flight.attr,
        &lustre_attr_short_io_bytes.attr,
index f7f4702..70edcfb 100644 (file)
@@ -712,17 +712,6 @@ void osc_io_setattr_end(const struct lu_env *env,
                result = io->ci_result = cbargs->opc_rc;
        }
 
-       if (result == 0) {
-               if (oio->oi_lockless) {
-                       /* lockless truncate */
-                       struct osc_device *osc = lu2osc_dev(obj->co_lu.lo_dev);
-
-                       LASSERT(cl_io_is_trunc(io) || cl_io_is_fallocate(io));
-                       /* XXX: Need a lock. */
-                       osc->od_stats.os_lockless_truncates++;
-               }
-       }
-
        if (cl_io_is_trunc(io)) {
                __u64 size = io->u.ci_setattr.sa_attr.lvb_size;
 
index a440fda..3d73ac8 100644 (file)
@@ -804,7 +804,6 @@ void osc_lock_to_lockless(const struct lu_env *env,
        struct cl_io *io = oio->oi_cl.cis_io;
        struct cl_object *obj = slice->cls_obj;
        struct osc_object *oob = cl2osc(obj);
-       const struct osc_device *osd = lu2osc_dev(obj->co_lu.lo_dev);
        struct obd_connect_data *ocd;
 
        LASSERT(ols->ols_state == OLS_NEW ||
@@ -825,10 +824,7 @@ void osc_lock_to_lockless(const struct lu_env *env,
                                         OBD_CONNECT_SRVLOCK);
                if (io->ci_lockreq == CILR_NEVER ||
                    /* lockless IO */
-                   (ols->ols_locklessable && osc_object_is_contended(oob)) ||
-                   /* lockless truncate */
-                   (cl_io_is_trunc(io) && osd->od_lockless_truncate &&
-                    (ocd->ocd_connect_flags & OBD_CONNECT_TRUNCLOCK))) {
+                   (ols->ols_locklessable && osc_object_is_contended(oob))) {
                        ols->ols_locklessable = 1;
                        slice->cls_ops = ols->ols_lockless_ops;
                }
index 223c596..9724fec 100644 (file)
@@ -1238,8 +1238,6 @@ void lustre_assert_wire_constants(void)
                 OBD_CONNECT_XATTR);
        LASSERTF(OBD_CONNECT_LARGE_ACL == 0x200ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_LARGE_ACL);
-       LASSERTF(OBD_CONNECT_TRUNCLOCK == 0x400ULL, "found 0x%.16llxULL\n",
-                OBD_CONNECT_TRUNCLOCK);
        LASSERTF(OBD_CONNECT_TRANSNO == 0x800ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_TRANSNO);
        LASSERTF(OBD_CONNECT_IBITS == 0x1000ULL, "found 0x%.16llxULL\n",
index d7221e2..e95536e 100755 (executable)
@@ -3431,19 +3431,6 @@ test_48a() {
        cmp -bl $tmpfile $testfile ||
                error "file $testfile is corrupted (4)"
 
-       # lockless truncate should be turned into regular truncate for enc file
-       save_lustre_params client "osc.*.lockless_truncate" > $save
-       # restore lockless_truncate default values on exit
-       stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
-       cancel_lru_locks osc ; cancel_lru_locks mdc
-       lctl set_param -n osc.*.lockless_truncate 1
-       cancel_lru_locks osc
-       clear_stats osc.*.osc_stats
-       $TRUNCATE $testfile 8000000 || error "truncate failed (1)"
-       [ $(calc_stats osc.*.osc_stats lockless_truncate) -eq 0 ] ||
-               error "lockless truncate should be turned into regular truncate"
-       lctl set_param -n osc.*.lockless_truncate 0
-
        # truncate to a smaller, non-multiple of PAGE_SIZE, non-multiple of 16
        sz=$((sz-7))
        $TRUNCATE $tmpfile $sz
index 2a7e2be..5498ad3 100755 (executable)
@@ -866,53 +866,6 @@ test_31b() {
 }
 run_test 31b "voluntary OST cancel / blocking ast race=============="
 
-# enable/disable lockless truncate feature, depending on the arg 0/1
-enable_lockless_truncate() {
-       lctl set_param -n $OSC.*.lockless_truncate $1
-}
-
-test_32a() { # bug 11270
-       local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
-       local stripe_size=$(do_facet $SINGLEMDS \
-               "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
-
-       save_lustre_params client "$OSC.*.lockless_truncate" > $save
-       # restore lockless_truncate default values on exit
-       stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
-       cancel_lru_locks $OSC
-       enable_lockless_truncate 1
-       rm -f $DIR1/$tfile
-       lfs setstripe -c -1 $DIR1/$tfile
-       dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$stripe_size > \
-               /dev/null 2>&1
-       clear_stats $OSC.*.${OSC}_stats
-
-       log "checking cached lockless truncate"
-       $TRUNCATE $DIR1/$tfile 8000000
-       $CHECKSTAT -s 8000000 $DIR2/$tfile ||
-               error "cached truncate - wrong file size"
-       [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
-               error "cached truncate isn't lockless"
-
-       log "checking not cached lockless truncate"
-       $TRUNCATE $DIR2/$tfile 5000000
-       $CHECKSTAT -s 5000000 $DIR1/$tfile ||
-               error "not cached truncate - wrong file size"
-       [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
-               error "not cached truncate isn't lockless"
-
-       log "disabled lockless truncate"
-       enable_lockless_truncate 0
-       clear_stats $OSC.*.${OSC}_stats
-       $TRUNCATE $DIR2/$tfile 3000000
-       $CHECKSTAT -s 3000000 $DIR1/$tfile ||
-               error "lockless truncate disabled - wrong file size"
-       [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
-               error "lockless truncate disabling failed"
-       rm -f $DIR1/$tfile
-}
-run_test 32a "lockless truncate"
-
 test_32b() { # bug 11270
        remote_ost_nodsh && skip "remote OST with nodsh" && return
 
index 2572237..511bdbf 100644 (file)
@@ -555,7 +555,6 @@ check_obd_connect_data(void)
        CHECK_DEFINE_64X(OBD_CONNECT_ACL);
        CHECK_DEFINE_64X(OBD_CONNECT_XATTR);
        CHECK_DEFINE_64X(OBD_CONNECT_LARGE_ACL);
-       CHECK_DEFINE_64X(OBD_CONNECT_TRUNCLOCK);
        CHECK_DEFINE_64X(OBD_CONNECT_TRANSNO);
        CHECK_DEFINE_64X(OBD_CONNECT_IBITS);
        CHECK_DEFINE_64X(OBD_CONNECT_BARRIER);
index 4983037..2911910 100644 (file)
@@ -1263,8 +1263,6 @@ void lustre_assert_wire_constants(void)
                 OBD_CONNECT_XATTR);
        LASSERTF(OBD_CONNECT_LARGE_ACL == 0x200ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_LARGE_ACL);
-       LASSERTF(OBD_CONNECT_TRUNCLOCK == 0x400ULL, "found 0x%.16llxULL\n",
-                OBD_CONNECT_TRUNCLOCK);
        LASSERTF(OBD_CONNECT_TRANSNO == 0x800ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_TRANSNO);
        LASSERTF(OBD_CONNECT_IBITS == 0x1000ULL, "found 0x%.16llxULL\n",