-/* Look up an entry by inode number. */
-/* this function ONLY returns valid dget'd dentries with an initialized inode
- or errors */
-struct dentry *mgs_fid2dentry(struct mgs_obd *mgs, struct ll_fid *fid,
- struct vfsmount **mnt)
-{
- unsigned long ino = fid->id;
- __u32 generation = fid->generation;
- struct mgs_open_llog *mollog, *n;
- struct list_head *llog_list = &mgs->mgs_open_llogs;
- struct inode *inode;
- struct dentry *result = NULL;
-
- if (ino == 0)
- RETURN(ERR_PTR(-ESTALE));
-
-
- CDEBUG(D_DENTRY, "--> mgs_fid2dentry: ino/gen %lu/%u, sb %p\n",
- ino, generation, mgs->mgs_sb);
-
- list_for_each_entry_safe(mollog, n, llog_list, mol_list) {
- if (mollog->mol_id == ino) {
- result = mollog->mol_dentry;
- dget(result);
- }
- }
-
- if (!result)
- RETURN(NULL);
-
- inode = result->d_inode;
- if (!inode)
- RETURN(ERR_PTR(-ENOENT));
-
- if (generation && inode->i_generation != generation) {
- /* we didn't find the right inode.. */
- CERROR("bad inode %lu, link: %lu ct: %d or generation %u/%u\n",
- inode->i_ino, (unsigned long)inode->i_nlink,
- atomic_read(&inode->i_count), inode->i_generation,
- generation);
- dput(result);
- RETURN(ERR_PTR(-ENOENT));
- }
-
- if (mnt) {
- *mnt = mgs->mgs_vfsmnt;
- mntget(*mnt);
- }
-
- RETURN(result);
-}
-
-static struct dentry *mgs_lvfs_fid2dentry(__u64 id, __u32 gen, __u64 gr,
- void *data)
-{
- struct obd_device *obd = data;
- struct ll_fid fid;
- fid.id = id;
- fid.generation = gen;
- return mgs_fid2dentry(&obd->u.mgs, &fid, NULL);
-}
-
-static int mgs_open_llog(__u64 id, void *data, void *handle)
-{
- struct obd_device *obd = data;
- struct mgs_update_llh *mul = handle;
- struct llog_handle *lgh = &mul->mul_lgh;
- struct dentry *dentry = lgh->lgh_file->f_dentry;
- __u64 id = dentry->d_inode->i_ino;
- struct mgs_obd *mgs = &obd->u.mgs;
- struct mgs_open_llog *mollog, *n;
- struct list_head *llog_list = &mgs->mgs_open_llogs;
-
- list_for_each_entry_safe(mollog, n, llog_list, mol_list) {
- if (mollog->mol_id == id) {
- spin_lock(&mollog->mol_lock);
- mollog->mol_ref++;
- spin_unlock(&mollog->mol_lock);
- dget(dentry);
- return 0;
- }
- }
-
- /* add a new open llog to mgs_open_llogs */
- OBD_ALLOC(mollog, sizeof(*mollog));
- if (!mollog) {
- CERROR("No memory for mollog.\n");
- return -ENOMEM;
- }
- mollog->mol_id = id;
- mollog->mol_dentry = dentry;
- mollog->mol_update = 0;
- mollog->mol_ref = 1;
- spin_lock_init(&mollog->mol_lock);
-
- spin_lock(&mgs->mgs_llogs_lock);
- list_add(&mollog->mol_list, &mgs->mgs_open_llogs);
- spin_unlock(&mgs->mgs_llogs_lock);
-
- lgh->
- return 0;
-}
-