GOTO(out, rc = -EPROTO);
}
- /* XXX: only exclusive open is supported. */
- lm = LCK_EX;
+ /* should conflict with new opens for write/execute */
+ lm = LCK_PW;
*ibits = MDS_INODELOCK_OPEN;
/* never grant LCK_EX layout lock to client */
PFID(mdt_object_fid(obj)),
atomic_read(&obj->mot_open_count), open_count);
- if (atomic_read(&obj->mot_open_count) > open_count)
- GOTO(out, rc = -EBUSY);
+ if (atomic_read(&obj->mot_open_count) > open_count) {
+ /* fail if anyone *else* has opened file for write */
+ if (mdt_write_read(obj) > 1)
+ GOTO(out, rc = -EBUSY);
+ }
}
GOTO(out, rc);
sleep 3
wait_request_state $(path2fid $file) RESTORE SUCCEED
$LFS hsm_remove $file || error "hsm remove $file failed"
- wait $pid && error "RW-PCC attach $file should fail"
+ wait $pid
do_facet $SINGLEAGT "[ -f $lpcc_path ]" &&
error "RW-PCC cached file '$lpcc_path' should be removed"
$MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
echo "==== test 2: verify lease can be broken by upcoming open"
- $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
+ $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
local PID=$!
sleep 1
- $MULTIOP $DIR/$tfile oO_RDONLY:c
+ $MULTIOP $DIR/$tfile oO_RDWR:c
kill -USR1 $PID && wait $PID || error "break lease error"
echo "==== test 3: verify lease can't be granted if an open already exists"
- $MULTIOP $DIR/$tfile oO_RDONLY:_c &
+ $MULTIOP $DIR/$tfile oO_RDWR:_c &
local PID=$!
sleep 1
- $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
+ $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
kill -USR1 $PID && wait $PID || error "open file error"
echo "==== test 4: lease can sustain over recovery"
- $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
+ $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
PID=$!
sleep 1
kill -USR1 $PID && wait $PID || error "lease broken over recovery"
echo "==== test 5: lease broken can't be regained by replay"
- $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
+ $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
PID=$!
sleep 1