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>
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;
#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 */
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)
#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 | \
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 |
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 |
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;
}
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));
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));
}
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)
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;
}
&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,
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;
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 ||
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;
}
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",
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
}
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
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);
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",