Lockless DIO don't update a KMS as other IO type does,
it caused a situation when next read don't known a real file size
to be read. Lets avoid using an invalid KMS.
Fixes:
6bce5367 (LU-4198 clio: turn on lockless for some kind of IO)
Signed-off-by: Alexey Lyashkov <alexey.lyashkov@hpe.com>
Change-Id: Ie71d3f3cc24fc16c03ed07f9f5a3a17c7fdfa684
Reviewed-on: https://review.whamcloud.com/47395
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
struct cl_attr {
/** Object size, in bytes */
loff_t cat_size;
struct cl_attr {
/** Object size, in bytes */
loff_t cat_size;
+
+ unsigned int cat_kms_valid:1;
/**
* Known minimal size, in bytes.
*
/**
* Known minimal size, in bytes.
*
result = cl_object_attr_get(env, obj, attr);
if (result == 0) {
kms = attr->cat_kms;
result = cl_object_attr_get(env, obj, attr);
if (result == 0) {
kms = attr->cat_kms;
+ if (pos > kms || !attr->cat_kms_valid) {
/*
* A glimpse is necessary to determine whether we
* return a short read (B) or some zeroes at the end
/*
* A glimpse is necessary to determine whether we
* return a short read (B) or some zeroes at the end
/* lov_merge.c */
int lov_merge_lvb_kms(struct lov_stripe_md *lsm, int index,
/* lov_merge.c */
int lov_merge_lvb_kms(struct lov_stripe_md *lsm, int index,
- struct ost_lvb *lvb, __u64 *kms_place);
/* lov_offset.c */
loff_t stripe_width(struct lov_stripe_md *lsm, unsigned int index);
/* lov_offset.c */
loff_t stripe_width(struct lov_stripe_md *lsm, unsigned int index);
#define DEBUG_SUBSYSTEM S_LOV
#include <libcfs/libcfs.h>
#define DEBUG_SUBSYSTEM S_LOV
#include <libcfs/libcfs.h>
#include <obd_class.h>
#include "lov_internal.h"
#include <obd_class.h>
#include "lov_internal.h"
* uptodate time on the local client.
*/
int lov_merge_lvb_kms(struct lov_stripe_md *lsm, int index,
* uptodate time on the local client.
*/
int lov_merge_lvb_kms(struct lov_stripe_md *lsm, int index,
- struct ost_lvb *lvb, __u64 *kms_place)
{
struct lov_stripe_md_entry *lse = lsm->lsm_entries[index];
u64 size = 0;
u64 kms = 0;
u64 blocks = 0;
{
struct lov_stripe_md_entry *lse = lsm->lsm_entries[index];
u64 size = 0;
u64 kms = 0;
u64 blocks = 0;
- s64 current_mtime = lvb->lvb_mtime;
- s64 current_atime = lvb->lvb_atime;
- s64 current_ctime = lvb->lvb_ctime;
+ /* XXX: timestamps can be negative by sanity:test_39m,
+ * how can it be? */
+ s64 current_mtime = LLONG_MIN;
+ s64 current_atime = LLONG_MIN;
+ s64 current_ctime = LLONG_MIN;
int i;
int rc = 0;
assert_spin_locked(&lsm->lsm_lock);
LASSERT(lsm->lsm_lock_owner == current->pid);
int i;
int rc = 0;
assert_spin_locked(&lsm->lsm_lock);
LASSERT(lsm->lsm_lock_owner == current->pid);
-
- CDEBUG(D_INODE, "MDT ID "DOSTID" initial value: s=%llu m=%llu"
- " a=%llu c=%llu b=%llu\n", POSTID(&lsm->lsm_oi),
- lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime,
- lvb->lvb_blocks);
for (i = 0; i < lse->lsme_stripe_count; i++) {
struct lov_oinfo *loi = lse->lsme_oinfo[i];
u64 lov_size;
for (i = 0; i < lse->lsme_stripe_count; i++) {
struct lov_oinfo *loi = lse->lsme_oinfo[i];
u64 lov_size;
- tmpsize = loi->loi_kms;
+ if (loi->loi_kms_valid) {
+ attr->cat_kms_valid = 1;
+ tmpsize = loi->loi_kms;
+ } else {
+ tmpsize = 0;
+ }
lov_size = lov_stripe_size(lsm, index, tmpsize, i);
if (lov_size > kms)
kms = lov_size;
lov_size = lov_stripe_size(lsm, index, tmpsize, i);
if (lov_size > kms)
kms = lov_size;
if (loi->loi_lvb.lvb_ctime > current_ctime)
current_ctime = loi->loi_lvb.lvb_ctime;
if (loi->loi_lvb.lvb_ctime > current_ctime)
current_ctime = loi->loi_lvb.lvb_ctime;
- CDEBUG(D_INODE, "MDT ID "DOSTID" on OST[%u]: s=%llu m=%llu"
+ CDEBUG(D_INODE, "MDT ID "DOSTID" on OST[%u]: s=%llu (%d) m=%llu"
" a=%llu c=%llu b=%llu\n", POSTID(&lsm->lsm_oi),
" a=%llu c=%llu b=%llu\n", POSTID(&lsm->lsm_oi),
- loi->loi_ost_idx, loi->loi_lvb.lvb_size,
+ loi->loi_ost_idx, loi->loi_lvb.lvb_size, loi->loi_kms_valid,
loi->loi_lvb.lvb_mtime, loi->loi_lvb.lvb_atime,
loi->loi_lvb.lvb_ctime, loi->loi_lvb.lvb_blocks);
}
loi->loi_lvb.lvb_mtime, loi->loi_lvb.lvb_atime,
loi->loi_lvb.lvb_ctime, loi->loi_lvb.lvb_blocks);
}
- *kms_place = kms;
- lvb->lvb_size = size;
- lvb->lvb_blocks = blocks;
- lvb->lvb_mtime = current_mtime;
- lvb->lvb_atime = current_atime;
- lvb->lvb_ctime = current_ctime;
+ if (!rc) {
+ attr->cat_kms = kms;
+ attr->cat_size = size;
+ attr->cat_mtime = current_mtime;
+ attr->cat_atime = current_atime;
+ attr->cat_ctime = current_ctime;
+ attr->cat_blocks = blocks;
+ }
{
struct lov_layout_raid0 *r0 = &lle->lle_raid0;
struct lov_stripe_md *lsm = lov->lo_lsm;
{
struct lov_layout_raid0 *r0 = &lle->lle_raid0;
struct lov_stripe_md *lsm = lov->lo_lsm;
- struct ost_lvb *lvb = &lov_env_info(env)->lti_lvb;
struct cl_attr *attr = &r0->lo_attr;
struct cl_attr *attr = &r0->lo_attr;
int result = 0;
if (r0->lo_attr_valid) {
int result = 0;
if (r0->lo_attr_valid) {
- memset(lvb, 0, sizeof(*lvb));
-
- /* XXX: timestamps can be negative by sanity:test_39m,
- * how can it be? */
- lvb->lvb_atime = LLONG_MIN;
- lvb->lvb_ctime = LLONG_MIN;
- lvb->lvb_mtime = LLONG_MIN;
-
- /*
- * XXX that should be replaced with a loop over sub-objects,
- * doing cl_object_attr_get() on them. But for now, let's
- * reuse old lov code.
- */
-
/*
* XXX take lsm spin-lock to keep lov_merge_lvb_kms()
* happy. It's not needed, because new code uses
/*
* XXX take lsm spin-lock to keep lov_merge_lvb_kms()
* happy. It's not needed, because new code uses
* sub-object attributes.
*/
lov_stripe_lock(lsm);
* sub-object attributes.
*/
lov_stripe_lock(lsm);
- result = lov_merge_lvb_kms(lsm, index, lvb, &kms);
+ result = lov_merge_lvb_kms(lsm, index, attr);
lov_stripe_unlock(lsm);
if (result == 0) {
lov_stripe_unlock(lsm);
if (result == 0) {
- cl_lvb2attr(attr, lvb);
- attr->cat_kms = kms;
r0->lo_attr_valid = 1;
*lov_attr = attr;
}
r0->lo_attr_valid = 1;
*lov_attr = attr;
}
lov_attr->cat_ctime, lov_attr->cat_blocks);
/* merge results */
lov_attr->cat_ctime, lov_attr->cat_blocks);
/* merge results */
+ if (lov_attr->cat_kms_valid)
+ attr->cat_kms_valid = 1;
attr->cat_blocks += lov_attr->cat_blocks;
if (attr->cat_size < lov_attr->cat_size)
attr->cat_size = lov_attr->cat_size;
attr->cat_blocks += lov_attr->cat_blocks;
if (attr->cat_size < lov_attr->cat_size)
attr->cat_size = lov_attr->cat_size;
if [[ $discard -gt $discard_limit ]]; then
$LCTL get_param llite.*.read_ahead_stats
if [[ $discard -gt $discard_limit ]]; then
$LCTL get_param llite.*.read_ahead_stats
- error "($discard) discarded pages with size (${read_size})"
+ error "($discard limit ${discard_limit}) discarded pages with size (${read_size})"
else
echo "Read-ahead success for size ${read_size}"
fi
else
echo "Read-ahead success for size ${read_size}"
fi
}
run_test 398n "test append with parallel DIO"
}
run_test 398n "test append with parallel DIO"
+test_398o() {
+ directio rdwr $DIR/$tfile 0 1 1 || error "bad KMS"
+}
+run_test 398o "right kms with DIO"
+
test_fake_rw() {
local read_write=$1
if [ "$read_write" = "write" ]; then
test_fake_rw() {
local read_write=$1
if [ "$read_write" = "write" ]; then
fi
pass "$testnum" "(${duration_sub}s)"
fi
pass "$testnum" "(${duration_sub}s)"
+ if [ -n "${DUMP_OK}" ]; then
+ gather_logs $(comma_list $(nodes_list))
+ fi
+
log_sub_test_end $TEST_STATUS $duration_sub "$rc" "$test_error"
[[ $rc != 0 ]] && break
done
log_sub_test_end $TEST_STATUS $duration_sub "$rc" "$test_error"
[[ $rc != 0 ]] && break
done