Skip to content
Snippets Groups Projects
Commit 0e10e415 authored by tianzy's avatar tianzy
Browse files

Branch b1_6

Have O_DIRECT honor the quota
b=16125
i=johann
i=tom.wang
parent 707fdafb
No related branches found
No related tags found
No related merge requests found
...@@ -341,6 +341,13 @@ Description: add quota statistics ...@@ -341,6 +341,13 @@ Description: add quota statistics
Details : 1. sort out quota proc entries and proc code. Details : 1. sort out quota proc entries and proc code.
2. add quota statistics 2. add quota statistics
Severity : normal
Frequncy : often
Bugzilla : 16125
Description: quotas are not honored with O_DIRECT
Details : all writes with the flag O_DIRECT will use grants which leads to
this problem. Now using OBD_BRW_SYNC to guard this.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
......
...@@ -177,7 +177,7 @@ static ssize_t ll_direct_IO_26_seg(int rw, struct inode *inode, ...@@ -177,7 +177,7 @@ static ssize_t ll_direct_IO_26_seg(int rw, struct inode *inode,
/* To the end of the page, or the length, whatever is less */ /* To the end of the page, or the length, whatever is less */
pga[i].count = min_t(int, CFS_PAGE_SIZE -(file_offset & ~CFS_PAGE_MASK), pga[i].count = min_t(int, CFS_PAGE_SIZE -(file_offset & ~CFS_PAGE_MASK),
length); length);
pga[i].flag = 0; pga[i].flag = OBD_BRW_SYNC;
if (rw == READ) if (rw == READ)
POISON_PAGE(pages[i], 0x0d); POISON_PAGE(pages[i], 0x0d);
} }
......
...@@ -697,10 +697,11 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, ...@@ -697,10 +697,11 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
if (this_size > iattr.ia_size) if (this_size > iattr.ia_size)
iattr.ia_size = this_size; iattr.ia_size = this_size;
/* if one page is a write-back page from client cache, or it's /* if one page is a write-back page from client cache and
* written by root, then mark the whole io request as ignore * not from direct_io, or it's written by root, then mark
* quota request */ * the whole io request as ignore quota request */
if (lnb->flags & (OBD_BRW_FROM_GRANT | OBD_BRW_NOQUOTA)) if (lnb->flags & OBD_BRW_NOQUOTA ||
(lnb->flags & (OBD_BRW_FROM_GRANT | OBD_BRW_SYNC)) == OBD_BRW_FROM_GRANT)
iobuf->dr_ignore_quota = 1; iobuf->dr_ignore_quota = 1;
} }
......
...@@ -46,6 +46,7 @@ LUSTRE=${LUSTRE:-`dirname $0`/..} ...@@ -46,6 +46,7 @@ LUSTRE=${LUSTRE:-`dirname $0`/..}
. $LUSTRE/tests/test-framework.sh . $LUSTRE/tests/test-framework.sh
init_test_env $@ init_test_env $@
. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh} . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
DIRECTIO=${DIRECTIO:-$LUSTRE/tests/directio}
[ "$SLOW" = "no" ] && EXCEPT_SLOW="9 10 11 21" [ "$SLOW" = "no" ] && EXCEPT_SLOW="9 10 11 21"
...@@ -1660,6 +1661,58 @@ test_22() { ...@@ -1660,6 +1661,58 @@ test_22() {
} }
run_test_with_stat 22 "test if quota_type saved as permanent parameter ====" run_test_with_stat 22 "test if quota_type saved as permanent parameter ===="
test_23_sub() {
mkdir -p $DIR/$tdir
chmod 0777 $DIR/$tdir
TESTFILE="$DIR/$tdir/$tfile-0"
local bs_unit=$((1024*1024))
LIMIT=$1
wait_delete_completed
# test for user
log " User quota (limit: $LIMIT kbytes)"
$LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
sleep 3
$SHOW_QUOTA_USER
$LFS setstripe $TESTFILE -c 1
chown $TSTUSR.$TSTUSR $TESTFILE
log " Step1: trigger quota with 0_DIRECT"
log " Write half of file"
$RUNAS $DIRECTIO write $TESTFILE 0 $(($LIMIT/1024/2)) $bs_unit || error "(usr) write failure, but expect success"
log " Write out of block quota ..."
$RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) $(($LIMIT/1024/2)) $bs_unit && error "(usr) write success, but expect EDQUOT"
log " Step1: done"
log " Step2: rewrite should succeed"
$RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) 1 $bs_unit 2>&1 || error "(usr) write failure, but expect success"
log " Step2: done"
rm -f $TESTFILE
wait_delete_completed
OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
echo $OST0_QUOTA_USED
[ $OST0_QUOTA_USED -ne 0 ] && \
($SHOW_QUOTA_USER; error "quota deleted isn't released")
$SHOW_QUOTA_USER
$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
}
test_23() {
log "run for 10MB test file"
test_23_sub 10240 #10MB
OST0_MIN=120000
check_whether_skip && return 0
log "run for 100MB test file"
test_23_sub 102400 #100MB
}
run_test_with_stat 23 "run for fixing bug16125 ==========="
# turn off quota # turn off quota
test_99() test_99()
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment