From 8d1e7317b3ce28a6909e139bee5ad84b787d7c7f Mon Sep 17 00:00:00 2001 From: Andriy Skulysh Date: Fri, 26 Feb 2016 17:54:04 +0200 Subject: [PATCH] LU-7830 ost: do not evict during truncate OST punch request can last for a long time, so it is needed to prolong taken lock until it completes. Seagate-bug-id: MRP-3332 Change-Id: Icad7d122bc559f9e0bd693c7f88cbac14235bd38 Signed-off-by: Andriy Skulysh Reviewed-on: http://review.whamcloud.com/18739 Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Reviewed-by: Chris Horn Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/obd_support.h | 1 + lustre/ofd/ofd_dev.c | 21 +++++++++++++++++++-- lustre/tests/recovery-small.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 5103f66..714410d 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -324,6 +324,7 @@ extern char obd_jobid_var[]; #define OBD_FAIL_OST_NODESTROY 0x233 #define OBD_FAIL_OST_READ_SIZE 0x234 #define OBD_FAIL_OST_LADVISE_NET 0x235 +#define OBD_FAIL_OST_PAUSE_PUNCH 0x236 #define OBD_FAIL_LDLM 0x300 #define OBD_FAIL_LDLM_NAMESPACE_NEW 0x301 diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 28bbf03..0a2ec19 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -2021,6 +2021,8 @@ static int ofd_punch_hdl(struct tgt_session_info *tsi) ENTRY; + OBD_FAIL_TIMEOUT(OBD_FAIL_OST_PAUSE_PUNCH, cfs_fail_val); + /* check that we do support OBD_CONNECT_TRUNCLOCK. */ CLASSERT(OST_CONNECT_SUPPORTED & OBD_CONNECT_TRUNCLOCK); @@ -2546,6 +2548,10 @@ static int ofd_punch_hpreq_lock_match(struct ptlrpc_request *req, struct ldlm_lock *lock) { struct tgt_session_info *tsi; + struct obdo *oa; + struct ldlm_extent ext; + + ENTRY; /* Don't use tgt_ses_info() to get session info, because lock_match() * can be called while request has no processing thread yet. */ @@ -2558,9 +2564,20 @@ static int ofd_punch_hpreq_lock_match(struct ptlrpc_request *req, LASSERT(tsi->tsi_ost_body != NULL); if (tsi->tsi_ost_body->oa.o_valid & OBD_MD_FLHANDLE && tsi->tsi_ost_body->oa.o_handle.cookie == lock->l_handle.h_cookie) - return 1; + RETURN(1); - return 0; + oa = &tsi->tsi_ost_body->oa; + ext.start = oa->o_size; + ext.end = oa->o_blocks; + + LASSERT(lock->l_resource != NULL); + if (!ostid_res_name_eq(&oa->o_oi, &lock->l_resource->lr_name)) + RETURN(0); + + if (!(lock->l_granted_mode & (LCK_PW | LCK_GROUP))) + RETURN(0); + + RETURN(ldlm_extent_overlap(&lock->l_policy_data.l_extent, &ext)); } /** diff --git a/lustre/tests/recovery-small.sh b/lustre/tests/recovery-small.sh index a36eeb1..e833e58 100755 --- a/lustre/tests/recovery-small.sh +++ b/lustre/tests/recovery-small.sh @@ -2344,6 +2344,41 @@ test_130c() { } run_test 130c "layout intent resend on a stale inode" +test_132() { + local before=$(date +%s) + local evict + + mount_client $MOUNT2 || error "mount filed" + + rm -f $DIR/$tfile + # get a lock on client so that export would reach the stale list + $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed" + dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync || + error "dd failed" + + #define OBD_FAIL_OST_PAUSE_PUNCH 0x236 + do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236 + + $TRUNCATE $DIR/$tfile 100 & + + sleep 1 + dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc || + error "dd failed" + + wait + umount_client $MOUNT2 + + evict=$(do_facet client $LCTL get_param \ + osc.$FSNAME-OST0000-osc-*/state | + awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }') + + [ -z "$evict" ] || [[ $evict -le $before ]] || + (do_facet client $LCTL get_param \ + osc.$FSNAME-OST0000-osc-*/state; + error "eviction happened: $evict before:$before") +} +run_test 132 "long punch" + complete $SECONDS check_and_cleanup_lustre exit_status -- 1.8.3.1