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

📄 file.c

📁 lustre 1.6.5 source code
💻 C
📖 第 1 页 / 共 2 页
字号:
        }        /* The MDS sent back the EA because we unlinked the last reference         * to this file. Use this EA to unlink the objects on the OST.         * It's opaque so we don't swab here; we leave it to obd_unpackmd() to         * check it is complete and sensible. */        eadata = lustre_swab_repbuf(request, REPLY_REC_OFF+1, body->eadatasize,                                    NULL);        LASSERT(eadata != NULL);        if (eadata == NULL) {                CERROR("Can't unpack MDS EA data\n");                GOTO(out, rc = -EPROTO);        }        rc = obd_unpackmd(llu_i2obdexp(dir), &lsm, eadata,body->eadatasize);        if (rc < 0) {                CERROR("obd_unpackmd: %d\n", rc);                GOTO(out, rc);        }        LASSERT(rc >= sizeof(*lsm));        OBDO_ALLOC(oa);        if (oa == NULL)                GOTO(out_free_memmd, rc = -ENOMEM);        oa->o_id = lsm->lsm_object_id;        oa->o_mode = body->mode & S_IFMT;        oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE;        if (body->valid & OBD_MD_FLCOOKIE) {                oa->o_valid |= OBD_MD_FLCOOKIE;                oti.oti_logcookies =                        lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF + 2,                                       sizeof(struct llog_cookie) *                                       lsm->lsm_stripe_count);                if (oti.oti_logcookies == NULL) {                        oa->o_valid &= ~OBD_MD_FLCOOKIE;                        body->valid &= ~OBD_MD_FLCOOKIE;                }        }        rc = obd_destroy(llu_i2obdexp(dir), oa, lsm, &oti, NULL);        OBDO_FREE(oa);        if (rc)                CERROR("obd destroy objid 0x"LPX64" error %d\n",                       lsm->lsm_object_id, rc); out_free_memmd:        obd_free_memmd(llu_i2obdexp(dir), &lsm); out:        return rc;}int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode){        struct llu_inode_info *lli = llu_i2info(inode);        struct intnl_stat *st = llu_i2stat(inode);        struct ll_file_data *fd = lli->lli_file_data;        struct ptlrpc_request *req = NULL;        struct obd_client_handle *och = &fd->fd_mds_och;        struct obdo obdo;        int rc, valid;        ENTRY;        /* clear group lock, if present */        if (fd->fd_flags & LL_FILE_GROUP_LOCKED) {                struct lov_stripe_md *lsm = llu_i2info(inode)->lli_smd;                fd->fd_flags &= ~(LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK);                rc = llu_extent_unlock(fd, inode, lsm, LCK_GROUP,                                       &fd->fd_cwlockh);        }        obdo.o_id = st->st_ino;        obdo.o_valid = OBD_MD_FLID;        valid = OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLSIZE |OBD_MD_FLBLOCKS |                OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME;        if (test_bit(LLI_F_HAVE_OST_SIZE_LOCK, &lli->lli_flags))                valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;        obdo_from_inode(&obdo, inode, valid);        if (0 /* ll_is_inode_dirty(inode) */) {                obdo.o_flags = MDS_BFLAG_UNCOMMITTED_WRITES;                obdo.o_valid |= OBD_MD_FLFLAGS;        }        rc = mdc_close(mdc_exp, &obdo, och, &req);        if (rc == EAGAIN) {                /* We are the last writer, so the MDS has instructed us to get                 * the file size and any write cookies, then close again. */                //ll_queue_done_writing(inode);                rc = 0;        } else if (rc) {                CERROR("inode %llu close failed: rc %d\n",                       (long long)st->st_ino, rc);        } else {                rc = llu_objects_destroy(req, inode);                if (rc)                        CERROR("inode %llu ll_objects destroy: rc = %d\n",                               (long long)st->st_ino, rc);        }        mdc_clear_open_replay_data(och);        ptlrpc_req_finished(req);        och->och_fh.cookie = DEAD_HANDLE_MAGIC;        lli->lli_file_data = NULL;        OBD_FREE(fd, sizeof(*fd));        RETURN(rc);}int llu_file_release(struct inode *inode){        struct ll_file_data *fd;        struct llu_sb_info *sbi = llu_i2sbi(inode);        struct llu_inode_info *lli = llu_i2info(inode);        int rc = 0, rc2;        ENTRY;        CDEBUG(D_VFSTRACE, "VFS Op:inode=%llu/%lu\n",               (long long)llu_i2stat(inode)->st_ino, lli->lli_st_generation);        if (llu_is_root_inode(inode))                RETURN(0);        /* still opened by others? */        if (--lli->lli_open_count)                RETURN(0);        fd = lli->lli_file_data;        if (!fd) /* no process opened the file after an mcreate */                RETURN(0);        rc2 = llu_mdc_close(sbi->ll_mdc_exp, inode);        if (rc2 && !rc)                rc = rc2;        RETURN(rc);}/* * libsysio require us return 0 */int llu_iop_close(struct inode *inode){        int rc;        struct ldlm_res_id res_id =                { .name = {llu_i2stat(inode)->st_ino,                 (__u64)llu_i2info(inode)->lli_st_generation, LDLM_FLOCK} };        struct lustre_handle lockh = {0};        liblustre_wait_event(0);        /* If we have posix locks on this file - clear all of those */        if (ldlm_lock_match(                      class_exp2obd(llu_i2mdcexp(inode))->obd_namespace,                      LDLM_FL_BLOCK_GRANTED|LDLM_FL_TEST_LOCK|LDLM_FL_CBPENDING,                      &res_id, LDLM_FLOCK, NULL, LCK_PR|LCK_PW, &lockh)) {                struct file_lock lock;                lock.fl_type = F_UNLCK;                lock.fl_flags = FL_POSIX;                lock.fl_start = 0;                lock.fl_end = OFFSET_MAX;                lock.fl_pid = getpid();                lock.fl_notify = NULL;                lock.fl_insert = NULL;                lock.fl_remove = NULL;                lock.fl_owner = NULL;                lock.fl_file = NULL;                llu_file_flock(inode, F_SETLK, &lock);        }        rc = llu_file_release(inode);        if (rc) {                CERROR("file close error %d\n", rc);        }        /* if open count == 0 && stale_flag is set, should we         * remove the inode immediately? */        liblustre_wait_idle();        return 0;}_SYSIO_OFF_T llu_iop_pos(struct inode *ino, _SYSIO_OFF_T off){        ENTRY;        liblustre_wait_event(0);        if (off < 0 || off > ll_file_maxbytes(ino))                RETURN(-EINVAL);        RETURN(off);}/* this isn't where truncate starts.  roughly: * llu_iop_{open,setattr}->llu_setattr_raw->llu_vmtruncate->llu_truncate * we grab the lock back in setattr_raw to avoid races. */static void llu_truncate(struct inode *inode, obd_flag flags){        struct llu_inode_info *lli = llu_i2info(inode);        struct intnl_stat *st = llu_i2stat(inode);        struct obd_info oinfo = { { { 0 } } };        struct obdo oa = { 0 };        int rc;        ENTRY;        CDEBUG(D_VFSTRACE, "VFS Op:inode=%llu/%lu(%p) to %llu\n",               (long long)st->st_ino, lli->lli_st_generation, inode,               (long long)st->st_size);        if (!lli->lli_smd) {                CDEBUG(D_INODE, "truncate on inode %llu with no objects\n",                       (long long)st->st_ino);                EXIT;                return;        }        oinfo.oi_md = lli->lli_smd;        oinfo.oi_policy.l_extent.start = st->st_size;        oinfo.oi_policy.l_extent.end = OBD_OBJECT_EOF;        oinfo.oi_oa = &oa;        oa.o_id = lli->lli_smd->lsm_object_id;        oa.o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS;        oa.o_flags = flags; /* We don't actually want to copy inode flags */         obdo_from_inode(&oa, inode,                        OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLATIME |                        OBD_MD_FLMTIME | OBD_MD_FLCTIME);        obd_adjust_kms(llu_i2obdexp(inode), lli->lli_smd, st->st_size, 1);        CDEBUG(D_INFO, "calling punch for "LPX64" (all bytes after %Lu)\n",               oa.o_id, (long long)st->st_size);        /* truncate == punch from new size to absolute end of file */        rc = obd_punch_rqset(llu_i2obdexp(inode), &oinfo, NULL);        if (rc)                CERROR("obd_truncate fails (%d) ino %llu\n",                       rc, (long long)st->st_ino);        else                obdo_to_inode(inode, &oa, OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |                                          OBD_MD_FLATIME | OBD_MD_FLMTIME |                                          OBD_MD_FLCTIME);        EXIT;        return;} /* llu_truncate */int llu_vmtruncate(struct inode * inode, loff_t offset, obd_flag flags){        llu_i2stat(inode)->st_size = offset;        /*         * llu_truncate() is only called from this         * point. llu_vmtruncate/llu_truncate split exists to mimic the         * structure of Linux VFS truncate code path.         */        llu_truncate(inode, flags);        return 0;}

⌨️ 快捷键说明

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