Whamcloud - gitweb
LU-14838 osc: Remove lockless truncate
authorPatrick Farrell <pfarrell@whamcloud.com>
Fri, 9 Jul 2021 20:13:09 +0000 (16:13 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 6 Aug 2021 02:51:32 +0000 (02:51 +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.

Lustre-change: https://review.whamcloud.com/44204
Lustre-commit: 6335dba83995765c1ffcd7993eb8958c162913e1

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Ia2979fb6b31a61da6d4833e9f463fcd5b6dbd718
Reviewed-on: https://review.whamcloud.com/44436
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@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 958b281..885aa47 100644 (file)
@@ -108,12 +108,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 1a7c866..ced247b 100644 (file)
@@ -781,7 +781,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 */
@@ -910,10 +910,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)
 
@@ -938,7 +938,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 3c32d77..470dc8f 100644 (file)
@@ -253,7 +253,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   |
@@ -475,7 +475,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 3498334..5cbde1a 100644 (file)
@@ -555,8 +555,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 5924aa1..fe147a1 100644 (file)
@@ -880,9 +880,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 73364a0..0f9eaa9 100644 (file)
@@ -2073,9 +2073,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 3bd71dd..6e55c8f 100644 (file)
@@ -542,38 +542,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)
@@ -893,8 +861,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;
 }
 
@@ -936,7 +902,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 b50071e..d048875 100644 (file)
@@ -683,18 +683,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 *osd = lu2osc_dev(obj->co_lu.lo_dev);
-
-                       LASSERT(cl_io_is_trunc(io));
-                       LASSERT(cl_io_is_trunc(io) || cl_io_is_fallocate(io));
-                       /* XXX: Need a lock. */
-                       osd->od_stats.os_lockless_truncates++;
-               }
-       }
-
        if (cl_io_is_trunc(io)) {
                __u64 size = io->u.ci_setattr.sa_attr.lvb_size;
 
index 62da056..512a6ae 100644 (file)
@@ -799,7 +799,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 ||
@@ -820,10 +819,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 5927929..0d6f35e 100644 (file)
@@ -1239,8 +1239,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 59ce031..42b3365 100755 (executable)
@@ -3409,19 +3409,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 8d7cdaa..d55b4be 100755 (executable)
@@ -858,53 +858,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 519f648..d248a08 100644 (file)
@@ -556,7 +556,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 e104642..405e0ce 100644 (file)
@@ -1275,8 +1275,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",