From 8acd500d4414392d9441c9214fd208b399f5941f Mon Sep 17 00:00:00 2001 From: shadow Date: Tue, 14 Jul 2009 06:23:12 +0000 Subject: [PATCH] first part of new dcache handling (bug 16654) make DCACHE_LUSTRE_INVALID is always defined. Branch b1_8 b=16417 i=green i=johann --- lustre/include/lustre_mds.h | 2 +- lustre/liblustre/namei.c | 2 +- lustre/llite/dcache.c | 49 +++++++++++++------------------------------ lustre/llite/file.c | 4 ++-- lustre/llite/llite_internal.h | 4 ++++ lustre/llite/llite_lib.c | 2 -- lustre/llite/namei.c | 22 ++++++++++++++----- lustre/mdc/mdc_locks.c | 7 ++++++- 8 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lustre/include/lustre_mds.h b/lustre/include/lustre_mds.h index 87c6978..4808866 100644 --- a/lustre/include/lustre_mds.h +++ b/lustre/include/lustre_mds.h @@ -181,7 +181,7 @@ static inline void it_clear_disposition(struct lookup_intent *it, int flag) } int it_open_error(int phase, struct lookup_intent *it); -void mdc_set_lock_data(__u64 *lockh, void *data); +void mdc_set_lock_data(__u64 *lockh, void *data, __u32 *lockbits); int mdc_change_cbdata(struct obd_export *exp, struct ll_fid *fid, ldlm_iterator_t it, void *data); int mdc_revalidate_lock(struct obd_export *exp, diff --git a/lustre/liblustre/namei.c b/lustre/liblustre/namei.c index ef60178b..2c976db 100644 --- a/lustre/liblustre/namei.c +++ b/lustre/liblustre/namei.c @@ -130,7 +130,7 @@ void llu_lookup_finish_locks(struct lookup_intent *it, struct pnode *pnode) CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%llu/%lu)\n", inode, (long long)llu_i2stat(inode)->st_ino, llu_i2info(inode)->lli_st_generation); - mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode); + mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode, NULL); } /* drop lookup/getattr locks */ diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index e87a6b8..0aa0984 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -75,7 +75,6 @@ static void ll_release(struct dentry *de) EXIT; } -#ifdef DCACHE_LUSTRE_INVALID /* Compare if two dentries are the same. Don't match if the existing dentry * is marked DCACHE_LUSTRE_INVALID. Returns 1 if different, 0 if the same. * @@ -88,41 +87,41 @@ int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name) struct dentry *dchild; ENTRY; + /* XXX: d_name must be in-dentry structure */ + dchild = container_of(d_name, struct dentry, d_name); /* ugh */ + if (d_name->len != name->len) RETURN(1); if (memcmp(d_name->name, name->name, name->len)) RETURN(1); - /* XXX: d_name must be in-dentry structure */ - dchild = container_of(d_name, struct dentry, d_name); /* ugh */ - if (dchild->d_flags & DCACHE_LUSTRE_INVALID) { - CDEBUG(D_DENTRY,"INVALID dentry %p not matched, was bug 3784\n", - dchild); + CDEBUG(D_DENTRY,"found name %.*s(%p) - flags %d/%x - refc %d\n", + name->len, name->name, dchild, + d_mountpoint(dchild), dchild->d_flags & DCACHE_LUSTRE_INVALID, + atomic_read(&dchild->d_count)); + + /* mountpoint is always valid */ + if (d_mountpoint(dchild)) + RETURN(0); + + if (dchild->d_flags & DCACHE_LUSTRE_INVALID) RETURN(1); - } RETURN(0); } -#endif /* should NOT be called with the dcache lock, see fs/dcache.c */ static int ll_ddelete(struct dentry *de) { ENTRY; LASSERT(de); -#ifndef DCACHE_LUSTRE_INVALID -#define DCACHE_LUSTRE_INVALID 0 -#endif CDEBUG(D_DENTRY, "%s dentry %.*s (%p, parent %p, inode %p) %s%s\n", - (de->d_flags & DCACHE_LUSTRE_INVALID ? "deleting" : "keeping"), + (de->d_flags & DCACHE_LUSTRE_INVALID ? "hiden" : "keeping"), de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode, d_unhashed(de) ? "" : "hashed,", list_empty(&de->d_subdirs) ? "" : "subdirs"); -#if DCACHE_LUSTRE_INVALID == 0 -#undef DCACHE_LUSTRE_INVALID -#endif RETURN(0); } @@ -270,17 +269,6 @@ restart: "ino=%lu\n", dentry, inode, inode->i_ino); lustre_dump_dentry(dentry, 1); libcfs_debug_dumpstack(NULL); - } else if (d_mountpoint(dentry)) { - /* For mountpoints we skip removal of the dentry - which happens solely because we have a lock on it - obtained when this dentry was not a mountpoint yet */ - CDEBUG(D_DENTRY, "Skippind mountpoint dentry removal " - "%.*s (%p) parent %p\n", - dentry->d_name.len, - dentry->d_name.name, - dentry, dentry->d_parent); - - continue; } if (ll_drop_dentry(dentry)) @@ -319,7 +307,7 @@ void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry) struct inode *inode = dentry->d_inode; CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n", inode, inode->i_ino, inode->i_generation); - mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode); + mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode, NULL); } /* drop lookup or getattr locks immediately */ @@ -476,13 +464,6 @@ do_lock: if (rc != -ESTALE) { CDEBUG(D_INFO, "ll_intent_lock: rc %d : it->it_status " "%d\n", rc, it->d.lustre.it_status); - } else { -#ifndef HAVE_VFS_INTENT_PATCHES - if (it_disposition(it, DISP_OPEN_OPEN) && - !it_open_error(DISP_OPEN_OPEN, it)) - /* server have valid open - close file first*/ - ll_release_openhandle(de, it); -#endif } GOTO(out, rc = 0); } diff --git a/lustre/llite/file.c b/lustre/llite/file.c index f8718c3..dfdd142e 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -333,7 +333,7 @@ static int ll_intent_file_open(struct file *file, void *lmm, if (itp->d.lustre.it_lock_mode) mdc_set_lock_data(&itp->d.lustre.it_lock_handle, - inode); + inode, NULL); rc = ll_prep_inode(sbi->ll_osc_exp, &file->f_dentry->d_inode, req, DLM_REPLY_REC_OFF, NULL); @@ -535,7 +535,7 @@ restart: } mdc_set_lock_data(&it->d.lustre.it_lock_handle, - file->f_dentry->d_inode); + file->f_dentry->d_inode, NULL); goto restart; } diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 814a83d..530689e 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -70,6 +70,10 @@ struct lustre_intent_data { #define FMODE_EXEC 0 #endif +#ifndef DCACHE_LUSTRE_INVALID +#define DCACHE_LUSTRE_INVALID 0x100 +#endif + #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0") #define LUSTRE_FPRIVATE(file) ((file)->private_data) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index d8f58d8..4b3d794 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -241,9 +241,7 @@ void ll_free_sbi(struct super_block *sb) } static struct dentry_operations ll_d_root_ops = { -#ifdef DCACHE_LUSTRE_INVALID .d_compare = ll_dcompare, -#endif .d_revalidate = ll_revalidate_nd, }; diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index ba48874..3535efc 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -423,9 +423,6 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *de) dget_locked(dentry); lock_dentry(dentry); __d_drop(dentry); -#ifdef DCACHE_LUSTRE_INVALID - dentry->d_flags &= ~DCACHE_LUSTRE_INVALID; -#endif unlock_dentry(dentry); ll_dops_init(dentry, 0); d_rehash_cond(dentry, 0); /* avoid taking dcache_lock inside */ @@ -443,6 +440,7 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *de) "refc %d\n", last_discon, last_discon->d_inode, atomic_read(&last_discon->d_count)); dget_locked(last_discon); + last_discon->d_flags |= DCACHE_LUSTRE_INVALID; spin_unlock(&dcache_lock); spin_unlock(&ll_lookup_lock); ll_dops_init(last_discon, 1); @@ -452,6 +450,7 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *de) return last_discon; } + de->d_flags |= DCACHE_LUSTRE_INVALID; ll_d_add(de, inode); spin_unlock(&dcache_lock); @@ -475,6 +474,7 @@ int lookup_it_finish(struct ptlrpc_request *request, int offset, * when I return */ if (!it_disposition(it, DISP_LOOKUP_NEG)) { struct dentry *save = *de; + __u32 bits; rc = ll_prep_inode(sbi->ll_osc_exp, &inode, request, offset, (*de)->d_sb); @@ -483,7 +483,7 @@ int lookup_it_finish(struct ptlrpc_request *request, int offset, CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n", inode, inode->i_ino, inode->i_generation); - mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode); + mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode, &bits); /* We used to query real size from OSTs here, but actually this is not needed. For stat() calls size would be updated @@ -507,6 +507,12 @@ int lookup_it_finish(struct ptlrpc_request *request, int offset, lld->lld_sa_generation = 0; } } + /* we have lookup look - unhide dentry */ + if (bits & MDS_INODELOCK_LOOKUP) { + lock_dentry(*de); + (*de)->d_flags &= ~(DCACHE_LUSTRE_INVALID); + unlock_dentry(*de); + } } else { ll_dops_init(*de, 1); /* Check that parent has UPDATE lock. If there is none, we @@ -517,6 +523,12 @@ int lookup_it_finish(struct ptlrpc_request *request, int offset, ll_d_add(*de, inode); spin_unlock(&dcache_lock); } else { + /* negative lookup - and don't have update lock to + * parent */ + lock_dentry(*de); + (*de)->d_flags |= DCACHE_LUSTRE_INVALID; + unlock_dentry(*de); + (*de)->d_inode = NULL; /* We do not want to hash the dentry if don`t have a * lock, but if this dentry is later used in d_move, @@ -773,7 +785,7 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, * stuff it in the lock. */ CDEBUG(D_DLMTRACE, "setting l_ast_data to inode %p (%lu/%u)\n", inode, inode->i_ino, inode->i_generation); - mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode); + mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode, NULL); EXIT; out: ptlrpc_req_finished(request); diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index 492eeea..be0d57d 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -90,12 +90,15 @@ int it_open_error(int phase, struct lookup_intent *it) EXPORT_SYMBOL(it_open_error); /* this must be called on a lockh that is known to have a referenced lock */ -void mdc_set_lock_data(__u64 *l, void *data) +void mdc_set_lock_data(__u64 *l, void *data, __u32 *bits) { struct ldlm_lock *lock; struct lustre_handle *lockh = (struct lustre_handle *)l; ENTRY; + if(bits) + *bits = 0; + if (!*l) { EXIT; return; @@ -118,6 +121,8 @@ void mdc_set_lock_data(__u64 *l, void *data) } #endif lock->l_ast_data = data; + if (bits) + *bits = lock->l_policy_data.l_inodebits.bits; unlock_res_and_lock(lock); LDLM_LOCK_PUT(lock); -- 1.8.3.1