From b0aec350d4a14906acf8a36f2dad631860eecb9b Mon Sep 17 00:00:00 2001 From: lsy Date: Thu, 28 Sep 2006 15:32:53 +0000 Subject: [PATCH] add ll_finish_md_op_data, rename ll_prepare_md_op_data to ll_prep_md_op_data. add md_get_info() for obd_connect_data. other capability related small fixes. --- lustre/include/lustre/lustre_idl.h | 7 ++- lustre/include/lustre_capa.h | 13 +---- lustre/include/obd.h | 2 + lustre/liblustre/dir.c | 2 +- lustre/liblustre/file.c | 16 +++--- lustre/liblustre/llite_lib.h | 10 ++-- lustre/liblustre/namei.c | 10 ++-- lustre/liblustre/super.c | 26 +++++---- lustre/llite/dcache.c | 33 ++++++------ lustre/llite/dir.c | 15 ++---- lustre/llite/file.c | 37 +++++-------- lustre/llite/llite_capa.c | 34 ++++++------ lustre/llite/llite_close.c | 4 +- lustre/llite/llite_internal.h | 7 +-- lustre/llite/llite_lib.c | 73 +++++++++++++++---------- lustre/llite/namei.c | 63 +++++++++------------- lustre/lmv/lmv_obd.c | 3 +- lustre/mdc/mdc_locks.c | 6 ++- lustre/mdc/mdc_request.c | 106 +++++++++++++++++++++---------------- lustre/mdd/mdd_handler.c | 2 +- lustre/mdt/mdt_handler.c | 24 ++++----- lustre/ost/ost_handler.c | 2 +- lustre/utils/mkfs_lustre.c | 2 +- 23 files changed, 241 insertions(+), 256 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 156d076..63b8d6b 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -451,11 +451,14 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb); OBD_CONNECT_ACL | OBD_CONNECT_XATTR | \ OBD_CONNECT_IBITS | OBD_CONNECT_JOIN | \ OBD_CONNECT_NODEVOH | OBD_CONNECT_ATTRFID | \ - OBD_CONNECT_LCL_CLIENT | OBD_CONNECT_RMT_CLIENT) + OBD_CONNECT_LCL_CLIENT | \ + OBD_CONNECT_RMT_CLIENT | \ + OBD_CONNECT_MDS_CAPA | OBD_CONNECT_OSS_CAPA) #define OST_CONNECT_SUPPORTED (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \ OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \ OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_INDEX | \ - OBD_CONNECT_BRW_SIZE | OBD_CONNECT_QUOTA64) + OBD_CONNECT_BRW_SIZE | OBD_CONNECT_QUOTA64 | \ + OBD_CONNECT_OSS_CAPA) #define ECHO_CONNECT_SUPPORTED (0) #define MGS_CONNECT_SUPPORTED (OBD_CONNECT_VERSION) diff --git a/lustre/include/lustre_capa.h b/lustre/include/lustre_capa.h index 555ee5f..dc36383 100644 --- a/lustre/include/lustre_capa.h +++ b/lustre/include/lustre_capa.h @@ -88,7 +88,6 @@ enum { OBD_CAPA_FL_NEW = 1, OBD_CAPA_FL_EXPIRED = 1<<1, OBD_CAPA_FL_ROOT = 1<<2, - OBD_CAPA_FL_SPLIT = 1<<3 }; static inline __u64 capa_opc(struct lustre_capa *capa) @@ -174,7 +173,7 @@ static inline int obd_capa_is_expired(struct obd_capa *oc) static inline int obd_capa_is_valid(struct obd_capa *oc) { - return !!((oc)->c_flags & (OBD_CAPA_FL_NEW | OBD_CAPA_FL_EXPIRED)); + return !((oc)->c_flags & (OBD_CAPA_FL_NEW | OBD_CAPA_FL_EXPIRED)); } static inline void obd_capa_set_new(struct obd_capa *oc) @@ -212,16 +211,6 @@ static inline void obd_capa_set_root(struct obd_capa *oc) oc->c_flags |= OBD_CAPA_FL_ROOT; } -static inline int obd_capa_is_split(struct obd_capa *oc) -{ - return !!((oc)->c_flags & OBD_CAPA_FL_SPLIT); -} - -static inline void obd_capa_set_split(struct obd_capa *oc) -{ - oc->c_flags |= OBD_CAPA_FL_SPLIT; -} - static inline struct obd_capa *alloc_capa(int site) { #ifdef __KERNEL__ diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 12ddad3..fbfd6ba 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -967,6 +967,8 @@ enum obd_cleanup_stage { #define KEY_INIT_RECOV_BACKUP "init_recov_bk" #define KEY_FLUSH_CTX "flush_ctx" #define KEY_CAPA_KEY "capa_key" +#define KEY_CONN_DATA "conn_data" +#define KEY_MAX_EASIZE "max_easize" struct lu_context; diff --git a/lustre/liblustre/dir.c b/lustre/liblustre/dir.c index 6e206c3..a747f46 100644 --- a/lustre/liblustre/dir.c +++ b/lustre/liblustre/dir.c @@ -85,7 +85,7 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page) rc = ldlm_lock_match(obddev->obd_namespace, LDLM_FL_BLOCK_GRANTED, &res_id, LDLM_IBITS, &policy, LCK_CR, &lockh); if (!rc) { - llu_prepare_md_op_data(&op_data, inode, NULL, NULL, 0, 0); + llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, 0); rc = md_enqueue(sbi->ll_md_exp, LDLM_IBITS, &it, LCK_CR, &op_data, &lockh, NULL, 0, diff --git a/lustre/liblustre/file.c b/lustre/liblustre/file.c index 8a74c18..a8e2935 100644 --- a/lustre/liblustre/file.c +++ b/lustre/liblustre/file.c @@ -71,15 +71,12 @@ void ll_i2gids(__u32 *suppgids, struct inode *i1, struct inode *i2) } } -void llu_prepare_md_op_data(struct md_op_data *op_data, - struct inode *i1, - struct inode *i2, - const char *name, - int namelen, - int mode) +void llu_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, + struct inode *i2, const char *name, int namelen, + int mode) { - LASSERT(op_data); LASSERT(i1 != NULL || i2 != NULL); + LASSERT(op_data); memset(op_data, 0, sizeof(*op_data)); if (i1) { @@ -99,6 +96,11 @@ void llu_prepare_md_op_data(struct md_op_data *op_data, op_data->mod_time = CURRENT_TIME; } +void llu_finish_md_op_data(struct md_op_data *op_data) +{ + OBD_FREE_PTR(op_data); +} + void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid) diff --git a/lustre/liblustre/llite_lib.h b/lustre/liblustre/llite_lib.h index ddd07d0..c01f962 100644 --- a/lustre/liblustre/llite_lib.h +++ b/lustre/liblustre/llite_lib.h @@ -198,12 +198,10 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr); extern struct fssw_ops llu_fssw_ops; /* file.c */ -void llu_prepare_md_op_data(struct md_op_data *op_data, - struct inode *i1, - struct inode *i2, - const char *name, - int namelen, - int mode); +void llu_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, + struct inode *i2, const char *name, int namelen, + int mode); +void llu_finish_md_op_data(struct md_op_data *op_data); int llu_create(struct inode *dir, struct pnode_base *pnode, int mode); int llu_local_open(struct llu_inode_info *lli, struct lookup_intent *it); int llu_iop_open(struct pnode *pnode, int flags, mode_t mode); diff --git a/lustre/liblustre/namei.c b/lustre/liblustre/namei.c index 258d1a9..7cdaf1f 100644 --- a/lustre/liblustre/namei.c +++ b/lustre/liblustre/namei.c @@ -275,8 +275,8 @@ static int llu_pb_revalidate(struct pnode *pnode, int flags, it->it_op_release = ll_intent_release; } - llu_prepare_md_op_data(&op_data, pnode->p_parent->p_base->pb_ino, - pb->pb_ino, pb->pb_name.name, pb->pb_name.len,0); + llu_prep_md_op_data(&op_data, pnode->p_parent->p_base->pb_ino, + pb->pb_ino, pb->pb_name.name, pb->pb_name.len,0); rc = md_intent_lock(exp, &op_data, NULL, 0, it, flags, &req, llu_md_blocking_ast, @@ -444,9 +444,9 @@ static int llu_lookup_it(struct inode *parent, struct pnode *pnode, icbd.icbd_child = pnode; icbd.icbd_parent = parent; - llu_prepare_md_op_data(&op_data, parent, NULL, - pnode->p_base->pb_name.name, - pnode->p_base->pb_name.len, flags); + llu_prep_md_op_data(&op_data, parent, NULL, + pnode->p_base->pb_name.name, + pnode->p_base->pb_name.len, flags); /* allocate new fid for child */ if (it->it_op & IT_CREAT || diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 1950081..0abd987 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -624,9 +624,8 @@ int llu_md_setattr(struct inode *inode, struct md_op_data *op_data) int rc; ENTRY; - llu_prepare_md_op_data(op_data, inode, NULL, NULL, 0, 0); + llu_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0); rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, NULL, 0, &request); - OBD_FREE_PTR(op_data); if (rc) { ptlrpc_req_finished(request); @@ -946,7 +945,7 @@ static int llu_iop_symlink_raw(struct pnode *pno, const char *tgt) if (llu_i2stat(dir)->st_nlink >= EXT2_LINK_MAX) RETURN(err); - llu_prepare_md_op_data(&op_data, dir, NULL, name, len, 0); + llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0); /* allocate new fid */ err = llu_fid_md_alloc(sbi, &op_data.fid2, &hint); @@ -1083,10 +1082,9 @@ static int llu_iop_mknod_raw(struct pnode *pno, case S_IFBLK: case S_IFIFO: case S_IFSOCK: - llu_prepare_md_op_data(&op_data, dir, NULL, - pno->p_base->pb_name.name, - pno->p_base->pb_name.len, - 0); + llu_prep_md_op_data(&op_data, dir, NULL, + pno->p_base->pb_name.name, + pno->p_base->pb_name.len, 0); /* allocate new fid */ err = llu_fid_md_alloc(sbi, &op_data.fid2, &hint); if (err) { @@ -1124,7 +1122,7 @@ static int llu_iop_link_raw(struct pnode *old, struct pnode *new) LASSERT(dir); liblustre_wait_event(0); - llu_prepare_md_op_data(&op_data, src, dir, name, namelen, 0); + llu_prep_md_op_data(&op_data, src, dir, name, namelen, 0); rc = md_link(llu_i2sbi(src)->ll_md_exp, &op_data, &request); ptlrpc_req_finished(request); liblustre_wait_event(0); @@ -1150,7 +1148,7 @@ static int llu_iop_unlink_raw(struct pnode *pno) LASSERT(target); liblustre_wait_event(0); - llu_prepare_md_op_data(&op_data, dir, NULL, name, len, 0); + llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0); rc = md_unlink(llu_i2sbi(dir)->ll_md_exp, &op_data, &request); if (!rc) rc = llu_objects_destroy(request, dir); @@ -1177,7 +1175,7 @@ static int llu_iop_rename_raw(struct pnode *old, struct pnode *new) LASSERT(tgt); liblustre_wait_event(0); - llu_prepare_md_op_data(&op_data, src, tgt, NULL, 0, 0); + llu_prep_md_op_data(&op_data, src, tgt, NULL, 0, 0); rc = md_rename(llu_i2sbi(src)->ll_md_exp, &op_data, oldname, oldnamelen, newname, newnamelen, &request); @@ -1329,7 +1327,7 @@ static int llu_iop_mkdir_raw(struct pnode *pno, mode_t mode) if (st->st_nlink >= EXT2_LINK_MAX) RETURN(err); - llu_prepare_md_op_data(&op_data, dir, NULL, name, len, 0); + llu_prep_md_op_data(&op_data, dir, NULL, name, len, 0); /* allocate new fid */ err = llu_fid_md_alloc(llu_i2sbi(dir), &op_data.fid2, &hint); @@ -1361,7 +1359,7 @@ static int llu_iop_rmdir_raw(struct pnode *pno) (long long)llu_i2stat(dir)->st_ino, llu_i2info(dir)->lli_st_generation, dir); - llu_prepare_md_op_data(&op_data, dir, NULL, name, len, S_IFDIR); + llu_prep_md_op_data(&op_data, dir, NULL, name, len, S_IFDIR); rc = md_unlink(llu_i2sbi(dir)->ll_md_exp, &op_data, &request); ptlrpc_req_finished(request); @@ -1701,7 +1699,7 @@ static int llu_lov_dir_setstripe(struct inode *ino, unsigned long arg) struct lov_user_md lum, *lump = (struct lov_user_md *)arg; int rc = 0; - llu_prepare_md_op_data(&op_data, ino, NULL, NULL, 0, 0); + llu_prep_md_op_data(&op_data, ino, NULL, NULL, 0, 0); LASSERT(sizeof(lum) == sizeof(*lump)); LASSERT(sizeof(lum.lmm_objects[0]) == @@ -1764,7 +1762,7 @@ static int llu_lov_setstripe_ea_info(struct inode *ino, int flags, lli2->lli_symlink_name = NULL; ino->i_private = lli2; - llu_prepare_md_op_data(&data, NULL, ino, NULL, 0, O_RDWR); + llu_prep_md_op_data(&data, NULL, ino, NULL, 0, O_RDWR); rc = md_enqueue(sbi->ll_md_exp, LDLM_IBITS, &oit, LCK_CR, &data, &lockh, lum, lum_size, ldlm_completion_ast, diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index bbdefd6..67fe181 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -388,10 +388,6 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, parent = de->d_parent->d_inode; - OBD_ALLOC_PTR(op_data); - if (op_data == NULL) - RETURN(-ENOMEM); - if (it->it_op & IT_CREAT) { /* * Allocate new fid for case of create or open(O_CREAT). In both @@ -406,8 +402,10 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, .ph_cname = &de->d_name, .ph_opc = LUSTRE_OPC_CREATE }; - ll_prepare_md_op_data(op_data, parent, NULL, - de->d_name.name, de->d_name.len, 0); + op_data = ll_prep_md_op_data(NULL, parent, NULL, + de->d_name.name, de->d_name.len, 0); + if (op_data == NULL) + RETURN(-ENOMEM); rc = ll_fid_md_alloc(ll_i2sbi(parent), &op_data->fid2, &hint); if (rc) { @@ -415,8 +413,10 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, LBUG(); } } else { - ll_prepare_md_op_data(op_data, parent, de->d_inode, - de->d_name.name, de->d_name.len, 0); + op_data = ll_prep_md_op_data(NULL, parent, de->d_inode, + de->d_name.name, de->d_name.len, 0); + if (op_data == NULL) + RETURN(-ENOMEM); } if ((it->it_op == IT_OPEN) && de->d_inode) { @@ -462,7 +462,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, if it would be, we'll reopen the open request to MDS later during file open path */ up(&lli->lli_och_sem); - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); RETURN(1); } else { up(&lli->lli_och_sem); @@ -475,7 +475,7 @@ do_lock: &req, ll_md_blocking_ast, 0); it->it_flags &= ~O_CHECK_STALE; - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); /* If req is NULL, then md_intent_lock only tried to do a lock match; * if all was well, it will return 1 if it found locks, 0 otherwise. */ if (req == NULL && rc >= 0) { @@ -567,13 +567,11 @@ do_lookup: it = &lookup_it; } - OBD_ALLOC_PTR(op_data); + /* do real lookup here */ + op_data = ll_prep_md_op_data(NULL, parent, NULL, + de->d_name.name, de->d_name.len, 0); if (op_data == NULL) RETURN(-ENOMEM); - - /* do real lookup here */ - ll_prepare_md_op_data(op_data, parent, NULL, - de->d_name.name, de->d_name.len, 0); if (it->it_op & IT_CREAT) { /* @@ -601,12 +599,13 @@ do_lookup: sizeof(*mdt_body)); /* see if we got same inode, if not - return error */ if(lu_fid_eq(&op_data->fid2, &mdt_body->fid1)) { - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); + op_data = NULL; goto revalidate_finish; } ll_intent_release(it); } - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); GOTO(out, rc = 0); } diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 3f97fcf..5772bf0 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -291,18 +291,16 @@ static struct page *ll_get_dir_page(struct inode *dir, __u32 hash, int exact, struct ptlrpc_request *request; struct md_op_data *op_data; - OBD_ALLOC_PTR(op_data); + op_data = ll_prep_md_op_data(NULL, dir, NULL, NULL, 0, 0); if (op_data == NULL) return ERR_PTR(-ENOMEM); - ll_prepare_md_op_data(op_data, dir, NULL, NULL, 0, 0); - rc = md_enqueue(ll_i2sbi(dir)->ll_md_exp, LDLM_IBITS, &it, LCK_CR, op_data, &lockh, NULL, 0, ldlm_completion_ast, ll_md_blocking_ast, dir, 0); - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); request = (struct ptlrpc_request *)it.d.lustre.it_data; if (request) @@ -620,10 +618,6 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, struct md_op_data *op_data; int rc = 0; - OBD_ALLOC_PTR(op_data); - if (op_data == NULL) - RETURN(-ENOMEM); - LASSERT(sizeof(lum) == sizeof(*lump)); LASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lump->lmm_objects[0])); @@ -643,7 +637,9 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, lustre_swab_lov_user_md(&lum); /* swabbing is done in lov_setstripe() on server side */ - ll_prepare_md_op_data(op_data, inode, NULL, NULL, 0, 0); + op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0); + if (op_data == NULL) + RETURN(-ENOMEM); rc = md_setattr(sbi->ll_md_exp, op_data, &lum, sizeof(lum), NULL, 0, &request); ll_finish_md_op_data(op_data); @@ -651,7 +647,6 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, if (rc != -EPERM && rc != -EACCES) CERROR("md_setattr fails: rc = %d\n", rc); } - OBD_FREE_PTR(op_data); ptlrpc_req_finished(request); RETURN(rc); } diff --git a/lustre/llite/file.c b/lustre/llite/file.c index bbc56b5..b4cbd9b 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -52,6 +52,7 @@ void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, struct lustre_handle *fh) { op_data->fid1 = ll_i2info(inode)->lli_fid; + op_data->mod_capa1 = ll_i2mdscapa(inode); op_data->attr.ia_atime = inode->i_atime; op_data->attr.ia_mtime = inode->i_mtime; op_data->attr.ia_ctime = inode->i_ctime; @@ -141,7 +142,6 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, rc = md_close(md_exp, op_data, och, &req); ll_finish_md_op_data(op_data); - OBD_FREE_PTR(op_data); if (rc == -EAGAIN) { /* This close must have closed the epoch. */ LASSERT(epoch_close); @@ -341,10 +341,6 @@ static int ll_intent_file_open(struct file *file, void *lmm, if (!parent) RETURN(-ENOENT); - OBD_ALLOC_PTR(op_data); - if (op_data == NULL) - RETURN(-ENOMEM); - /* Usually we come here only for NFSD, and we want open lock. But we can also get here with pre 2.6.15 patchless kernels, and in that case that lock is also ok */ @@ -357,15 +353,16 @@ static int ll_intent_file_open(struct file *file, void *lmm, if (!lmm && !lmmsize) itp->it_flags |= MDS_OPEN_LOCK; - ll_prepare_md_op_data(op_data, parent->d_inode, NULL, - name, len, O_RDWR); + op_data = ll_prep_md_op_data(NULL, parent->d_inode, NULL, name, len, + O_RDWR); + if (op_data == NULL) + RETURN(-ENOMEM); rc = md_enqueue(sbi->ll_md_exp, LDLM_IBITS, itp, LCK_PW, op_data, &lockh, lmm, lmmsize, ldlm_completion_ast, ll_md_blocking_ast, NULL, 0); ll_finish_md_op_data(op_data); - OBD_FREE_PTR(op_data); if (rc < 0) { CERROR("lock enqueue: err: %d\n", rc); RETURN(rc); @@ -1900,19 +1897,17 @@ static int join_file(struct inode *head_inode, struct file *head_filp, tail_inode = tail_dentry->d_inode; tail_parent = tail_dentry->d_parent->d_inode; - OBD_ALLOC_PTR(op_data); - if (op_data == NULL) { + op_data = ll_prep_md_op_data(NULL, head_inode, tail_parent, + tail_dentry->d_name.name, + tail_dentry->d_name.len, 0); + if (op_data == NULL) RETURN(-ENOMEM); - } - - ll_prepare_md_op_data(op_data, head_inode, tail_parent, - tail_dentry->d_name.name, - tail_dentry->d_name.len, 0); rc = md_enqueue(ll_i2mdexp(head_inode), LDLM_IBITS, &oit, LCK_PW, op_data, &lockh, &tsize, 0, ldlm_completion_ast, ll_md_blocking_ast, &hsize, 0); + ll_finish_md_op_data(op_data); if (rc < 0) GOTO(out, rc); @@ -1931,8 +1926,6 @@ static int join_file(struct inode *head_inode, struct file *head_filp, } ll_release_openhandle(head_filp->f_dentry, &oit); out: - if (op_data) - OBD_FREE_PTR(op_data); ll_intent_release(&oit); RETURN(rc); } @@ -2437,21 +2430,19 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it) struct lookup_intent oit = { .it_op = IT_GETATTR }; struct md_op_data *op_data; - OBD_ALLOC_PTR(op_data); + /* Call getattr by fid, so do not provide name at all. */ + op_data = ll_prep_md_op_data(NULL, dentry->d_parent->d_inode, + dentry->d_inode, NULL, 0, 0); if (op_data == NULL) RETURN(-ENOMEM); - - /* Call getattr by fid, so do not provide name at all. */ - ll_prepare_md_op_data(op_data, dentry->d_parent->d_inode, - dentry->d_inode, NULL, 0, 0); it->it_flags |= O_CHECK_STALE; rc = md_intent_lock(exp, op_data, NULL, 0, /* we are not interested in name based lookup */ &oit, 0, &req, ll_md_blocking_ast, 0); + ll_finish_md_op_data(op_data); it->it_flags &= ~ O_CHECK_STALE; - OBD_FREE_PTR(op_data); if (rc < 0) { rc = ll_inode_revalidate_fini(inode, rc); GOTO (out, rc); diff --git a/lustre/llite/llite_capa.c b/lustre/llite/llite_capa.c index 5bbae3f..1957886 100644 --- a/lustre/llite/llite_capa.c +++ b/lustre/llite/llite_capa.c @@ -111,20 +111,14 @@ static void sort_add_capa(struct obd_capa *ocapa, struct list_head *head) static int inode_have_md_lock(struct inode *inode, __u64 inodebits) { struct obd_export *exp = ll_i2mdexp(inode); - struct lustre_handle lockh; - struct ldlm_res_id res_id = { .name = {0} }; ldlm_policy_data_t policy = { .l_inodebits = {inodebits}}; - int flags, rc; + struct lustre_handle lockh; + int flags = LDLM_FL_BLOCK_GRANTED|LDLM_FL_CBPENDING|LDLM_FL_TEST_LOCK; + int rc; ENTRY; - res_id.name[0] = inode->i_ino; - res_id.name[1] = inode->i_generation; - - CDEBUG(D_SEC, "trying to match res "LPU64"\n", res_id.name[0]); - - flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING | LDLM_FL_TEST_LOCK; - rc = ldlm_lock_match(exp->exp_obd->obd_namespace, flags, &res_id, - LDLM_IBITS, &policy, LCK_CR|LCK_CW|LCK_PR, &lockh); + rc = md_lock_match(exp, flags, ll_inode2fid(inode), + LDLM_IBITS, &policy, LCK_CR|LCK_CW|LCK_PR, &lockh); RETURN(rc); } @@ -185,7 +179,7 @@ static int capa_thread_main(void *unused) !ll_have_md_lock(ocapa->u.cli.inode, MDS_INODELOCK_LOOKUP) && !obd_capa_is_root(ocapa)) { - /* fid capa without LOOKUP lock won't renew, + /* MDS capa without LOOKUP lock won't renew, * move to idle list (except root fid) */ DEBUG_CAPA(D_SEC, &ocapa->c_capa, "skip renewal for"); @@ -362,13 +356,15 @@ struct obd_capa *ll_lookup_oss_capa(struct inode *inode, __u64 opc) struct obd_capa *ll_i2mdscapa(struct inode *inode) { struct obd_capa *ocapa; + struct ll_inode_info *lli = ll_i2info(inode); + ENTRY; LASSERT(inode); if ((ll_i2sbi(inode)->ll_flags & LL_SBI_MDS_CAPA) == 0) - return NULL; + RETURN(NULL); spin_lock(&capa_lock); - ocapa = capa_get(ll_i2info(inode)->lli_mds_capa); + ocapa = capa_get(lli->lli_mds_capa); spin_unlock(&capa_lock); if (ocapa && !obd_capa_is_valid(ocapa)) { DEBUG_CAPA(D_ERROR, &ocapa->c_capa, "invalid"); @@ -385,7 +381,7 @@ struct obd_capa *ll_i2mdscapa(struct inode *inode) atomic_set(&ll_capa_debug, 0); } - return ocapa; + RETURN(ocapa); } static inline int do_add_mds_capa(struct inode *inode, struct obd_capa **pcapa) @@ -401,7 +397,7 @@ static inline int do_add_mds_capa(struct inode *inode, struct obd_capa **pcapa) obd_capa_clear_new(ocapa); obd_capa_set_valid(ocapa); - DEBUG_CAPA(D_SEC, &ocapa->c_capa, "add fid"); + DEBUG_CAPA(D_SEC, &ocapa->c_capa, "add MDS"); } else { if (ocapa->c_capa.lc_expiry == old->c_capa.lc_expiry) { rc = -EEXIST; @@ -411,7 +407,7 @@ static inline int do_add_mds_capa(struct inode *inode, struct obd_capa **pcapa) obd_capa_set_valid(old); spin_unlock(&old->c_lock); - DEBUG_CAPA(D_SEC, &old->c_capa, "update fid"); + DEBUG_CAPA(D_SEC, &old->c_capa, "update MDS"); } free_capa(ocapa); @@ -457,7 +453,7 @@ static inline int do_add_oss_capa(struct inode *inode, struct obd_capa **pcapa) INIT_LIST_HEAD(&ocapa->u.cli.lli_list); obd_capa_set_valid(ocapa); - DEBUG_CAPA(D_SEC, capa, "add oss"); + DEBUG_CAPA(D_SEC, capa, "add OSS"); } else { if (old->c_capa.lc_expiry == capa->lc_expiry) { rc = -EEXIST; @@ -467,7 +463,7 @@ static inline int do_add_oss_capa(struct inode *inode, struct obd_capa **pcapa) obd_capa_set_valid(old); spin_unlock(&old->c_lock); - DEBUG_CAPA(D_SEC, capa, "update oss"); + DEBUG_CAPA(D_SEC, capa, "update OSS"); } free_capa(ocapa); diff --git a/lustre/llite/llite_close.c b/lustre/llite/llite_close.c index 0a83605..f0bc9ec 100644 --- a/lustre/llite/llite_close.c +++ b/lustre/llite/llite_close.c @@ -165,7 +165,7 @@ out: if (oa) obdo_free(oa); if (op_data) - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); return rc; } @@ -198,7 +198,7 @@ static void ll_done_writing(struct inode *inode) ll_pack_inode2opdata(inode, op_data, &och->och_fh); rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, op_data, och); - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); if (rc == -EAGAIN) { /* MDS has instructed us to obtain Size-on-MDS attribute from * OSTs and send setattr to back to MDS. */ diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 13442da..93103b5 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -573,9 +573,10 @@ int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize); int ll_process_config(struct lustre_cfg *lcfg); int ll_ioctl_getfacl(struct inode *inode, struct rmtacl_ioctl_data *ioc); int ll_ioctl_setfacl(struct inode *inode, struct rmtacl_ioctl_data *ioc); -void ll_prepare_md_op_data(struct md_op_data *op_data, struct inode *i1, - struct inode *i2, const char *name, int namelen, - int mode); +struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, + struct inode *i1, struct inode *i2, + const char *name, int namelen, + int mode); void ll_finish_md_op_data(struct md_op_data *op_data); /* llite/llite_nfs.c */ diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 2707aa7..8c87b6a 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -156,14 +156,14 @@ static int client_common_fill_super(struct super_block *sb, struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; struct lu_fid rootfid; - struct obd_capa *pc = NULL; + struct obd_capa *oc = NULL; struct obd_statfs osfs; struct ptlrpc_request *request = NULL; struct lustre_handle dt_conn = {0, }; struct lustre_handle md_conn = {0, }; struct obd_connect_data *data = NULL; struct lustre_md lmd; - int err; + int size, err; ENTRY; obd = class_name2obd(md); @@ -186,8 +186,8 @@ static int client_common_fill_super(struct super_block *sb, /* indicate the features supported by this client */ data->ocd_connect_flags = OBD_CONNECT_IBITS | OBD_CONNECT_NODEVOH | OBD_CONNECT_ACL | OBD_CONNECT_JOIN | - OBD_CONNECT_ATTRFID | OBD_CONNECT_VERSION;/* | - OBD_CONNECT_MDS_CAPA | OBD_CONNECT_OSS_CAPA;*/ + OBD_CONNECT_ATTRFID | OBD_CONNECT_VERSION | + OBD_CONNECT_MDS_CAPA | OBD_CONNECT_OSS_CAPA; data->ocd_ibits_known = MDS_INODELOCK_FULL; data->ocd_version = LUSTRE_VERSION_CODE; @@ -228,6 +228,14 @@ static int client_common_fill_super(struct super_block *sb, if (err) GOTO(out_md, err); + size = sizeof(*data); + err = obd_get_info(sbi->ll_md_exp, strlen(KEY_CONN_DATA), KEY_CONN_DATA, + &size, data); + if (err) { + CERROR("Get connect data failed: %d \n", err); + GOTO(out_md, err); + } + LASSERT(osfs.os_bsize); sb->s_blocksize = osfs.os_bsize; sb->s_blocksize_bits = log2(osfs.os_bsize); @@ -265,12 +273,12 @@ static int client_common_fill_super(struct super_block *sb, } if (data->ocd_connect_flags & OBD_CONNECT_MDS_CAPA) { - CDEBUG(D_SEC, "client enabled fid capa!\n"); + CDEBUG(D_SEC, "client enabled MDS capability!\n"); sbi->ll_flags |= LL_SBI_MDS_CAPA; } if (data->ocd_connect_flags & OBD_CONNECT_OSS_CAPA) { - CDEBUG(D_SEC, "client enabled oss capa!\n"); + CDEBUG(D_SEC, "client enabled OSS capability!\n"); sbi->ll_flags |= LL_SBI_OSS_CAPA; } @@ -357,7 +365,7 @@ static int client_common_fill_super(struct super_block *sb, GOTO(out_dt, err); } - err = md_getstatus(sbi->ll_md_exp, &rootfid, &pc); + err = md_getstatus(sbi->ll_md_exp, &rootfid, &oc); if (err) { CERROR("cannot mds_connect: rc = %d\n", err); GOTO(out_dt_fid, err); @@ -372,14 +380,14 @@ static int client_common_fill_super(struct super_block *sb, /* make root inode * XXX: move this to after cbd setup? */ - err = md_getattr(sbi->ll_md_exp, &rootfid, pc, - OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS | + err = md_getattr(sbi->ll_md_exp, &rootfid, oc, + OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS | OBD_MD_FLMDSCAPA | (sbi->ll_flags & LL_SBI_ACL ? OBD_MD_FLACL : 0), 0, &request); + if (oc) + free_capa(oc); if (err) { CERROR("md_getattr failed for root: rc = %d\n", err); - if (pc) - free_capa(pc); GOTO(out_dt, err); } @@ -388,17 +396,12 @@ static int client_common_fill_super(struct super_block *sb, &lmd); if (err) { CERROR("failed to understand root inode md: rc = %d\n", err); - if (pc) - free_capa(pc); ptlrpc_req_finished (request); GOTO(out_dt, err); } - if (pc) { - obd_capa_set_root(pc); - lmd.mds_capa = pc; - lmd.body->valid |= OBD_MD_FLMDSCAPA; - } + if (lmd.mds_capa) + obd_capa_set_root(lmd.mds_capa); LASSERT(fid_is_sane(&sbi->ll_root_fid)); root = ll_iget(sb, ll_fid_build_ino(sbi, &sbi->ll_root_fid), &lmd); ptlrpc_req_finished(request); @@ -1245,7 +1248,7 @@ int ll_md_setattr(struct inode *inode, struct md_op_data *op_data) int rc; ENTRY; - ll_prepare_md_op_data(op_data, inode, NULL, NULL, 0, 0); + op_data = ll_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0); rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, NULL, 0, &request); if (rc) { ptlrpc_req_finished(request); @@ -1524,7 +1527,7 @@ out: if (op_data) { if (op_data->ioepoch) rc = ll_setattr_done_writing(inode, op_data); - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); } return rc; } @@ -1791,6 +1794,15 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) } LASSERT(fid_seq(&lli->lli_fid) != 0); + + if (body->valid & OBD_MD_FLMDSCAPA) { + LASSERT(md->mds_capa); + ll_add_capa(inode, md->mds_capa); + } + if (body->valid & OBD_MD_FLOSSCAPA) { + LASSERT(md->oss_capa); + ll_add_capa(inode, md->oss_capa); + } } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) @@ -1920,17 +1932,15 @@ int ll_iocontrol(struct inode *inode, struct file *file, if (!oinfo.oi_oa) RETURN(-ENOMEM); - OBD_ALLOC_PTR(op_data); + op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0); if (op_data == NULL) RETURN(-ENOMEM); - ll_prepare_md_op_data(op_data, inode, NULL, NULL, 0, 0); - ((struct ll_iattr *)&op_data->attr)->ia_attr_flags = flags; op_data->attr.ia_valid |= ATTR_ATTR_FLAG; rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, NULL, 0, &req); - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); ptlrpc_req_finished(req); if (rc || lsm == NULL) { obdo_free(oinfo.oi_oa); @@ -2211,12 +2221,16 @@ int ll_process_config(struct lustre_cfg *lcfg) } /* this function prepares md_op_data hint for passing ot down to MD stack. */ -void ll_prepare_md_op_data(struct md_op_data *op_data, struct inode *i1, - struct inode *i2, const char *name, int namelen, - int mode) +struct md_op_data * +ll_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, + struct inode *i2, const char *name, int namelen, int mode) { LASSERT(i1 != NULL); - LASSERT(op_data != NULL); + + if (!op_data) + OBD_ALLOC_PTR(op_data); + if (!op_data) + return NULL; ll_i2gids(op_data->suppgids, i1, i2); op_data->fid1 = ll_i2info(i1)->lli_fid; @@ -2236,12 +2250,15 @@ void ll_prepare_md_op_data(struct md_op_data *op_data, struct inode *i1, op_data->fsuid = current->fsuid; op_data->fsgid = current->fsgid; op_data->cap = current->cap_effective; + + return op_data; } void ll_finish_md_op_data(struct md_op_data *op_data) { capa_put(op_data->mod_capa1); capa_put(op_data->mod_capa2); + OBD_FREE_PTR(op_data); } int ll_ioctl_getfacl(struct inode *inode, struct rmtacl_ioctl_data *ioc) diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index a2cc955..c597012 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -473,14 +473,12 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, icbd.icbd_childp = &dentry; icbd.icbd_parent = parent; - OBD_ALLOC_PTR(op_data); - if (op_data == NULL) - RETURN(ERR_PTR(-ENOMEM)); - /* prepare operatoin hint first */ - ll_prepare_md_op_data(op_data, parent, NULL, dentry->d_name.name, - dentry->d_name.len, lookup_flags); + op_data = ll_prep_md_op_data(NULL, parent, NULL, dentry->d_name.name, + dentry->d_name.len, lookup_flags); + if (op_data == NULL) + RETURN(ERR_PTR(-ENOMEM)); /* allocate new fid for child */ if (it->it_op & IT_CREAT || @@ -501,8 +499,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, rc = md_intent_lock(ll_i2mdexp(parent), op_data, NULL, 0, it, lookup_flags, &req, ll_md_blocking_ast, 0); - OBD_FREE_PTR(op_data); - + ll_finish_md_op_data(op_data); if (rc < 0) GOTO(out, retval = ERR_PTR(rc)); @@ -789,18 +786,19 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode, case S_IFBLK: case S_IFIFO: case S_IFSOCK: - OBD_ALLOC_PTR(op_data); + op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, + name->len, 0); if (op_data == NULL) RETURN(-ENOMEM); - ll_prepare_md_op_data(op_data, dir, NULL, name->name, - name->len, 0); err = ll_fid_md_alloc(sbi, &op_data->fid2, &hint); - if (err) + if (err) { + ll_finish_md_op_data(op_data); break; + } err = md_create(sbi->ll_md_exp, op_data, NULL, 0, mode, current->fsuid, current->fsgid, current->cap_effective, rdev, &request); - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); if (err) break; ll_update_times(request, REPLY_REC_OFF, dir); @@ -890,12 +888,9 @@ static int ll_symlink_generic(struct inode *dir, struct dentry *dchild, name->len, name->name, dir->i_ino, dir->i_generation, dir, tgt); - OBD_ALLOC_PTR(op_data); + op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, 0); if (op_data == NULL) RETURN(-ENOMEM); - - ll_prepare_md_op_data(op_data, dir, NULL, - name->name, name->len, 0); /* allocate new fid */ err = ll_fid_md_alloc(ll_i2sbi(dir), &op_data->fid2, &hint); @@ -908,7 +903,7 @@ static int ll_symlink_generic(struct inode *dir, struct dentry *dchild, tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO, current->fsuid, current->fsgid, current->cap_effective, 0, &request); - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); if (err == 0) { ll_update_times(request, REPLY_REC_OFF, dir); @@ -938,13 +933,11 @@ static int ll_link_generic(struct inode *src, struct inode *dir, src->i_ino, src->i_generation, src, dir->i_ino, dir->i_generation, dir, name->len, name->name); - OBD_ALLOC_PTR(op_data); + op_data = ll_prep_md_op_data(NULL, src, dir, name->name, name->len, 0); if (op_data == NULL) RETURN(-ENOMEM); - ll_prepare_md_op_data(op_data, src, dir, name->name, - name->len, 0); err = md_link(sbi->ll_md_exp, op_data, &request); - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); if (err == 0) ll_update_times(request, REPLY_REC_OFF, dir); @@ -971,11 +964,9 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, mode = (mode & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR; - OBD_ALLOC_PTR(op_data); + op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, 0); if (op_data == NULL) RETURN(-ENOMEM); - ll_prepare_md_op_data(op_data, dir, NULL, - name->name, name->len, 0); /* allocate new fid */ err = ll_fid_md_alloc(ll_i2sbi(dir), &op_data->fid2, &hint); @@ -987,7 +978,7 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, err = md_create(sbi->ll_md_exp, op_data, NULL, 0, mode, current->fsuid, current->fsgid, current->cap_effective, 0, &request); - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); ll_update_times(request, REPLY_REC_OFF, dir); if (!err && dchild) { err = ll_prep_inode(&inode, request, REPLY_REC_OFF, @@ -1025,14 +1016,12 @@ static int ll_rmdir_generic(struct inode *dir, struct dentry *dparent, } } - OBD_ALLOC_PTR(op_data); + op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, + S_IFDIR); if (op_data == NULL) RETURN(-ENOMEM); - - ll_prepare_md_op_data(op_data, dir, NULL, name->name, - name->len, S_IFDIR); rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request); - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); if (rc == 0) ll_update_times(request, REPLY_REC_OFF, dir); ptlrpc_req_finished(request); @@ -1128,13 +1117,11 @@ static int ll_unlink_generic(struct inode * dir, struct qstr *name) CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", name->len, name->name, dir->i_ino, dir->i_generation, dir); - OBD_ALLOC_PTR(op_data); + op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, 0); if (op_data == NULL) RETURN(-ENOMEM); - - ll_prepare_md_op_data(op_data, dir, NULL, name->name, name->len, 0); rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request); - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); if (rc) GOTO(out, rc); @@ -1160,15 +1147,13 @@ static int ll_rename_generic(struct inode *src, struct qstr *src_name, src->i_ino, src->i_generation, src, tgt_name->len, tgt_name->name, tgt->i_ino, tgt->i_generation, tgt); - OBD_ALLOC_PTR(op_data); + op_data = ll_prep_md_op_data(NULL, src, tgt, NULL, 0, 0); if (op_data == NULL) RETURN(-ENOMEM); - - ll_prepare_md_op_data(op_data, src, tgt, NULL, 0, 0); err = md_rename(sbi->ll_md_exp, op_data, src_name->name, src_name->len, tgt_name->name, tgt_name->len, &request); - OBD_FREE_PTR(op_data); + ll_finish_md_op_data(op_data); if (!err) { ll_update_times(request, REPLY_REC_OFF, src); ll_update_times(request, REPLY_REC_OFF, tgt); diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 50f99ed..ed8a84f 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -2213,8 +2213,7 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen, RETURN(0); } RETURN(-EINVAL); - } else if (keylen >= strlen("max_easize") && !strcmp(key, "max_easize")) { - + } else if (KEY_IS(KEY_MAX_EASIZE) || KEY_IS(KEY_CONN_DATA)) { rc = lmv_check_connect(obd); if (rc) RETURN(rc); diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index a1c19d6..ed129bd 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -404,6 +404,8 @@ int mdc_enqueue(struct obd_export *exp, size[DLM_INTENT_REC_OFF] = sizeof(struct mdt_body); size[DLM_INTENT_REC_OFF + 1] = op_data->mod_capa1 ? sizeof(struct lustre_capa) : 0; + if (op_data->mod_capa1) + valid |= OBD_MD_FLMDSCAPA; size[DLM_INTENT_REC_OFF + 2] = op_data->namelen + 1; if (it->it_op & IT_GETATTR) @@ -598,7 +600,7 @@ int mdc_enqueue(struct obd_export *exp, capa = lustre_unpack_capa(req->rq_repmsg, reply_off++); if (capa == NULL) { - CERROR("Missing/short client fid capa\n"); + CERROR("Missing/short MDS capability\n"); RETURN(-EPROTO); } @@ -616,7 +618,7 @@ int mdc_enqueue(struct obd_export *exp, capa = lustre_unpack_capa(req->rq_repmsg, reply_off++); if (capa == NULL) { - CERROR("Missing/short client oss capa\n"); + CERROR("Missing/short OSS capability\n"); RETURN(-EPROTO); } } diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index ca2a095..56f7032 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -150,31 +150,29 @@ int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid, * of fields. This issue will be fixed later when client gets awar of RPC * layouts. --umka */ -static -int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, - unsigned int acl_size, struct ptlrpc_request *req) +static int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, + unsigned int acl_size, int mdscapa, + struct ptlrpc_request *req) { struct mdt_body *body; void *eadata; int size[5] = { sizeof(struct ptlrpc_body), - sizeof(*body) }; - int bufcount = 2, rc; + sizeof(*body), + ea_size, + acl_size }; + int offset, rc; ENTRY; /* Request message already built. */ - if (ea_size != 0) { - size[bufcount++] = ea_size; + if (ea_size) CDEBUG(D_INODE, "reserved %u bytes for MD/symlink in packet\n", ea_size); - } - - if (acl_size) { - size[bufcount++] = acl_size; + if (acl_size) CDEBUG(D_INODE, "reserved %u bytes for ACL\n", acl_size); - } + if (mdscapa) + size[REPLY_REC_OFF + 2] = sizeof(struct lustre_capa); - size[bufcount++] = sizeof(struct lustre_capa); - ptlrpc_req_set_repsize(req, bufcount, size); + ptlrpc_req_set_repsize(req, 5, size); rc = ptlrpc_queue_wait(req); if (rc != 0) @@ -189,10 +187,11 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, CDEBUG(D_NET, "mode: %o\n", body->mode); - LASSERT_REPSWAB(req, REPLY_REC_OFF + 1); + offset = REPLY_REC_OFF + 1; + LASSERT_REPSWAB(req, offset); if (body->eadatasize != 0) { /* reply indicates presence of eadata; check it's there... */ - eadata = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1, + eadata = lustre_msg_buf(req->rq_repmsg, offset++, body->eadatasize); if (eadata == NULL) { CERROR ("Missing/short eadata\n"); @@ -201,13 +200,25 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, } if (body->valid & OBD_MD_FLMODEASIZE) { - if (exp->exp_obd->u.cli.cl_max_mds_easize < body->max_mdsize) - exp->exp_obd->u.cli.cl_max_mds_easize = - body->max_mdsize; - if (exp->exp_obd->u.cli.cl_max_mds_cookiesize < - body->max_cookiesize) - exp->exp_obd->u.cli.cl_max_mds_cookiesize = - body->max_cookiesize; + struct client_obd *cli = &exp->exp_obd->u.cli; + + if (cli->cl_max_mds_easize < body->max_mdsize) + cli->cl_max_mds_easize = body->max_mdsize; + if (cli->cl_max_mds_cookiesize < body->max_cookiesize) + cli->cl_max_mds_cookiesize = body->max_cookiesize; + } + + offset += !!body->aclsize; + + if (body->valid & OBD_MD_FLMDSCAPA) { + struct lustre_capa *capa; + + LASSERT(mdscapa); + capa = lustre_unpack_capa(req->rq_repmsg, offset++); + if (capa == NULL) { + CERROR("Missing/short client MDS capability\n"); + RETURN(-EPROTO); + } } RETURN (0); @@ -241,7 +252,8 @@ int mdc_getattr(struct obd_export *exp, const struct lu_fid *fid, if (valid & OBD_MD_FLACL) acl_size = LUSTRE_POSIX_ACL_MAX_SIZE; - rc = mdc_getattr_common(exp, ea_size, acl_size, req); + rc = mdc_getattr_common(exp, ea_size, acl_size, + !!(valid & OBD_MD_FLMDSCAPA), req); if (rc != 0) { ptlrpc_req_finished (req); req = NULL; @@ -277,7 +289,8 @@ int mdc_getattr_name(struct obd_export *exp, const struct lu_fid *fid, memcpy(lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2, namelen), filename, namelen); - rc = mdc_getattr_common(exp, ea_size, 0, req); + rc = mdc_getattr_common(exp, ea_size, 0, !!(valid & OBD_MD_FLMDSCAPA), + req); if (rc != 0) { ptlrpc_req_finished (req); req = NULL; @@ -483,7 +496,7 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, struct obd_export *md_exp, struct lustre_md *md) { - int rc = 0; + int rc; ENTRY; LASSERT(md); @@ -494,10 +507,6 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, LASSERT_REPSWABBED(req, offset); offset++; - if (!(md->body->valid & OBD_MD_FLEASIZE) && - !(md->body->valid & OBD_MD_FLDIREA)) - RETURN(0); - if (md->body->valid & OBD_MD_FLEASIZE) { int lmmsize; struct lov_mds_md *lmm; @@ -505,7 +514,7 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, LASSERT(S_ISREG(md->body->mode)); if (md->body->eadatasize == 0) { - CERROR ("OBD_MD_FLEASIZE set, but eadatasize 0\n"); + CERROR("OBD_MD_FLEASIZE set, but eadatasize 0\n"); RETURN(-EPROTO); } lmmsize = md->body->eadatasize; @@ -518,8 +527,6 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, RETURN(rc); LASSERT (rc >= sizeof (*md->lsm)); - rc = 0; - offset++; } else if (md->body->valid & OBD_MD_FLDIREA) { int lmvsize; @@ -527,7 +534,8 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, LASSERT(S_ISDIR(md->body->mode)); if (md->body->eadatasize == 0) { - RETURN(0); + CERROR("OBD_MD_FLEASIZE set, but eadatasize 0\n"); + RETURN(-EPROTO); } if (md->body->valid & OBD_MD_MEA) { lmvsize = md->body->eadatasize; @@ -542,44 +550,40 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, LASSERT (rc >= sizeof (*md->mea)); } - rc = 0; - offset ++; + offset++; } + rc = 0; /* for ACL, it's possible that FLACL is set but aclsize is zero. only * when aclsize != 0 there's an actual segment for ACL in reply * buffer. */ if ((md->body->valid & OBD_MD_FLACL) && md->body->aclsize) { - rc = mdc_unpack_acl(dt_exp, req, md, offset); + rc = mdc_unpack_acl(dt_exp, req, md, offset++); if (rc) GOTO(out, rc); - offset++; } /* remote permission */ if (md->body->valid & OBD_MD_FLRMTPERM) { - md->remote_perm = lustre_msg_buf(req->rq_repmsg, offset, + md->remote_perm = lustre_msg_buf(req->rq_repmsg, offset++, sizeof(struct mdt_remote_perm)); LASSERT(md->remote_perm); - offset++; } if (md->body->valid & OBD_MD_FLMDSCAPA) { - struct obd_capa *oc = mdc_unpack_capa(req, offset); + struct obd_capa *oc = mdc_unpack_capa(req, offset++); if (IS_ERR(oc)) GOTO(out, rc = PTR_ERR(oc)); md->mds_capa = oc; - offset++; } if (md->body->valid & OBD_MD_FLOSSCAPA) { - struct obd_capa *oc = mdc_unpack_capa(req, offset); + struct obd_capa *oc = mdc_unpack_capa(req, offset++); if (IS_ERR(oc)) GOTO(out, rc = PTR_ERR(oc)); md->oss_capa = oc; - offset++; } EXIT; @@ -1124,8 +1128,7 @@ int mdc_get_info(struct obd_export *exp, __u32 keylen, void *key, { int rc = -EINVAL; - if (keylen == strlen("max_easize") && - memcmp(key, "max_easize", strlen("max_easize")) == 0) { + if (KEY_IS(KEY_MAX_EASIZE)) { int mdsize, *max_easize; if (*vallen != sizeof(int)) @@ -1137,6 +1140,17 @@ int mdc_get_info(struct obd_export *exp, __u32 keylen, void *key, *max_easize = exp->exp_obd->u.cli.cl_max_mds_easize; RETURN(0); } + if (KEY_IS(KEY_CONN_DATA)) { + struct obd_import *imp = class_exp2cliimp(exp); + struct obd_connect_data *data = val; + + if (*vallen != sizeof(*data)) + RETURN(-EINVAL); + + *data = imp->imp_connect_data; + RETURN(0); + } + RETURN(rc); } diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index d7caeea..b756fc9 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -3176,7 +3176,7 @@ static int mdd_capa_get(const struct lu_context *ctxt, struct md_object *obj, capa->lc_flags |= CAPA_FL_SHORT_EXPIRY; if (lu_fid_eq(&capa->lc_fid, &mdd->mdd_root_fid)) capa->lc_flags |= CAPA_FL_ROOT; - capa->lc_flags = ls->ls_capa_alg << 23; + capa->lc_flags = ls->ls_capa_alg << 24; /* TODO: get right permission here after remote uid landing */ ocapa = capa_lookup(capa); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index a76ca78..f774a4c 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -353,12 +353,10 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, buffer = req_capsule_server_get(pill, &RMF_ACL); /* mdt_getattr_lock only */ rc = mdt_pack_remote_perm(info, o, buffer); - if (rc) { + if (rc) RETURN(rc); - } else { - repbody->valid |= OBD_MD_FLRMTPERM; - repbody->aclsize = sizeof(struct mdt_remote_perm); - } + repbody->valid |= OBD_MD_FLRMTPERM; + repbody->aclsize = sizeof(struct mdt_remote_perm); } #ifdef CONFIG_FS_POSIX_ACL else if ((req->rq_export->exp_connect_flags & OBD_CONNECT_ACL) && @@ -381,7 +379,7 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, } #endif - if (mdt->mdt_opts.mo_mds_capa) { + if ((reqbody->valid & OBD_MD_FLMDSCAPA) && mdt->mdt_opts.mo_mds_capa) { struct lustre_capa *capa; spin_lock(&capa_lock); @@ -394,8 +392,7 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, rc = mo_capa_get(ctxt, next, capa); if (rc) RETURN(rc); - else - repbody->valid |= OBD_MD_FLMDSCAPA; + repbody->valid |= OBD_MD_FLMDSCAPA; } RETURN(rc); @@ -1151,10 +1148,11 @@ static int mdt_quotactl_handle(struct mdt_thread_info *info) static int mdt_renew_capa(struct mdt_thread_info *info) { struct mdt_device *mdt = info->mti_mdt; - struct mdt_object *obj; + struct mdt_object *obj = info->mti_object; struct mdt_body *body; - struct lustre_capa *capa; + struct lustre_capa *capa; int rc; + ENTRY; body = req_capsule_server_get(&info->mti_pill, &RMF_MDT_BODY); LASSERT(body); @@ -1166,11 +1164,7 @@ static int mdt_renew_capa(struct mdt_thread_info *info) info->mti_capa_key = *red_capa_key(mdt); spin_unlock(&capa_lock); - obj = mdt_object_find(info->mti_ctxt, info->mti_mdt, &capa->lc_fid, - capa); - if (!IS_ERR(obj)) - rc = PTR_ERR(obj); - + *capa = obj->mot_header.loh_capa; /* TODO: add capa check */ rc = mo_capa_get(info->mti_ctxt, mdt_object_child(obj), capa); if (rc) diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index e73fbc9..8def3b1 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -99,7 +99,7 @@ static int ost_destroy(struct obd_export *exp, struct ptlrpc_request *req, sizeof(*repbody)); memcpy(&repbody->oa, &body->oa, sizeof(body->oa)); if (body->oa.o_valid & OBD_MD_FLOSSCAPA) - capa = lustre_unpack_capa(req->rq_repmsg, REQ_REC_OFF + 1); + capa = lustre_unpack_capa(req->rq_reqmsg, REQ_REC_OFF + 1); req->rq_status = obd_destroy(exp, &body->oa, NULL, oti, NULL, capa); RETURN(0); } diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index 4ffbd6c..7f5ab64 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -1307,7 +1307,7 @@ static int mkfs_mdt(struct mkfs_opts *mop) } snprintf(filepnm, sizeof(filepnm) - 1, "%s/%s", mntpt, CAPA_KEYS); - ret = iam_creat(filepnm, FMT_LFIX, L_BLOCK_SIZE, 1, 1, 4); + ret = touch_file(filepnm); if (ret) { goto out_umount; } -- 1.8.3.1