X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdc%2Fmdc_lib.c;h=1e4bc75a6dfb27a95f60e3bccdebdfd7087b005d;hb=864c1cef52710ce1980f32592bd1af364c6a75ed;hp=de09e61b149de6c61196e6b6804a41b6361d4bd2;hpb=fd908da92ccd9aab4ffc3d2463301831260c0474;p=fs%2Flustre-release.git diff --git a/lustre/mdc/mdc_lib.c b/lustre/mdc/mdc_lib.c index de09e61..1e4bc75 100644 --- a/lustre/mdc/mdc_lib.c +++ b/lustre/mdc/mdc_lib.c @@ -1,25 +1,37 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * Copyright (c) 2003 Cluster File Systems, Inc. + * GPL HEADER START * - * This file is part of the Lustre file system, http://www.lustre.org - * Lustre is a trademark of Cluster File Systems, Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * You may have signed or agreed to another license before downloading - * this software. If so, you are bound by the terms and conditions - * of that agreement, and the following does not apply to you. See the - * LICENSE file included with this distribution for more information. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. * - * If you did not agree to a different license, then this copy of Lustre - * is open source 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. + * This program 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 version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). * - * In either case, 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 - * license text for more details. + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + * GPL HEADER END + */ +/* + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. */ #define DEBUG_SUBSYSTEM S_MDC @@ -27,8 +39,8 @@ # include # include #endif -#include #include +#include #include "mdc_internal.h" #ifndef __KERNEL__ @@ -43,11 +55,11 @@ static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid) LASSERT (b != NULL); b->suppgid = suppgid; - b->uid = current->uid; - b->gid = current->gid; - b->fsuid = current->fsuid; - b->fsgid = current->fsgid; - b->capability = current->cap_effective; + b->uid = cfs_curproc_uid(); + b->gid = cfs_curproc_gid(); + b->fsuid = cfs_curproc_fsuid(); + b->fsgid = cfs_curproc_fsgid(); + b->capability = cfs_curproc_cap_pack(); } void mdc_pack_capa(struct ptlrpc_request *req, const struct req_msg_field *field, @@ -110,13 +122,15 @@ void mdc_readdir_pack(struct ptlrpc_request *req, __u64 pgoff, b->size = pgoff; /* !! */ b->nlink = size; /* !! */ __mdc_pack_body(b, -1); + b->mode = LUDA_FID | LUDA_TYPE; + mdc_pack_capa(req, &RMF_CAPA1, oc); } /* packing of MDS records */ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data, const void *data, int datalen, __u32 mode, - __u32 uid, __u32 gid, __u32 cap_effective, __u64 rdev) + __u32 uid, __u32 gid, cfs_cap_t cap_effective, __u64 rdev) { struct mdt_rec_create *rec; char *tmp; @@ -136,7 +150,7 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data, rec->cr_time = op_data->op_mod_time; rec->cr_suppgid1 = op_data->op_suppgids[0]; rec->cr_suppgid2 = op_data->op_suppgids[1]; - rec->cr_flags = op_data->op_flags & ~MF_SOM_LOCAL_FLAGS; + rec->cr_flags = op_data->op_flags & MF_SOM_LOCAL_FLAGS; rec->cr_bias = op_data->op_bias; mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1); @@ -150,7 +164,7 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data, } } -static __u32 mds_pack_open_flags(__u32 flags) +static __u32 mds_pack_open_flags(__u32 flags, __u32 mode) { __u32 cr_flags = (flags & (FMODE_READ | FMODE_WRITE | MDS_OPEN_HAS_EA | MDS_OPEN_HAS_OBJS | @@ -167,8 +181,6 @@ static __u32 mds_pack_open_flags(__u32 flags) cr_flags |= MDS_OPEN_SYNC; if (flags & O_DIRECTORY) cr_flags |= MDS_OPEN_DIRECTORY; - if (flags & O_JOIN_FILE) - cr_flags |= MDS_OPEN_JOIN_FILE; #ifdef FMODE_EXEC if (flags & FMODE_EXEC) cr_flags |= MDS_FMODE_EXEC; @@ -180,18 +192,6 @@ static __u32 mds_pack_open_flags(__u32 flags) } /* packing of MDS records */ -void mdc_join_pack(struct ptlrpc_request *req, - struct md_op_data *op_data, - __u64 head_size) -{ - struct mdt_rec_join *rec; - - rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_JOINFILE); - LASSERT(rec != NULL); - rec->jr_fid = op_data->op_fid2; - rec->jr_headsize = head_size; -} - void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data, __u32 mode, __u64 rdev, __u32 flags, const void *lmm, int lmmlen) @@ -204,15 +204,15 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data, /* XXX do something about time, uid, gid */ rec->cr_opcode = REINT_OPEN; - rec->cr_fsuid = current->fsuid; - rec->cr_fsgid = current->fsgid; - rec->cr_cap = current->cap_effective; + rec->cr_fsuid = cfs_curproc_fsuid(); + rec->cr_fsgid = cfs_curproc_fsgid(); + rec->cr_cap = cfs_curproc_cap_pack(); if (op_data != NULL) { rec->cr_fid1 = op_data->op_fid1; rec->cr_fid2 = op_data->op_fid2; } rec->cr_mode = mode; - rec->cr_flags = mds_pack_open_flags(flags); + rec->cr_flags = mds_pack_open_flags(flags, mode); rec->cr_rdev = rdev; rec->cr_time = op_data->op_mod_time; rec->cr_suppgid1 = op_data->op_suppgids[0]; @@ -284,9 +284,9 @@ static void mdc_setattr_pack_rec(struct mdt_rec_setattr *rec, struct md_op_data *op_data) { rec->sa_opcode = REINT_SETATTR; - rec->sa_fsuid = current->fsuid; - rec->sa_fsgid = current->fsgid; - rec->sa_cap = current->cap_effective; + rec->sa_fsuid = cfs_curproc_fsuid(); + rec->sa_fsgid = cfs_curproc_fsgid(); + rec->sa_cap = cfs_curproc_cap_pack(); rec->sa_suppgid = -1; rec->sa_fid = op_data->op_fid1; @@ -301,24 +301,26 @@ static void mdc_setattr_pack_rec(struct mdt_rec_setattr *rec, rec->sa_ctime = LTIME_S(op_data->op_attr.ia_ctime); rec->sa_attr_flags = ((struct ll_iattr *)&op_data->op_attr)->ia_attr_flags; if ((op_data->op_attr.ia_valid & ATTR_GID) && - in_group_p(op_data->op_attr.ia_gid)) + cfs_curproc_is_in_groups(op_data->op_attr.ia_gid)) rec->sa_suppgid = op_data->op_attr.ia_gid; else rec->sa_suppgid = op_data->op_suppgids[0]; } -static void mdc_epoch_pack(struct mdt_epoch *epoch, struct md_op_data *op_data) +static void mdc_ioepoch_pack(struct mdt_ioepoch *epoch, + struct md_op_data *op_data) { memcpy(&epoch->handle, &op_data->op_handle, sizeof(epoch->handle)); epoch->ioepoch = op_data->op_ioepoch; - epoch->flags = op_data->op_flags & ~MF_SOM_LOCAL_FLAGS; + epoch->flags = op_data->op_flags & MF_SOM_LOCAL_FLAGS; } void mdc_setattr_pack(struct ptlrpc_request *req, struct md_op_data *op_data, void *ea, int ealen, void *ea2, int ea2len) { struct mdt_rec_setattr *rec; - struct mdt_epoch *epoch; + struct mdt_ioepoch *epoch; + struct lov_user_md *lum = NULL; CLASSERT(sizeof(struct mdt_rec_reint) ==sizeof(struct mdt_rec_setattr)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); @@ -328,13 +330,21 @@ void mdc_setattr_pack(struct ptlrpc_request *req, struct md_op_data *op_data, if (op_data->op_flags & (MF_SOM_CHANGE | MF_EPOCH_OPEN)) { epoch = req_capsule_client_get(&req->rq_pill, &RMF_MDT_EPOCH); - mdc_epoch_pack(epoch, op_data); + mdc_ioepoch_pack(epoch, op_data); } if (ealen == 0) return; - memcpy(req_capsule_client_get(&req->rq_pill, &RMF_EADATA), ea, ealen); + lum = req_capsule_client_get(&req->rq_pill, &RMF_EADATA); + if (ea == NULL) { /* Remove LOV EA */ + lum->lmm_magic = LOV_USER_MAGIC_V1; + lum->lmm_stripe_size = 0; + lum->lmm_stripe_count = 0; + lum->lmm_stripe_offset = (typeof(lum->lmm_stripe_offset))(-1); + } else { + memcpy(lum, ea, ealen); + } if (ea2len == 0) return; @@ -438,15 +448,15 @@ void mdc_getattr_pack(struct ptlrpc_request *req, __u64 valid, int flags, struct mdt_body *b = req_capsule_client_get(&req->rq_pill, &RMF_MDT_BODY); - b->fsuid = current->fsuid; - b->fsgid = current->fsgid; - b->capability = current->cap_effective; + b->fsuid = cfs_curproc_fsuid(); + b->fsgid = cfs_curproc_fsgid(); + b->capability = cfs_curproc_cap_pack(); b->valid = valid; if (op_data->op_bias & MDS_CHECK_SPLIT) b->valid |= OBD_MD_FLCKSPLIT; if (op_data->op_bias & MDS_CROSS_REF) b->valid |= OBD_MD_FLCROSSREF; - b->flags = flags | MDS_BFLAG_EXT_FLAGS; + b->flags = flags; b->suppgid = op_data->op_suppgids[0]; b->fid1 = op_data->op_fid1; @@ -458,12 +468,13 @@ void mdc_getattr_pack(struct ptlrpc_request *req, __u64 valid, int flags, if (op_data->op_name) { char *tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME); LOGL0(op_data->op_name, op_data->op_namelen, tmp); + } } void mdc_close_pack(struct ptlrpc_request *req, struct md_op_data *op_data) { - struct mdt_epoch *epoch; + struct mdt_ioepoch *epoch; struct mdt_rec_setattr *rec; epoch = req_capsule_client_get(&req->rq_pill, &RMF_MDT_EPOCH); @@ -471,16 +482,16 @@ void mdc_close_pack(struct ptlrpc_request *req, struct md_op_data *op_data) mdc_setattr_pack_rec(rec, op_data); mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1); - mdc_epoch_pack(epoch, op_data); + mdc_ioepoch_pack(epoch, op_data); } static int mdc_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw) { int rc; ENTRY; - spin_lock(&cli->cl_loi_list_lock); - rc = list_empty(&mcw->mcw_entry); - spin_unlock(&cli->cl_loi_list_lock); + client_obd_list_lock(&cli->cl_loi_list_lock); + rc = cfs_list_empty(&mcw->mcw_entry); + client_obd_list_unlock(&cli->cl_loi_list_lock); RETURN(rc); }; @@ -492,38 +503,38 @@ void mdc_enter_request(struct client_obd *cli) struct mdc_cache_waiter mcw; struct l_wait_info lwi = { 0 }; - spin_lock(&cli->cl_loi_list_lock); + client_obd_list_lock(&cli->cl_loi_list_lock); if (cli->cl_r_in_flight >= cli->cl_max_rpcs_in_flight) { - list_add_tail(&mcw.mcw_entry, &cli->cl_cache_waiters); - init_waitqueue_head(&mcw.mcw_waitq); - spin_unlock(&cli->cl_loi_list_lock); + cfs_list_add_tail(&mcw.mcw_entry, &cli->cl_cache_waiters); + cfs_waitq_init(&mcw.mcw_waitq); + client_obd_list_unlock(&cli->cl_loi_list_lock); l_wait_event(mcw.mcw_waitq, mdc_req_avail(cli, &mcw), &lwi); } else { cli->cl_r_in_flight++; - spin_unlock(&cli->cl_loi_list_lock); + client_obd_list_unlock(&cli->cl_loi_list_lock); } } void mdc_exit_request(struct client_obd *cli) { - struct list_head *l, *tmp; + cfs_list_t *l, *tmp; struct mdc_cache_waiter *mcw; - spin_lock(&cli->cl_loi_list_lock); + client_obd_list_lock(&cli->cl_loi_list_lock); cli->cl_r_in_flight--; - list_for_each_safe(l, tmp, &cli->cl_cache_waiters) { + cfs_list_for_each_safe(l, tmp, &cli->cl_cache_waiters) { if (cli->cl_r_in_flight >= cli->cl_max_rpcs_in_flight) { /* No free request slots anymore */ break; } - mcw = list_entry(l, struct mdc_cache_waiter, mcw_entry); - list_del_init(&mcw->mcw_entry); + mcw = cfs_list_entry(l, struct mdc_cache_waiter, mcw_entry); + cfs_list_del_init(&mcw->mcw_entry); cli->cl_r_in_flight++; - wake_up(&mcw->mcw_waitq); + cfs_waitq_signal(&mcw->mcw_waitq); } /* Empty waiting list? Decrease reqs in-flight number */ - spin_unlock(&cli->cl_loi_list_lock); + client_obd_list_unlock(&cli->cl_loi_list_lock); }