Whamcloud - gitweb
LU-7830 ost: do not evict during truncate 39/18739/5
authorAndriy Skulysh <andriy.skulysh@seagate.com>
Fri, 26 Feb 2016 15:54:04 +0000 (17:54 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 14 Jun 2016 03:51:06 +0000 (03:51 +0000)
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 <andriy.skulysh@seagate.com>
Reviewed-on: http://review.whamcloud.com/18739
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Chris Horn <hornc@cray.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/obd_support.h
lustre/ofd/ofd_dev.c
lustre/tests/recovery-small.sh

index 5103f66..714410d 100644 (file)
@@ -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_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
 
 #define OBD_FAIL_LDLM                    0x300
 #define OBD_FAIL_LDLM_NAMESPACE_NEW      0x301
index 28bbf03..0a2ec19 100644 (file)
@@ -2021,6 +2021,8 @@ static int ofd_punch_hdl(struct tgt_session_info *tsi)
 
        ENTRY;
 
 
        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);
 
        /* 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 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. */
 
        /* 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)
        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));
 }
 
 /**
 }
 
 /**
index a36eeb1..e833e58 100755 (executable)
@@ -2344,6 +2344,41 @@ test_130c() {
 }
 run_test 130c "layout intent resend on a stale inode"
 
 }
 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
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status