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

📄 dir.c

📁 lustre 1.6.5 source code
💻 C
📖 第 1 页 / 共 3 页
字号:
                                RETURN(PTR_ERR(filename));                        rc = ll_lov_getstripe_ea_info(inode, filename, &lmm,                                                      &lmmsize, &request);                } else {                        rc = ll_dir_getstripe(inode, &lmm, &lmmsize, &request);                }                if (request) {                        body = lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF,                                              sizeof(*body));                        LASSERT(body != NULL); /* checked by mdc_getattr_name */                        /* swabbed by mdc_getattr_name */                        LASSERT(lustre_rep_swabbed(request, REPLY_REC_OFF));                } else {                        GOTO(out_req, rc);                }                if (rc < 0) {                        if (rc == -ENODATA && (cmd == IOC_MDC_GETFILEINFO ||                                               cmd == LL_IOC_MDC_GETINFO))                                GOTO(skip_lmm, rc = 0);                        else                                GOTO(out_req, rc);                }                if (cmd == IOC_MDC_GETFILESTRIPE ||                    cmd == LL_IOC_LOV_GETSTRIPE) {                        lump = (struct lov_user_md *)arg;                } else {                        struct lov_user_mds_data *lmdp;                        lmdp = (struct lov_user_mds_data *)arg;                        lump = &lmdp->lmd_lmm;                }                rc = copy_to_user(lump, lmm, lmmsize);                if (rc)                        GOTO(out_lmm, rc = -EFAULT);        skip_lmm:                if (cmd == IOC_MDC_GETFILEINFO || cmd == LL_IOC_MDC_GETINFO) {                        struct lov_user_mds_data *lmdp;                        lstat_t st = { 0 };                        st.st_dev     = inode->i_sb->s_dev;                        st.st_mode    = body->mode;                        st.st_nlink   = body->nlink;                        st.st_uid     = body->uid;                        st.st_gid     = body->gid;                        st.st_rdev    = body->rdev;                        st.st_size    = body->size;                        st.st_blksize = CFS_PAGE_SIZE;                        st.st_blocks  = body->blocks;                        st.st_atime   = body->atime;                        st.st_mtime   = body->mtime;                        st.st_ctime   = body->ctime;                        st.st_ino     = body->ino;                        lmdp = (struct lov_user_mds_data *)arg;                        rc = copy_to_user(&lmdp->lmd_st, &st, sizeof(st));                        if (rc)                                GOTO(out_lmm, rc = -EFAULT);                }                EXIT;        out_lmm:                if (lmm && lmm->lmm_magic == LOV_MAGIC_JOIN)                        OBD_FREE(lmm, lmmsize);        out_req:                ptlrpc_req_finished(request);                if (filename)                        putname(filename);                return rc;        }        case IOC_LOV_GETINFO: {                struct lov_user_mds_data *lumd;                struct lov_stripe_md *lsm;                struct lov_user_md *lum;                struct lov_mds_md *lmm;                int lmmsize;                lstat_t st;                int rc;                lumd = (struct lov_user_mds_data *)arg;                lum = &lumd->lmd_lmm;                rc = ll_get_max_mdsize(sbi, &lmmsize);                if (rc)                        RETURN(rc);                OBD_ALLOC(lmm, lmmsize);                rc = copy_from_user(lmm, lum, lmmsize);                if (rc)                        GOTO(free_lmm, rc = -EFAULT);                rc = obd_unpackmd(sbi->ll_osc_exp, &lsm, lmm, lmmsize);                if (rc < 0)                        GOTO(free_lmm, rc = -ENOMEM);                rc = obd_checkmd(sbi->ll_osc_exp, sbi->ll_mdc_exp, lsm);                if (rc)                        GOTO(free_lsm, rc);                /* Perform glimpse_size operation. */                memset(&st, 0, sizeof(st));                rc = ll_glimpse_ioctl(sbi, lsm, &st);                if (rc)                        GOTO(free_lsm, rc);                rc = copy_to_user(&lumd->lmd_st, &st, sizeof(st));                if (rc)                        GOTO(free_lsm, rc = -EFAULT);                EXIT;        free_lsm:                obd_free_memmd(sbi->ll_osc_exp, &lsm);        free_lmm:                OBD_FREE(lmm, lmmsize);                return rc;        }        case OBD_IOC_LLOG_CATINFO: {                struct ptlrpc_request *req = NULL;                char *buf = NULL;                int rc, len = 0;                char *bufs[3] = { NULL }, *str;                int lens[3] = { sizeof(struct ptlrpc_body) };                int size[2] = { sizeof(struct ptlrpc_body) };                rc = obd_ioctl_getdata(&buf, &len, (void *)arg);                if (rc)                        RETURN(rc);                data = (void *)buf;                if (!data->ioc_inlbuf1) {                        obd_ioctl_freedata(buf, len);                        RETURN(-EINVAL);                }                lens[REQ_REC_OFF] = data->ioc_inllen1;                bufs[REQ_REC_OFF] = data->ioc_inlbuf1;                if (data->ioc_inllen2) {                        lens[REQ_REC_OFF + 1] = data->ioc_inllen2;                        bufs[REQ_REC_OFF + 1] = data->ioc_inlbuf2;                } else {                        lens[REQ_REC_OFF + 1] = 0;                        bufs[REQ_REC_OFF + 1] = NULL;                }                req = ptlrpc_prep_req(sbi2mdc(sbi)->cl_import,                                      LUSTRE_LOG_VERSION, LLOG_CATINFO, 3, lens,                                      bufs);                if (!req)                        GOTO(out_catinfo, rc = -ENOMEM);                size[REPLY_REC_OFF] = data->ioc_plen1;                ptlrpc_req_set_repsize(req, 2, size);                rc = ptlrpc_queue_wait(req);                str = lustre_msg_string(req->rq_repmsg, REPLY_REC_OFF,                                        data->ioc_plen1);                if (!rc)                        rc = copy_to_user(data->ioc_pbuf1, str,data->ioc_plen1);                ptlrpc_req_finished(req);        out_catinfo:                obd_ioctl_freedata(buf, len);                RETURN(rc);        }        case OBD_IOC_QUOTACHECK: {                struct obd_quotactl *oqctl;                int rc, error = 0;                if (!capable(CAP_SYS_ADMIN))                        RETURN(-EPERM);                OBD_ALLOC_PTR(oqctl);                if (!oqctl)                        RETURN(-ENOMEM);                oqctl->qc_type = arg;                rc = obd_quotacheck(sbi->ll_mdc_exp, oqctl);                if (rc < 0) {                        CDEBUG(D_INFO, "mdc_quotacheck failed: rc %d\n", rc);                        error = rc;                }                rc = obd_quotacheck(sbi->ll_osc_exp, oqctl);                if (rc < 0)                        CDEBUG(D_INFO, "osc_quotacheck failed: rc %d\n", rc);                OBD_FREE_PTR(oqctl);                return error ?: rc;        }        case OBD_IOC_POLL_QUOTACHECK: {                struct if_quotacheck *check;                int rc;                if (!capable(CAP_SYS_ADMIN))                        RETURN(-EPERM);                OBD_ALLOC_PTR(check);                if (!check)                        RETURN(-ENOMEM);                rc = obd_iocontrol(cmd, sbi->ll_mdc_exp, 0, (void *)check,                                   NULL);                if (rc) {                        CDEBUG(D_QUOTA, "mdc ioctl %d failed: %d\n", cmd, rc);                        if (copy_to_user((void *)arg, check, sizeof(*check)))                                rc = -EFAULT;                        GOTO(out_poll, rc);                }                rc = obd_iocontrol(cmd, sbi->ll_osc_exp, 0, (void *)check,                                   NULL);                if (rc) {                        CDEBUG(D_QUOTA, "osc ioctl %d failed: %d\n", cmd, rc);                        if (copy_to_user((void *)arg, check, sizeof(*check)))                                rc = -EFAULT;                        GOTO(out_poll, rc);                }        out_poll:                OBD_FREE_PTR(check);                RETURN(rc);        }#ifdef HAVE_QUOTA_SUPPORT        case OBD_IOC_QUOTACTL: {                struct if_quotactl *qctl;                struct obd_quotactl *oqctl;                int cmd, type, id, rc = 0;                OBD_ALLOC_PTR(qctl);                if (!qctl)                        RETURN(-ENOMEM);                OBD_ALLOC_PTR(oqctl);                if (!oqctl) {                        OBD_FREE_PTR(qctl);                        RETURN(-ENOMEM);                }                if (copy_from_user(qctl, (void *)arg, sizeof(*qctl)))                        GOTO(out_quotactl, rc = -EFAULT);                cmd = qctl->qc_cmd;                type = qctl->qc_type;                id = qctl->qc_id;                switch (cmd) {                case LUSTRE_Q_INVALIDATE:                case Q_QUOTAON:                case Q_QUOTAOFF:                case Q_SETQUOTA:                case Q_SETINFO:                        if (!capable(CAP_SYS_ADMIN))                                GOTO(out_quotactl, rc = -EPERM);                        break;                case Q_GETQUOTA:                        if (((type == USRQUOTA && current->euid != id) ||                             (type == GRPQUOTA && !in_egroup_p(id))) &&                            !capable(CAP_SYS_ADMIN))                                GOTO(out_quotactl, rc = -EPERM);                        /* XXX: dqb_valid is borrowed as a flag to mark that                         *      only mds quota is wanted */                        if (qctl->qc_dqblk.dqb_valid) {                                qctl->obd_uuid = sbi->ll_mdc_exp->exp_obd->                                                        u.cli.cl_target_uuid;                                qctl->qc_dqblk.dqb_valid = 0;                        }                        break;                case Q_GETINFO:                        break;                default:                        CERROR("unsupported quotactl op: %#x\n", cmd);                        GOTO(out_quotactl, -ENOTTY);                }                QCTL_COPY(oqctl, qctl);                if (qctl->obd_uuid.uuid[0]) {                        struct obd_device *obd;                        struct obd_uuid *uuid = &qctl->obd_uuid;                        obd = class_find_client_notype(uuid,                                         &sbi->ll_osc_exp->exp_obd->obd_uuid);                        if (!obd)                                GOTO(out_quotactl, rc = -ENOENT);                        if (cmd == Q_GETINFO)                                oqctl->qc_cmd = Q_GETOINFO;                        else if (cmd == Q_GETQUOTA)                                oqctl->qc_cmd = Q_GETOQUOTA;                        else                                GOTO(out_quotactl, rc = -EINVAL);                        if (sbi->ll_mdc_exp->exp_obd == obd) {                                rc = obd_quotactl(sbi->ll_mdc_exp, oqctl);                        } else {                                int i;                                struct obd_export *exp;                                struct lov_obd *lov = &sbi->ll_osc_exp->                                                            exp_obd->u.lov;                                for (i = 0; i < lov->desc.ld_tgt_count; i++) {                                        if (!lov->lov_tgts[i] ||                                            !lov->lov_tgts[i]->ltd_active)                                                continue;                                        exp = lov->lov_tgts[i]->ltd_exp;                                        if (exp->exp_obd == obd) {                                                rc = obd_quotactl(exp, oqctl);                                                break;                                        }                                }                        }                        oqctl->qc_cmd = cmd;                        QCTL_COPY(qctl, oqctl);                        if (copy_to_user((void *)arg, qctl, sizeof(*qctl)))                                rc = -EFAULT;                        GOTO(out_quotactl, rc);                }                rc = obd_quotactl(sbi->ll_mdc_exp, oqctl);                if (rc && rc != -EBUSY && cmd == Q_QUOTAON) {                        oqctl->qc_cmd = Q_QUOTAOFF;                        obd_quotactl(sbi->ll_mdc_exp, oqctl);                }                QCTL_COPY(qctl, oqctl);                if (copy_to_user((void *)arg, qctl, sizeof(*qctl)))                        rc = -EFAULT;        out_quotactl:                OBD_FREE_PTR(qctl);                OBD_FREE_PTR(oqctl);                RETURN(rc);        }#endif /* HAVE_QUOTA_SUPPORT */        case OBD_IOC_GETNAME_OLD:        case OBD_IOC_GETNAME: {                struct obd_device *obd = class_exp2obd(sbi->ll_osc_exp);                if (!obd)                        RETURN(-EFAULT);                if (copy_to_user((void *)arg, obd->obd_name,                                strlen(obd->obd_name) + 1))                        RETURN (-EFAULT);                RETURN(0);        }        default:                RETURN(obd_iocontrol(cmd, sbi->ll_osc_exp,0,NULL,(void *)arg));        }}struct file_operations ll_dir_operations = {        .open     = ll_file_open,        .release  = ll_file_release,        .read     = generic_read_dir,        .readdir  = ll_readdir,        .ioctl    = ll_dir_ioctl};

⌨️ 快捷键说明

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