X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fsmfs%2Fost_kml.c;h=31e2e7979c217f1800c29aab00ea648b83d00ec9;hb=e52a140eb7f65a63f07dbb7e2aaff7f9e22974f2;hp=01d9ccd14c6c43c82c53f05863b56dd7054c72e9;hpb=2dc9c16e770415d56839e1996015fec5fab93f29;p=fs%2Flustre-release.git diff --git a/lustre/smfs/ost_kml.c b/lustre/smfs/ost_kml.c index 01d9ccd1..31e2e79 100644 --- a/lustre/smfs/ost_kml.c +++ b/lustre/smfs/ost_kml.c @@ -42,15 +42,17 @@ static int smfs_ost_get_id(obd_id *id, char *data, int size) { - /*for obdfilter obdid is the name of the filename*/ + /* for obdfilter obdid is the name of the filename */ char end; char *endp = &end; if (data) *id = simple_strtoull(data, &endp, 10); else return -EINVAL; + CDEBUG(D_DENTRY,"name = %s\n", data); return 0; } + /* Group 0 is no longer a legal group, to catch uninitialized IDs */ #define FILTER_MIN_GROUPS 3 static int smfs_ost_get_group(struct dentry *dentry, struct obdo *oa) @@ -65,14 +67,16 @@ static int smfs_ost_get_group(struct dentry *dentry, struct obdo *oa) if (dparent_group == NULL || dparent_group == dparent_subdir) return -EINVAL; + CDEBUG(D_DENTRY,"try to find group for dentry %p\n", dparent_group); for (i = 1; i < filter->fo_group_count; i++) { + CDEBUG(D_DENTRY, "group[%i] = %p\n", i, filter->fo_groups[i]); if (filter->fo_groups[i] == dparent_group) { oa->o_gr = i; oa->o_valid |= OBD_MD_FLGROUP; return 0; } } - return -EINVAL; + return -ENOENT; } static int ost_rec_create_pack(char *buffer, struct dentry *dentry, @@ -80,27 +84,37 @@ static int ost_rec_create_pack(char *buffer, struct dentry *dentry, { struct obdo *oa = NULL; int rc = 0; - + PACK_KML_REC_INIT(buffer, OST_CREATE); oa = (struct obdo*)buffer; - oa->o_uid = 0; /* must have 0 uid / gid on OST */ - oa->o_gid = 0; - oa->o_valid = OBD_MD_FLID | OBD_MD_FLGENER | OBD_MD_FLTYPE | - OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID; - oa->o_size = 0; - obdo_from_inode(oa, dentry->d_inode, OBD_MD_FLTYPE|OBD_MD_FLATIME| - OBD_MD_FLMTIME| OBD_MD_FLCTIME); - rc = smfs_ost_get_id(&oa->o_id, (char*)dentry->d_name.name, - dentry->d_name.len); - if (rc) { - CERROR("Can not find id of node %lu\n", dentry->d_inode->i_ino); - GOTO(out, rc = -ENOMEM); - } - - rc = smfs_ost_get_group(dentry, oa); - if (rc) { - CERROR("Can not find group node %lu\n", dentry->d_inode->i_ino); - GOTO(out, rc = -ENOMEM); + if (data1 && data2) { + struct obdo *create_oa = (struct obdo *)data2; + int num = *((int *)data1); + + memcpy(oa, create_oa, sizeof(*oa)); + memcpy(oa->o_inline, &num, sizeof(int)); + oa->o_valid |= OBD_MD_REINT; + } else { + oa->o_uid = 0; /* must have 0 uid / gid on OST */ + oa->o_gid = 0; + oa->o_valid = OBD_MD_FLID | OBD_MD_FLGENER | OBD_MD_FLTYPE | + OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID; + oa->o_size = 0; + obdo_from_inode(oa, dentry->d_inode, OBD_MD_FLTYPE | OBD_MD_FLATIME | + OBD_MD_FLMTIME | OBD_MD_FLCTIME); + rc = smfs_ost_get_id(&oa->o_id, (char *)dentry->d_name.name, + dentry->d_name.len); + if (rc) { + CERROR("can not find id of inode %lu, name %s\n", + dentry->d_inode->i_ino, (char *)dentry->d_name.name); + GOTO(out, rc); + } + rc = smfs_ost_get_group(dentry, oa); + if (rc) { + CERROR("can not find group inode %lu, name %s\n", + dentry->d_inode->i_ino, (char *)dentry->d_name.name); + GOTO(out, rc); + } } rc = sizeof(*oa) + sizeof(int); out: @@ -133,11 +147,12 @@ static int ost_rec_setattr_pack(char *buffer, struct dentry *dentry, out: RETURN(rc); } + static int ost_rec_write_pack(char *buffer, struct dentry *dentry, struct inode *dir, void *data1, void *data2) { struct obdo *oa = NULL; - int rc = 0; + int rc = 0; PACK_KML_REC_INIT(buffer, OST_WRITE); oa = (struct obdo*)buffer; @@ -157,28 +172,20 @@ static int ost_rec_write_pack(char *buffer, struct dentry *dentry, out: RETURN(rc); } + typedef int (*ost_pack_rec_func)(char *buffer, struct dentry *dentry, struct inode *dir, void *data1, void *data2); + static ost_pack_rec_func ost_kml_pack[REINT_MAX + 1] = { [REINT_SETATTR] ost_rec_setattr_pack, [REINT_CREATE] ost_rec_create_pack, [REINT_WRITE] ost_rec_write_pack, }; -int ost_rec_pack(char *buffer, struct dentry *dentry, struct inode *dir, - void *data1, void *data2, int op) +int ost_rec_pack(int op, char *buffer, struct dentry *dentry, + struct inode *dir, void *data1, void *data2) { - if (op == REINT_SETATTR || op == REINT_CREATE || op == REINT_WRITE) { + if (op == REINT_SETATTR || op == REINT_CREATE || op == REINT_WRITE) return ost_kml_pack[op](buffer, dentry, dir, data1, data2); - } - return 0; -} - -int ost_rec_pack_init(struct super_block *sb) -{ - struct smfs_super_info *smsi = S2SMI(sb); - - smsi->smsi_pack_rec[PACK_OST] = ost_rec_pack; - return 0; }