From: nikita Date: Fri, 28 Jul 2006 17:29:16 +0000 (+0000) Subject: readdir fixes X-Git-Tag: v1_8_0_110~486^2~1321 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=2ac2f5a2454782c275dee3733dbd9080f96a5b46;p=fs%2Flustre-release.git readdir fixes --- diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index e34d701..5492160 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -229,7 +229,7 @@ static inline int fid_is_sane(const struct lu_fid *fid) fid_seq_is_sane(fid_seq(fid)) && fid_oid(fid) != 0; } -#define DFID3 "["LPU64"/%u:%u]" +#define DFID3 "[%16.16"LPF64"x/%8.8x:%8.8x]" #define PFID3(fid) \ fid_seq(fid), \ diff --git a/lustre/kernel_patches/patches/ext3-iam-separate.patch b/lustre/kernel_patches/patches/ext3-iam-separate.patch index b06605a..f89ab7a 100644 --- a/lustre/kernel_patches/patches/ext3-iam-separate.patch +++ b/lustre/kernel_patches/patches/ext3-iam-separate.patch @@ -1,7 +1,7 @@ Index: iam/fs/ext3/Makefile =================================================================== --- iam.orig/fs/ext3/Makefile 2006-05-31 20:24:32.000000000 +0400 -+++ iam/fs/ext3/Makefile 2006-07-28 01:53:16.000000000 +0400 ++++ iam/fs/ext3/Makefile 2006-07-28 20:55:09.000000000 +0400 @@ -6,7 +6,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \ @@ -5461,7 +5461,7 @@ Index: iam/fs/ext3/namei.c Index: iam/include/linux/lustre_iam.h =================================================================== --- iam.orig/include/linux/lustre_iam.h 2006-05-31 20:24:32.000000000 +0400 -+++ iam/include/linux/lustre_iam.h 2006-07-28 01:53:16.000000000 +0400 ++++ iam/include/linux/lustre_iam.h 2006-07-28 20:55:09.000000000 +0400 @@ -1,9 +1,68 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: diff --git a/lustre/kernel_patches/patches/ext3-iam-uapi.patch b/lustre/kernel_patches/patches/ext3-iam-uapi.patch index 146d4af..ad82ce0 100644 --- a/lustre/kernel_patches/patches/ext3-iam-uapi.patch +++ b/lustre/kernel_patches/patches/ext3-iam-uapi.patch @@ -1,7 +1,7 @@ Index: iam/fs/ext3/Makefile =================================================================== ---- iam.orig/fs/ext3/Makefile 2006-07-28 01:53:16.000000000 +0400 -+++ iam/fs/ext3/Makefile 2006-07-28 01:53:16.000000000 +0400 +--- iam.orig/fs/ext3/Makefile 2006-07-28 20:55:09.000000000 +0400 ++++ iam/fs/ext3/Makefile 2006-07-28 20:55:10.000000000 +0400 @@ -6,7 +6,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \ @@ -13,8 +13,8 @@ Index: iam/fs/ext3/Makefile ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o Index: iam/fs/ext3/dir.c =================================================================== ---- iam.orig/fs/ext3/dir.c 2006-07-28 01:53:16.000000000 +0400 -+++ iam/fs/ext3/dir.c 2006-07-28 01:53:16.000000000 +0400 +--- iam.orig/fs/ext3/dir.c 2006-07-28 20:55:09.000000000 +0400 ++++ iam/fs/ext3/dir.c 2006-07-28 20:55:10.000000000 +0400 @@ -28,6 +28,7 @@ #include #include @@ -112,8 +112,8 @@ Index: iam/fs/ext3/dir.c (filp->f_version != inode->i_version)) { Index: iam/fs/ext3/file.c =================================================================== ---- iam.orig/fs/ext3/file.c 2006-07-28 01:53:16.000000000 +0400 -+++ iam/fs/ext3/file.c 2006-07-28 01:53:16.000000000 +0400 +--- iam.orig/fs/ext3/file.c 2006-07-28 20:55:09.000000000 +0400 ++++ iam/fs/ext3/file.c 2006-07-28 20:55:10.000000000 +0400 @@ -23,6 +23,7 @@ #include #include @@ -149,7 +149,7 @@ Index: iam/fs/ext3/file.c Index: iam/fs/ext3/iam-uapi.c =================================================================== --- iam.orig/fs/ext3/iam-uapi.c 2004-04-06 17:27:52.000000000 +0400 -+++ iam/fs/ext3/iam-uapi.c 2006-07-28 01:53:16.000000000 +0400 ++++ iam/fs/ext3/iam-uapi.c 2006-07-28 20:55:10.000000000 +0400 @@ -0,0 +1,361 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: @@ -514,8 +514,8 @@ Index: iam/fs/ext3/iam-uapi.c +} Index: iam/fs/ext3/ioctl.c =================================================================== ---- iam.orig/fs/ext3/ioctl.c 2006-07-28 01:53:16.000000000 +0400 -+++ iam/fs/ext3/ioctl.c 2006-07-28 01:53:16.000000000 +0400 +--- iam.orig/fs/ext3/ioctl.c 2006-07-28 20:55:09.000000000 +0400 ++++ iam/fs/ext3/ioctl.c 2006-07-28 20:55:10.000000000 +0400 @@ -250,6 +250,6 @@ flags_err: @@ -526,8 +526,8 @@ Index: iam/fs/ext3/ioctl.c } Index: iam/include/linux/lustre_iam.h =================================================================== ---- iam.orig/include/linux/lustre_iam.h 2006-07-28 01:53:16.000000000 +0400 -+++ iam/include/linux/lustre_iam.h 2006-07-28 01:53:16.000000000 +0400 +--- iam.orig/include/linux/lustre_iam.h 2006-07-28 20:55:09.000000000 +0400 ++++ iam/include/linux/lustre_iam.h 2006-07-28 20:55:10.000000000 +0400 @@ -30,9 +30,6 @@ #ifndef __LINUX_LUSTRE_IAM_H__ #define __LINUX_LUSTRE_IAM_H__ diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 44a82af..655e667 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -73,7 +73,7 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, op_data.flags = MDS_BFLAG_UNCOMMITTED_WRITES; op_data.valid |= OBD_MD_FLFLAGS; } - + rc = md_close(md_exp, &op_data, och, &req); if (rc == EAGAIN) { /* We are the last writer, so the MDS has instructed us to get @@ -129,7 +129,7 @@ int ll_md_close(struct obd_export *md_exp, struct inode *inode, och->och_mod->mod_open_req->rq_type, och->och_mod->mod_open_req->rq_transno, och->och_fh.cookie); - + rc = ll_close_inode_openhandle(md_exp, inode, och); och->och_fh.cookie = DEAD_HANDLE_MAGIC; LUSTRE_FPRIVATE(file) = NULL; @@ -157,14 +157,17 @@ int ll_file_release(struct inode *inode, struct file *file) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); - /* don't do anything for / */ - if (inode->i_sb->s_root == file->f_dentry) - RETURN(0); - lprocfs_counter_incr(sbi->ll_stats, LPROC_LL_RELEASE); fd = LUSTRE_FPRIVATE(file); LASSERT(fd != NULL); + /* don't do anything for / */ + if (inode->i_sb->s_root == file->f_dentry) { + LUSTRE_FPRIVATE(file) = NULL; + ll_file_data_put(fd); + RETURN(0); + } + if (lsm) lov_test_and_clear_async_rc(lsm); lli->lli_async_rc = 0; @@ -187,7 +190,7 @@ static int ll_intent_file_open(struct file *file, void *lmm, if (!parent) RETURN(-ENOENT); - ll_prepare_md_op_data(&op_data, parent->d_inode, NULL, + ll_prepare_md_op_data(&op_data, parent->d_inode, NULL, name, len, O_RDWR); rc = md_enqueue(sbi->ll_md_exp, LDLM_IBITS, itp, LCK_PW, &op_data, @@ -205,7 +208,7 @@ out: RETURN(rc); } -static void ll_och_fill(struct obd_export *md_exp, struct ll_inode_info *lli, +static void ll_och_fill(struct obd_export *md_exp, struct ll_inode_info *lli, struct lookup_intent *it, struct obd_client_handle *och) { struct ptlrpc_request *req = it->d.lustre.it_data; @@ -236,7 +239,7 @@ int ll_local_open(struct file *file, struct lookup_intent *it, ll_och_fill(ll_i2sbi(inode)->ll_md_exp, ll_i2info(inode), it, &fd->fd_mds_och); - + LUSTRE_FPRIVATE(file) = fd; ll_readahead_init(inode, &fd->fd_ras); @@ -272,19 +275,21 @@ int ll_file_open(struct inode *inode, struct file *file) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), flags %o\n", inode->i_ino, inode->i_generation, inode, file->f_flags); - /* don't do anything for / */ - if (inode->i_sb->s_root == file->f_dentry) - RETURN(0); - it = file->f_it; fd = ll_file_data_get(); if (fd == NULL) RETURN(-ENOMEM); + /* don't do anything for / */ + if (inode->i_sb->s_root == file->f_dentry) { + LUSTRE_FPRIVATE(file) = fd; + RETURN(0); + } + if (!it || !it->d.lustre.it_disposition) { struct ll_sb_info *sbi = ll_i2sbi(inode); - + /* Convert f_flags into access mode. We cannot use file->f_mode, * because everything but O_ACCMODE mask was stripped from * there */ @@ -306,7 +311,7 @@ int ll_file_open(struct inode *inode, struct file *file) ll_file_data_put(fd); GOTO(out, rc); } - + md_set_lock_data(sbi->ll_md_exp, &it->d.lustre.it_lock_handle, file->f_dentry->d_inode); } @@ -325,7 +330,7 @@ int ll_file_open(struct inode *inode, struct file *file) LASSERTF(rc == 0, "rc = %d\n", rc); CDEBUG(D_INFO, "opening ino = %lu file = %p has open req = %p, type = %x, " "transno = "LPU64", handle = "LPX64"\n", - inode->i_ino, file, req, req->rq_type, + inode->i_ino, file, req, req->rq_type, req->rq_transno, fd->fd_mds_och.och_fh.cookie); if (!S_ISREG(inode->i_mode)) @@ -1480,7 +1485,7 @@ static int join_file(struct inode *head_inode, struct file *head_filp, 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); @@ -1628,7 +1633,7 @@ int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it) ll_och_fill(ll_i2sbi(inode)->ll_md_exp, ll_i2info(inode), it, och); - rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, + rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, inode, och); OBD_FREE(och, sizeof(*och)); @@ -1931,7 +1936,7 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it) } sbi = ll_i2sbi(inode); lli = ll_i2info(inode); - + CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),name=%s\n", inode->i_ino, inode->i_generation, inode, dentry->d_name.name); #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)) @@ -1939,7 +1944,7 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it) #endif ll_prepare_md_op_data(&op_data, inode, inode, NULL, 0, 0); - + rc = md_intent_lock(sbi->ll_md_exp, &op_data, NULL, 0, &oit, 0, &req, ll_md_blocking_ast, 0); @@ -1951,7 +1956,7 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it) GOTO(out, rc); ll_lookup_finish_locks(&oit, dentry); - + /* object is allocated, validate size */ if (lli->lli_smd) { /* ll_glimpse_size will prefer locally cached writes if they diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index e5e14a4..9d0838a 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -450,6 +450,7 @@ static int __mdd_attr_set(const struct lu_context *ctxt, struct md_object *obj, static int mdd_attr_set(const struct lu_context *ctxt, struct md_object *obj, const struct lu_attr *attr) { + struct mdd_object *mdo = md2mdd_obj(obj); struct mdd_device *mdd = mdo2mdd(obj); struct thandle *handle; int rc; @@ -460,7 +461,9 @@ static int mdd_attr_set(const struct lu_context *ctxt, if (IS_ERR(handle)) RETURN(PTR_ERR(handle)); + mdd_lock(ctxt, mdo, DT_WRITE_LOCK); rc = __mdd_attr_set(ctxt, obj, attr, handle); + mdd_unlock(ctxt, mdo, DT_WRITE_LOCK); mdd_trans_stop(ctxt, mdd, handle); @@ -483,6 +486,7 @@ static int __mdd_xattr_set(const struct lu_context *ctxt,struct mdd_device *mdd, int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj, const void *buf, int buf_len, const char *name, int fl) { + struct mdd_object *mdo = md2mdd_obj(obj); struct mdd_device *mdd = mdo2mdd(obj); struct thandle *handle; int rc; @@ -493,8 +497,10 @@ int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj, if (IS_ERR(handle)) RETURN(PTR_ERR(handle)); + mdd_lock(ctxt, mdo, DT_WRITE_LOCK); rc = __mdd_xattr_set(ctxt, mdd, md2mdd_obj(obj), buf, buf_len, name, fl, handle); + mdd_unlock(ctxt, mdo, DT_WRITE_LOCK); mdd_trans_stop(ctxt, mdd, handle); @@ -515,6 +521,7 @@ static int __mdd_xattr_del(const struct lu_context *ctxt,struct mdd_device *mdd, int mdd_xattr_del(const struct lu_context *ctxt, struct md_object *obj, const char *name) { + struct mdd_object *mdo = md2mdd_obj(obj); struct mdd_device *mdd = mdo2mdd(obj); struct thandle *handle; int rc; @@ -525,7 +532,9 @@ int mdd_xattr_del(const struct lu_context *ctxt, struct md_object *obj, if (IS_ERR(handle)) RETURN(PTR_ERR(handle)); + mdd_lock(ctxt, mdo, DT_WRITE_LOCK); rc = __mdd_xattr_del(ctxt, mdd, md2mdd_obj(obj), name, handle); + mdd_unlock(ctxt, mdo, DT_WRITE_LOCK); mdd_trans_stop(ctxt, mdd, handle); @@ -661,10 +670,8 @@ static int mdd_unlink(const struct lu_context *ctxt, struct md_object *pobj, if (dt_try_as_dir(ctxt, dt_cobj)) { if (!S_ISDIR(ma->ma_attr.la_mode)) RETURN(rc = -EISDIR); - } else { - if (S_ISDIR(ma->ma_attr.la_mode)) + } else if (S_ISDIR(ma->ma_attr.la_mode)) RETURN(rc = -ENOTDIR); - } if (S_ISREG(ma->ma_attr.la_mode) && ma && ma->ma_lmm != 0 && ma->ma_lmm_size > 0) { @@ -845,16 +852,19 @@ cleanup: static int mdd_lookup(const struct lu_context *ctxt, struct md_object *pobj, const char *name, struct lu_fid* fid) { - struct dt_object *dir = mdd_object_child(md2mdd_obj(pobj)); + struct mdd_object *mdo = md2mdd_obj(pobj); + struct dt_object *dir = mdd_object_child(mdo); struct dt_rec *rec = (struct dt_rec *)fid; const struct dt_key *key = (const struct dt_key *)name; int rc; ENTRY; + mdd_lock(ctxt, mdo, DT_READ_LOCK); if (dt_try_as_dir(ctxt, dir)) rc = dir->do_index_ops->dio_lookup(ctxt, dir, rec, key); else rc = -ENOTDIR; + mdd_unlock(ctxt, mdo, DT_READ_LOCK); RETURN(rc); } @@ -1156,7 +1166,10 @@ static int mdd_ref_add(const struct lu_context *ctxt, struct md_object *obj) handle = mdd_trans_start(ctxt, mdd); if (IS_ERR(handle)) RETURN(-ENOMEM); + + mdd_lock(ctxt, mdd_obj, DT_WRITE_LOCK); __mdd_ref_add(ctxt, mdd_obj, handle); + mdd_unlock(ctxt, mdd_obj, DT_WRITE_LOCK); mdd_trans_stop(ctxt, mdd, handle); @@ -1191,7 +1204,10 @@ static int mdd_ref_del(const struct lu_context *ctxt, struct md_object *obj, handle = mdd_trans_start(ctxt, mdd); if (IS_ERR(handle)) RETURN(-ENOMEM); + + mdd_lock(ctxt, mdd_obj, DT_WRITE_LOCK); __mdd_ref_del(ctxt, mdd_obj, handle, ma); + mdd_unlock(ctxt, mdd_obj, DT_WRITE_LOCK); mdd_trans_stop(ctxt, mdd, handle); @@ -1212,11 +1228,18 @@ static int mdd_readpage(const struct lu_context *ctxt, struct md_object *obj, const struct lu_rdpg *rdpg) { struct dt_object *next; + struct mdd_object *mdd = md2mdd_obj(obj); int rc; LASSERT(lu_object_exists(ctxt, mdd2lu_obj(md2mdd_obj(obj)))); next = mdd_object_child(md2mdd_obj(obj)); + + mdd_lock(ctxt, mdd, DT_READ_LOCK); + if (dt_try_as_dir(ctxt, next)) rc = next->do_ops->do_readpage(ctxt, next, rdpg); + else + rc = -ENOTDIR; + mdd_unlock(ctxt, mdd, DT_READ_LOCK); return rc; } diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 13b03cb..50777cd1 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -1785,7 +1785,7 @@ invalid: /* Common mount */ -int lustre_fill_super(struct super_block *sb, void *data, int silent) +static int lustre_fill_super(struct super_block *sb, void *data, int silent) { struct lustre_mount_data *lmd; struct lustre_sb_info *lsi; diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index c6dc005..0d981cd 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -926,6 +926,8 @@ static int osd_dir_page_build(const struct lu_context *ctx, int first, */ hash = *(__u32 *)(name - sizeof(__u16) - sizeof(__u32)); *end = hash; + CERROR("%p %p %d "DFID3": %#8.8x (%d)\"%*.*s\"\n", + area, ent, nob, PFID3(fid), hash, len, len, len, name); if (nob >= recsize) { ent->lde_fid = *fid; ent->lde_hash = hash; @@ -964,6 +966,7 @@ static int osd_readpage(const struct lu_context *ctxt, LASSERT(lu_object_exists(ctxt, &dt->do_lu)); LASSERT(osd_invariant(obj)); + LASSERT(osd_has_index(obj)); LASSERT(rdpg->rp_pages != NULL); @@ -995,13 +998,14 @@ static int osd_readpage(const struct lu_context *ctxt, for (i = 0, rc = 0, nob = rdpg->rp_count; rc == 0 && nob > 0; i++, nob -= CFS_PAGE_SIZE) { - LASSERT(i < rdpg->rp_npages); pg = rdpg->rp_pages[i]; rc = osd_dir_page_build(ctxt, !i, kmap(pg), min_t(int, nob, CFS_PAGE_SIZE), iops, it, &hash_start, &hash_end, &last); + if (rc != 0 || i == rdpg->rp_npages - 1) + last->lde_reclen = 0; kunmap(pg); } iops->put(ctxt, it); @@ -1019,11 +1023,6 @@ static int osd_readpage(const struct lu_context *ctxt, dp->ldp_hash_start = hash_start; dp->ldp_hash_end = hash_end; kunmap(rdpg->rp_pages[0]); - kmap(pg); - LASSERT(page_address(pg) <= (void *)last && - (void *)last < page_address(pg) + CFS_PAGE_SIZE); - last->lde_reclen = 0; - kunmap(pg); } } else if (rc == 0) rc = -EIO; @@ -1062,6 +1061,8 @@ static struct file *osd_rw_init(const struct lu_context *ctxt, file->f_dentry = dentry; file->f_mapping = inode->i_mapping; + file->f_op = inode->i_fop; + file->f_mode = FMODE_WRITE|FMODE_READ; dentry->d_inode = inode; *seg = get_fs(); @@ -1083,7 +1084,11 @@ static ssize_t osd_read(const struct lu_context *ctxt, struct dt_object *dt, ssize_t result; file = osd_rw_init(ctxt, inode, &seg); - result = inode->i_fop->read(file, buf, count, pos); + /* + * We'd like to use vfs_read() here, but it messes with + * dnotify_parent() and locks. + */ + result = file->f_op->read(file, buf, count, pos); osd_rw_fini(&seg); return result; } @@ -1098,7 +1103,7 @@ static int osd_write(const struct lu_context *ctxt, struct dt_object *dt, ssize_t result; file = osd_rw_init(ctxt, inode, &seg); - result = inode->i_fop->write(file, buf, count, pos); + result = file->f_op->write(file, buf, count, pos); osd_rw_fini(&seg); return result; }