* pack fid for direct io.
* seperate verify_fid from verify_capa to fully support truncate.
* debug message cleanup.
if (!och->och_capa)
rc = -ENOMEM;
- DEBUG_CAPA(D_INFO, capa, "ll_set_och_capa");
-
expiry = expiry_to_jiffies(capa->lc_expiry - capa_pre_expiry(capa));
spin_lock(&capa_lock);
oa->o_fsuid = current->fsuid;
oa->o_valid |= OBD_MD_FLFSUID;
+ *(obdo_id(oa)) = ll_i2info(inode)->lli_id;
rc = obd_brw(OBD_BRW_CHECK, ll_i2dtexp(inode),
oa, lsm, 1, &pga, NULL);
if (rc)
RETURN(rc);
- DEBUG_CAPA(D_INFO, capa, "capa renewal");
-
spin_lock(&capa_lock);
expiry = expiry_to_jiffies(capa->lc_expiry - capa_pre_expiry(capa));
if (time_before(expiry, ll_capa_timer.expires) ||
struct obd_capa *ocapa;
uid_t ouid;
- CDEBUG(D_CACHE, "find_capa uid %u op %u mdsid "LPU64" ino %lu "
- "type %d\n", uid, capa_op, mdsid, ino, type);
-
hlist_for_each_entry(ocapa, pos, head, c_hash) {
if (ocapa->c_capa.lc_ino != ino)
continue;
if (ouid != uid)
continue;
+ DEBUG_CAPA(D_CACHE, &ocapa->c_capa, "found");
+
return ocapa;
}
unsigned long ino, int type)
{
struct obd_capa *ocapa;
- ENTRY;
spin_lock(&capa_lock);
ocapa = find_capa(head, uid, capa_op, mdsid, ino, type);
__capa_get(ocapa);
spin_unlock(&capa_lock);
- RETURN(ocapa);
+ return ocapa;
}
static struct obd_capa *alloc_capa(void)
__u64 mdsid = capa->lc_mdsid;
unsigned long ino = capa->lc_ino;
struct obd_capa *ocapa, *old;
- ENTRY;
ocapa = alloc_capa();
if (!ocapa)
- RETURN(NULL);
+ return NULL;
spin_lock(&capa_lock);
old = find_capa(head, uid, capa_op, mdsid, ino, type);
memcpy(&ocapa->c_handle, handle, sizeof(*handle));
}
+ DEBUG_CAPA(D_CACHE, &ocapa->c_capa, "new");
+
list_add_capa(ocapa, &capa_list[type]);
hlist_add_head(&ocapa->c_hash, capa_hash);
capa_count[type]++;
}
spin_unlock(&capa_lock);
- RETURN(ocapa);
+ return ocapa;
}
__capa_get(old);
spin_unlock(&capa_lock);
destroy_capa(ocapa);
- RETURN(old);
+ return old;
}
static struct obd_capa *
struct hlist_head *head = capa_hash +
capa_hashfn(uid, capa_op, mdsid, ino);
struct obd_capa *ocapa;
- ENTRY;
ocapa = find_capa_locked(head, uid, capa_op, mdsid, ino, type);
if (ocapa)
- RETURN(ocapa);
+ return ocapa;
if (capa)
ocapa = get_new_capa_locked(head, type, capa, inode, handle);
- RETURN(ocapa);
+ return ocapa;
}
struct obd_capa *
int capa_renew(struct lustre_capa *capa, int type)
{
+ DEBUG_CAPA(D_INFO, capa, "renew");
+
return update_capa_locked(capa, type);
}
if (IS_ERR(dentry))
GOTO(out_pop, rc = PTR_ERR(dentry));
- rc = filter_verify_capa(OBD_BRW_WRITE, exp, dentry->d_inode, capa);
+ rc = filter_verify_fid(exp, dentry->d_inode, capa);
if (rc)
- RETURN(rc);
+ GOTO(out_pop, rc);
+
lock_kernel();
/* setting objects attributes (including owner/group) */
struct lustre_capa *capa)
{
int error;
+ int rc;
ENTRY;
if (end != OBD_OBJECT_EOF)
CERROR("PUNCH not supported, only truncate: end = "LPX64"\n",
end);
+ rc = filter_verify_capa(OBD_BRW_WRITE, exp, capa);
+ if (rc)
+ RETURN(rc);
+
CDEBUG(D_INODE, "calling truncate for object "LPU64", valid = "LPU64", "
"o_size = "LPD64"\n", oa->o_id, oa->o_valid, start);
if (bkey) {
tmp = bkey;
+
+ DEBUG_CAPA_KEY(D_INFO, &tmp->k_key, "filter update");
} else {
OBD_ALLOC(tmp, sizeof(*tmp));
if (!tmp)
GOTO(out, rc = -ENOMEM);
+
+ DEBUG_CAPA_KEY(D_INFO, &tmp->k_key, "filter new");
}
/* fields in lustre_capa_key are in cpu order */
if (!bkey)
list_add_tail(&tmp->k_list, &filter->fo_capa_keys);
spin_unlock(&filter->fo_capa_lock);
-
- DEBUG_CAPA_KEY(D_INFO, &tmp->k_key, "filter_update_capa_key");
out:
RETURN(rc);
}
-int filter_verify_capa(int cmd, struct obd_export *exp, struct inode *inode,
- struct lustre_capa *capa)
+int filter_verify_fid(struct obd_export *exp, struct inode *inode,
+ struct lustre_capa *capa)
+{
+ struct lustre_id fid;
+ int rc;
+
+ if (!capa)
+ return 0;
+
+ ENTRY;
+ rc = fsfilt_get_md(exp->exp_obd, inode, &fid, sizeof(fid), EA_SID);
+ if (rc < 0) {
+ CERROR("get fid from object failed! rc:%d\n", rc);
+ RETURN(rc);
+ } else if (rc > 0) {
+ if (capa->lc_mdsid != id_group(&fid) ||
+ capa->lc_ino != id_ino(&fid))
+ RETURN(-EINVAL);
+ }
+
+ RETURN(0);
+}
+
+int
+filter_verify_capa(int cmd, struct obd_export *exp, struct lustre_capa *capa)
{
struct obd_device *obd = exp->exp_obd;
struct filter_obd *filter = &obd->u.filter;
struct obd_capa *ocapa;
struct lustre_capa tcapa;
- struct lustre_id fid;
struct filter_capa_key *rkey = NULL, *bkey = NULL, *tmp;
__u8 hmac_key[CAPA_KEY_LEN];
int rc = 0;
- ENTRY;
/* capability is disabled */
if (filter->fo_capa_stat == 0)
RETURN(0);
+ ENTRY;
if (capa == NULL)
RETURN(-EACCES);
if (OBD_FAIL_CHECK(OBD_FAIL_FILTER_VERIFY_CAPA))
RETURN(-EACCES);
- rc = fsfilt_get_md(obd, inode, &fid, sizeof(fid), EA_SID);
- if (rc < 0) {
- CERROR("get fid from object failed! rc:%d\n", rc);
- RETURN(rc);
- } else if (rc > 0) {
- if (capa->lc_mdsid != id_group(&fid) ||
- capa->lc_ino != id_ino(&fid))
- RETURN(-EINVAL);
- }
-
if (capa_expired(capa))
RETURN(-ESTALE);
int filter_init_capa_keys(struct obd_device *obd);
void filter_free_capa_keys(struct filter_obd *filter);
int filter_update_capa_key(struct obd_device *obd, struct lustre_capa_key *key);
-int filter_verify_capa(int cmd, struct obd_export *exp, struct inode *inode,
- struct lustre_capa *capa);
+int filter_verify_capa(int cmd, struct obd_export *exp, struct lustre_capa *capa);
+int filter_verify_fid(struct obd_export *exp, struct inode *inode,
+ struct lustre_capa *capa);
#endif
inode = dentry->d_inode;
- rc = filter_verify_capa(cmd, exp, inode, capa);
- if (rc)
- return rc;
+ if (inode) {
+ rc = filter_verify_fid(exp, inode, capa);
+ if (rc)
+ GOTO(cleanup, rc);
+ }
fsfilt_check_slow(now, obd_timeout, "preprw_read setup");
if (IS_ERR(dentry))
GOTO(cleanup, rc = PTR_ERR(dentry));
- rc = filter_verify_capa(cmd, exp, dentry->d_inode, capa);
+ rc = filter_verify_fid(exp, dentry->d_inode, capa);
if (rc)
- return rc;
+ GOTO(cleanup, rc);
cleanup_phase = 2;
struct niobuf_remote *nb, struct niobuf_local *res,
struct obd_trans_info *oti, struct lustre_capa *capa)
{
+ int rc;
+
+ rc = filter_verify_capa(cmd, exp, capa);
+ if (rc)
+ return rc;
+
if (cmd == OBD_BRW_WRITE)
return filter_preprw_write(cmd, exp, oa, objcount, obj,
niocount, nb, res, oti, capa);
void lustre_assert_wire_constants(void)
{
/* Wire protocol assertions generated by 'wirecheck'
- * running on Linux localhost.localdomain 2.6.9-1.667 #1 Tue Nov 2 14:41:25 EST 2004 i686 i68
+ * running on Linux localhost.localdomain 2.6.12-1.1372_FC3 #1 Fri Jul 15 00:59:10 EDT 2005 i
* with gcc version 3.4.3 20050227 (Red Hat 3.4.3-22.fc3) */