if (lnb->lnb_len < PAGE_SIZE)
memset(kaddr + lnb->lnb_len, 0,
PAGE_SIZE - lnb->lnb_len);
- flush_dcache_page(page);
- SetPageUptodate(page);
kunmap_atomic(kaddr);
if (inode && IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode)) {
- if (!llcrypt_has_encryption_key(inode))
+ if (!llcrypt_has_encryption_key(inode)) {
CDEBUG(D_SEC, "no enc key for "DFID"\n",
PFID(ll_inode2fid(inode)));
- else {
+ rc = -ENOKEY;
+ } else {
unsigned int offs = 0;
while (offs < PAGE_SIZE) {
}
}
}
+ if (!rc) {
+ flush_dcache_page(page);
+ SetPageUptodate(page);
+ }
unlock_page(page);
return rc;
rc = llcrypt_prepare_readdir(inode);
if (rc)
GOTO(out, rc);
- if (!llcrypt_has_encryption_key(inode))
- GOTO(out, rc = -ENOKEY);
}
} else if (!it_disposition(it, DISP_OPEN_CREATE)) {
/*
rc = llcrypt_prepare_readdir(dir);
if (rc)
GOTO(out_release, rc);
+ encrypt = true;
if (open_flags & O_CREAT) {
/* For migration or mirroring without enc key, we still
* need to be able to create a volatile file.
(open_flags & O_FILE_ENC) != O_FILE_ENC ||
!(open_flags & O_DIRECT)))
GOTO(out_release, rc = -ENOKEY);
- encrypt = true;
}
}
cmp -bl $tmpfile $testfile ||
error "file $testfile is corrupted in memory"
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
# check that file read from server is correct
cmp -bl $tmpfile $testfile ||
# decrease size: truncate to PAGE_SIZE
$TRUNCATE $tmpfile $pagesz
$TRUNCATE $testfile $pagesz
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
cmp -bl $tmpfile $testfile ||
error "file $testfile is corrupted (1)"
sz=$((pagesz*2))
$TRUNCATE $tmpfile $sz
$TRUNCATE $testfile $sz
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
cmp -bl $tmpfile $testfile ||
error "file $testfile is corrupted (2)"
sz=$((pagesz/2))
$TRUNCATE $tmpfile $sz
$TRUNCATE $testfile $sz
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
cmp -bl $tmpfile $testfile ||
error "file $testfile is corrupted (3)"
sz=$((sz-7))
$TRUNCATE $tmpfile $sz
$TRUNCATE $testfile $sz
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
cmp -bl $tmpfile $testfile ||
error "file $testfile is corrupted (4)"
sz=$((sz+18))
$TRUNCATE $tmpfile $sz
$TRUNCATE $testfile $sz
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
cmp -bl $tmpfile $testfile ||
error "file $testfile is corrupted (5)"
sz=$((sz+pagesz+30))
$TRUNCATE $tmpfile $sz
$TRUNCATE $testfile $sz
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
cmp -bl $tmpfile $testfile ||
error "file $testfile is corrupted (6)"
rm -f $testfile
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
# write hole in file, data spread on MDT and OST
tr '\0' '2' < /dev/zero |
cmp -bl $tmpfile $testfile ||
error "file $testfile is corrupted in memory"
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
# check that file read from server is correct
cmp -bl $tmpfile $testfile ||
sz=$((1024*1024+13))
$TRUNCATE $tmpfile $sz
$TRUNCATE $testfile $sz
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
cmp -bl $tmpfile $testfile ||
error "file $testfile is corrupted (7)"
sz=7
$TRUNCATE $tmpfile $sz
$TRUNCATE $testfile $sz
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
cmp -bl $tmpfile $testfile ||
error "file $testfile is corrupted (8)"
sz=$((1024*1024-13))
$TRUNCATE $tmpfile $sz
$TRUNCATE $testfile $sz
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
cmp -bl $tmpfile $testfile ||
error "file $testfile is corrupted (9)"
sz=$((1024*1024+7))
$TRUNCATE $tmpfile $sz
$TRUNCATE $testfile $sz
- cancel_lru_locks osc ; cancel_lru_locks mdc
+ remove_enc_key ; insert_enc_key
cmp -bl $tmpfile $testfile ||
error "file $testfile is corrupted (10)"