⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 namei.c

📁 lustre 1.6.5 source code
💻 C
📖 第 1 页 / 共 2 页
字号:
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * * Lustre Light name resolution * *  Copyright (c) 2002-2004 Cluster File Systems, Inc. * *   This file is part of Lustre, http://www.lustre.org. * *   Lustre is free software; you can redistribute it and/or *   modify it under the terms of version 2 of the GNU General Public *   License as published by the Free Software Foundation. * *   Lustre is distributed in the hope that it will be useful, *   but WITHOUT ANY WARRANTY; without even the implied warranty of *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *   GNU General Public License for more details. * *   You should have received a copy of the GNU General Public License *   along with Lustre; if not, write to the Free Software *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#define DEBUG_SUBSYSTEM S_LLITE#include <stdlib.h>#include <string.h>#include <assert.h>#include <time.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <sys/queue.h>#include <sysio.h>#ifdef HAVE_XTIO_H#include <xtio.h>#endif#include <fs.h>#include <mount.h>#include <inode.h>#ifdef HAVE_FILE_H#include <file.h>#endif#undef LIST_HEAD#include "llite_lib.h"void ll_intent_drop_lock(struct lookup_intent *it){        struct lustre_handle *handle;        if (it->it_op && it->d.lustre.it_lock_mode) {                handle = (struct lustre_handle *)&it->d.lustre.it_lock_handle;                CDEBUG(D_DLMTRACE, "releasing lock with cookie "LPX64                       " from it %p\n", handle->cookie, it);                ldlm_lock_decref(handle, it->d.lustre.it_lock_mode);                /* bug 494: intent_release may be called multiple times, from                 * this thread and we don't want to double-decref this lock */                it->d.lustre.it_lock_mode = 0;        }}void ll_intent_release(struct lookup_intent *it){        ENTRY;        ll_intent_drop_lock(it);        it->it_magic = 0;        it->it_op_release = 0;        it->d.lustre.it_disposition = 0;        it->d.lustre.it_data = NULL;        EXIT;}#if 0/* * remove the stale inode from pnode */void unhook_stale_inode(struct pnode *pno){        struct inode *inode = pno->p_base->pb_ino;        ENTRY;        LASSERT(inode);        LASSERT(llu_i2info(inode)->lli_stale_flag);        pno->p_base->pb_ino = NULL;        I_RELE(inode);        if (!llu_i2info(inode)->lli_open_count) {                CDEBUG(D_INODE, "unhook inode %p (ino %lu) from pno %p\n",                                inode, llu_i2info(inode)->lli_st_ino, pno);                if (!inode->i_ref)                        _sysio_i_gone(inode);        }        EXIT;        return;}#endifvoid llu_lookup_finish_locks(struct lookup_intent *it, struct pnode *pnode){        struct inode *inode;        LASSERT(it);        LASSERT(pnode);        inode = pnode->p_base->pb_ino;        if (it->d.lustre.it_lock_mode && inode != NULL) {                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);        }        /* drop lookup/getattr locks */        if (it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR)                ll_intent_release(it);}static inline void llu_invalidate_inode_pages(struct inode * inode){        /* do nothing */}int llu_mdc_blocking_ast(struct ldlm_lock *lock,                         struct ldlm_lock_desc *desc,                         void *data, int flag){        int rc;        struct lustre_handle lockh;        ENTRY;        switch (flag) {        case LDLM_CB_BLOCKING:                ldlm_lock2handle(lock, &lockh);                rc = ldlm_cli_cancel(&lockh);                if (rc < 0) {                        CDEBUG(D_INODE, "ldlm_cli_cancel: %d\n", rc);                        RETURN(rc);                }                break;        case LDLM_CB_CANCELING: {                struct inode *inode = llu_inode_from_lock(lock);                struct llu_inode_info *lli;                struct intnl_stat *st;                __u64 bits = lock->l_policy_data.l_inodebits.bits;                /* Invalidate all dentries associated with this inode */                if (inode == NULL)                        break;                lli =  llu_i2info(inode);                st = llu_i2stat(inode);                if (bits & MDS_INODELOCK_UPDATE)                        clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);                if (lock->l_resource->lr_name.name[0] != st->st_ino ||                    lock->l_resource->lr_name.name[1] !=lli->lli_st_generation){                        LDLM_ERROR(lock, "data mismatch with ino %llu/%lu",                                  (long long)st->st_ino,lli->lli_st_generation);                }                if (S_ISDIR(st->st_mode) &&                    (bits & MDS_INODELOCK_UPDATE)) {                        CDEBUG(D_INODE, "invalidating inode %llu\n",                               (long long)st->st_ino);                        llu_invalidate_inode_pages(inode);                }/*                if (inode->i_sb->s_root &&                    inode != inode->i_sb->s_root->d_inode)                        ll_unhash_aliases(inode);*/                I_RELE(inode);                break;        }        default:                LBUG();        }        RETURN(0);}static int pnode_revalidate_finish(struct ptlrpc_request *req,                                   int offset,                                   struct lookup_intent *it,                                   struct pnode *pnode){        struct inode *inode = pnode->p_base->pb_ino;        struct lustre_md md;        int rc = 0;        ENTRY;        LASSERT(inode);        if (!req)                RETURN(0);        if (it_disposition(it, DISP_LOOKUP_NEG))                RETURN(-ENOENT);        rc = mdc_req2lustre_md(req, offset, llu_i2sbi(inode)->ll_osc_exp, &md);        if (rc)                RETURN(rc);        llu_update_inode(inode, md.body, md.lsm);        RETURN(rc);}static int llu_pb_revalidate(struct pnode *pnode, int flags,                             struct lookup_intent *it){        struct pnode_base *pb = pnode->p_base;        struct it_cb_data icbd;        struct mdc_op_data op_data;        struct ptlrpc_request *req = NULL;        struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };        struct obd_export *exp;        int rc;        ENTRY;        CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,intent=%x\n",               (int)pb->pb_name.len, pb->pb_name.name, it ? it->it_op : 0);        /* We don't want to cache negative dentries, so return 0 immediately.         * We believe that this is safe, that negative dentries cannot be         * pinned by someone else */        if (pb->pb_ino == NULL) {                CDEBUG(D_INODE, "negative pb\n");                RETURN(0);        }        /* This is due to bad interaction with libsysio. remove this when we         * switched to libbsdio XXX         */        {                struct llu_inode_info *lli = llu_i2info(pb->pb_ino);                struct intnl_stat *st = llu_i2stat(pb->pb_ino);                if (lli->lli_it) {                        CDEBUG(D_INODE, "inode %llu still have intent "                                        "%p(opc 0x%x), release it\n",                                        (long long) st->st_ino, lli->lli_it,                                        lli->lli_it->it_op);                        ll_intent_release(lli->lli_it);                        OBD_FREE(lli->lli_it, sizeof(*lli->lli_it));                        lli->lli_it = NULL;                }        }        exp = llu_i2mdcexp(pb->pb_ino);        icbd.icbd_parent = pnode->p_parent->p_base->pb_ino;        icbd.icbd_child = pnode;        if (!it) {                it = &lookup_it;                it->it_op_release = ll_intent_release;        }        llu_prepare_mdc_op_data(&op_data, pnode->p_parent->p_base->pb_ino,                                pb->pb_ino, pb->pb_name.name,pb->pb_name.len,0);        rc = mdc_intent_lock(exp, &op_data, NULL, 0, it, flags,                             &req, llu_mdc_blocking_ast,                             LDLM_FL_CANCEL_ON_BLOCK);        /* If req is NULL, then mdc_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)                GOTO(out, rc);        if (rc < 0)                GOTO(out, rc = 0);        rc = pnode_revalidate_finish(req, DLM_REPLY_REC_OFF, it, pnode);        if (rc != 0) {                ll_intent_release(it);                GOTO(out, rc = 0);        }        rc = 1;        /* Note: ll_intent_lock may cause a callback, check this! */        if (it->it_op & IT_OPEN)                LL_SAVE_INTENT(pb->pb_ino, it); out:        if (req && rc == 1)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -