if (queued > 0)
result = osc_queue_sync_pages(env, osc, &list, cmd, brw_flags);
+ /* Update c/mtime for sync write. LU-7310 */
+ if (qout->pl_nr > 0 && result == 0) {
+ struct cl_object *obj = ios->cis_obj;
+ struct cl_attr *attr = &osc_env_info(env)->oti_attr;
+
+ cl_object_attr_lock(obj);
+ attr->cat_mtime = attr->cat_ctime = LTIME_S(CURRENT_TIME);
+ cl_object_attr_update(env, obj, attr, CAT_MTIME | CAT_CTIME);
+ cl_object_attr_unlock(obj);
+ }
+
CDEBUG(D_INFO, "%d/%d %d\n", qin->pl_nr, qout->pl_nr, result);
return qout->pl_nr > 0 ? 0 : result;
}
}
run_test 39c "check truncate mtime update ======================"
+test_39d() { # LU-7310
+ touch $DIR1/$tfile
+ touch -m -d @$TEST_39_MTIME $DIR1/$tfile
+
+ local mtime1=$(stat -c %Y $DIR2/$tfile)
+ [ "$mtime1" = $TEST_39_MTIME ] ||
+ error "mtime: $mtime1, should be $TEST_39_MTIME"
+
+ # force sync write
+ # define OBD_FAIL_OSC_NO_GRANT 0x411
+ $LCTL set_param fail_loc=0x411
+
+ local d1=$(date +%s)
+ echo hello >> $DIR1/$tfile
+ local d2=$(date +%s)
+
+ $LCTL set_param fail_loc=0
+
+ cancel_lru_locks osc
+
+ local mtime2=$(stat -c %Y $DIR2/$tfile)
+ [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
+ error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
+}
+run_test 39d "sync write should update mtime"
+
# check that pid exists hence second operation wasn't blocked by first one
# if it is so then there is no conflict, return 0
# else second operation is conflicting with first one, return 1