From c39489126f88bb5b30643ebb11c72fbe9f9d2241 Mon Sep 17 00:00:00 2001 From: yury Date: Sun, 24 Oct 2004 17:05:37 +0000 Subject: [PATCH] - unland b_fid to HEAD --- lnet/include/linux/kp30.h | 9 - lnet/include/linux/libcfs.h | 7 - lnet/klnds/qswlnd/qswlnd.h | 1 - lnet/utils/portals.c | 11 +- lustre/cmobd/Makefile.in | 4 +- lustre/cmobd/Makefile.mk | 4 +- lustre/cmobd/autoMakefile.am | 2 +- lustre/cmobd/cache_manager_obd.c | 215 +++ lustre/cmobd/cm_internal.h | 33 - lustre/cmobd/cm_mds_reint.c | 377 ----- lustre/cmobd/cm_obd.c | 319 ----- lustre/cmobd/cmobd_internal.h | 28 + lustre/cmobd/cmobd_mds_reint.c | 184 +++ lustre/cmobd/{cm_oss_reint.c => cmobd_oss_reint.c} | 71 +- lustre/cmobd/{cm_reint.c => cmobd_reint.c} | 63 +- lustre/cmobd/{cm_write.c => cmobd_write.c} | 78 +- lustre/cobd/cache_obd.c | 212 +-- lustre/cobd/lproc_cache.c | 4 +- lustre/include/liblustre.h | 8 +- lustre/include/linux/lustre_fsfilt.h | 57 +- lustre/include/linux/lustre_idl.h | 208 ++- lustre/include/linux/lustre_lib.h | 9 - lustre/include/linux/lustre_lite.h | 35 +- lustre/include/linux/lustre_mds.h | 110 +- lustre/include/linux/lustre_net.h | 77 +- lustre/include/linux/lustre_smfs.h | 19 +- lustre/include/linux/lvfs.h | 33 +- lustre/include/linux/lvfs_linux.h | 2 +- lustre/include/linux/obd.h | 181 ++- lustre/include/linux/obd_class.h | 87 +- lustre/include/linux/obd_lmv.h | 1 + .../kernel_patches/patches/ext3-dentry-fid.patch | 52 - .../patches/kksymoops-2.4.24.vanilla.patch | 2 +- lustre/kernel_patches/series/vanilla-2.4.24 | 1 - lustre/ldlm/ldlm_lib.c | 13 +- lustre/liblustre/dir.c | 17 +- lustre/liblustre/file.c | 21 +- lustre/liblustre/llite_lib.c | 7 +- lustre/liblustre/llite_lib.h | 40 +- lustre/liblustre/namei.c | 50 +- lustre/liblustre/rw.c | 11 +- lustre/liblustre/super.c | 299 ++-- lustre/llite/dcache.c | 48 +- lustre/llite/dir.c | 68 +- lustre/llite/file.c | 89 +- lustre/llite/llite_internal.h | 38 +- lustre/llite/llite_lib.c | 361 +++-- lustre/llite/llite_nfs.c | 14 +- lustre/llite/namei.c | 123 +- lustre/llite/rw.c | 9 +- lustre/llite/special.c | 4 +- lustre/llite/symlink.c | 9 +- lustre/lmv/lmv_intent.c | 344 ++--- lustre/lmv/lmv_internal.h | 62 +- lustre/lmv/lmv_obd.c | 621 ++++----- lustre/lmv/lmv_objmgr.c | 112 +- lustre/lov/lov_obd.c | 36 +- lustre/lvfs/fsfilt_ext3.c | 230 ++- lustre/lvfs/fsfilt_smfs.c | 97 +- lustre/lvfs/llog_lvfs.c | 64 +- lustre/lvfs/lvfs_common.c | 8 +- lustre/mdc/mdc_internal.h | 2 +- lustre/mdc/mdc_lib.c | 15 +- lustre/mdc/mdc_locks.c | 131 +- lustre/mdc/mdc_reint.c | 36 +- lustre/mdc/mdc_request.c | 204 +-- lustre/mds/handler.c | 1089 +++++---------- lustre/mds/mds_fs.c | 305 +--- lustre/mds/mds_groups.c | 32 +- lustre/mds/mds_internal.h | 61 +- lustre/mds/mds_lib.c | 128 +- lustre/mds/mds_lmv.c | 235 +--- lustre/mds/mds_log.c | 19 +- lustre/mds/mds_lov.c | 67 +- lustre/mds/mds_open.c | 282 ++-- lustre/mds/mds_reint.c | 990 +++++-------- lustre/mds/mds_unlink_open.c | 10 +- lustre/obdclass/genops.c | 14 +- lustre/obdclass/lprocfs_status.c | 10 +- lustre/obdclass/mea.c | 1 + lustre/obdclass/obd_config.c | 27 +- lustre/obdecho/echo.c | 1 + lustre/obdfilter/filter.c | 30 +- lustre/obdfilter/filter_internal.h | 8 +- lustre/obdfilter/filter_io.c | 13 +- lustre/obdfilter/filter_log.c | 5 +- lustre/osc/osc_request.c | 12 +- lustre/portals/include/linux/kp30.h | 9 - lustre/portals/include/linux/libcfs.h | 7 - lustre/portals/knals/qswnal/qswnal.h | 1 - lustre/portals/utils/portals.c | 11 +- lustre/ptlbd/client.c | 4 +- lustre/ptlrpc/import.c | 7 +- lustre/ptlrpc/pack_generic.c | 1474 +++++++++++++++++++- lustre/ptlrpc/ptlrpc_module.c | 5 +- lustre/smfs/cache_space.c | 109 +- lustre/smfs/dir.c | 69 +- lustre/smfs/file.c | 12 +- lustre/smfs/inode.c | 204 ++- lustre/smfs/ioctl.c | 7 +- lustre/smfs/kml.c | 64 +- lustre/smfs/mds_kml.c | 109 +- lustre/smfs/ost_kml.c | 3 +- lustre/smfs/smfs_internal.h | 5 +- lustre/smfs/smfs_lib.c | 80 +- lustre/smfs/smfs_llog.c | 2 +- lustre/smfs/super.c | 4 +- lustre/smfs/symlink.c | 12 +- lustre/tests/cmobd.sh | 122 -- lustre/tests/cobd.sh | 2 +- lustre/tests/cobd_test.sh | 29 +- lustre/tests/conf-sanity.sh | 2 +- lustre/tests/local.sh | 6 +- lustre/tests/sanity-cmobd.sh | 310 ---- lustre/tests/sanity.sh | 56 +- lustre/tests/uml_cobd.sh | 46 +- lustre/utils/lconf | 955 ++++++------- lustre/utils/lmc | 230 ++- lustre/utils/lustre_cfg.c | 2 +- lustre/utils/obd.c | 30 +- lustre/utils/wirecheck.c | 42 +- lustre/utils/wiretest.c | 1389 ++++++++++++++++++ 122 files changed, 7356 insertions(+), 7089 deletions(-) create mode 100644 lustre/cmobd/cache_manager_obd.c delete mode 100644 lustre/cmobd/cm_internal.h delete mode 100644 lustre/cmobd/cm_mds_reint.c delete mode 100644 lustre/cmobd/cm_obd.c create mode 100644 lustre/cmobd/cmobd_internal.h create mode 100644 lustre/cmobd/cmobd_mds_reint.c rename lustre/cmobd/{cm_oss_reint.c => cmobd_oss_reint.c} (82%) rename lustre/cmobd/{cm_reint.c => cmobd_reint.c} (70%) rename lustre/cmobd/{cm_write.c => cmobd_write.c} (91%) delete mode 100644 lustre/kernel_patches/patches/ext3-dentry-fid.patch delete mode 100644 lustre/tests/cmobd.sh delete mode 100644 lustre/tests/sanity-cmobd.sh diff --git a/lnet/include/linux/kp30.h b/lnet/include/linux/kp30.h index de642bd..db63a08 100644 --- a/lnet/include/linux/kp30.h +++ b/lnet/include/linux/kp30.h @@ -728,13 +728,4 @@ typedef int (*cfg_record_cb_t)(enum cfg_record_type, int len, void *data); # error "No word size defined" #endif -/* lustre_id output helper macros */ -#define DLID4 "%lu/%lu/%lu/%lu" - -#define OLID4(id) \ - (unsigned long)(id)->li_fid.lf_id, \ - (unsigned long)(id)->li_fid.lf_group, \ - (unsigned long)(id)->li_stc.u.e3s.l3s_ino, \ - (unsigned long)(id)->li_stc.u.e3s.l3s_gen - #endif diff --git a/lnet/include/linux/libcfs.h b/lnet/include/linux/libcfs.h index 17d5a11..d1a5c44 100644 --- a/lnet/include/linux/libcfs.h +++ b/lnet/include/linux/libcfs.h @@ -145,13 +145,6 @@ struct ptldebug_header { # endif #endif -#ifndef likely -# define likely(exp) (exp) -#endif -#ifndef unlikely -# define unlikely(exp) (exp) -#endif - #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5) #ifdef __KERNEL__ diff --git a/lnet/klnds/qswlnd/qswlnd.h b/lnet/klnds/qswlnd/qswlnd.h index d25d201..438edc6 100644 --- a/lnet/klnds/qswlnd/qswlnd.h +++ b/lnet/klnds/qswlnd/qswlnd.h @@ -79,7 +79,6 @@ #include #include #include -#include #define KQSW_CHECKSUM 0 #if KQSW_CHECKSUM diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c index 0e109cb..1bde59f 100644 --- a/lnet/utils/portals.c +++ b/lnet/utils/portals.c @@ -37,8 +37,10 @@ #include #ifdef __CYGWIN__ + #include -#endif + +#endif /* __CYGWIN__ */ #include #include @@ -52,7 +54,12 @@ unsigned int portal_printk; static unsigned int g_nal = 0; -typedef struct { +static int g_socket_txmem = 0; +static int g_socket_rxmem = 0; +static int g_socket_nonagle = 1; + +typedef struct +{ char *name; int num; } name2num_t; diff --git a/lustre/cmobd/Makefile.in b/lustre/cmobd/Makefile.in index 51c1902..8c16488 100644 --- a/lustre/cmobd/Makefile.in +++ b/lustre/cmobd/Makefile.in @@ -1,4 +1,4 @@ MODULES := cmobd -cmobd-objs := cm_obd.o cm_reint.o cm_write.o -cmobd-objs += cm_oss_reint.o cm_mds_reint.o lproc_cm.o +cmobd-objs := cache_manager_obd.o cmobd_reint.o cmobd_write.o +cmobd-objs += cmobd_oss_reint.o cmobd_mds_reint.o lproc_cm.o @INCLUDE_RULES@ diff --git a/lustre/cmobd/Makefile.mk b/lustre/cmobd/Makefile.mk index 4fc7cf2..bcc81ec 100644 --- a/lustre/cmobd/Makefile.mk +++ b/lustre/cmobd/Makefile.mk @@ -6,6 +6,6 @@ include $(src)/../portals/Kernelenv obj-y += cmobd.o -cmobd-objs := cm_obd.o cm_reint.o cm_write.o \ - cm_oss_reint.o cm_mds_reint.o lproc_cm.o +cmobd-objs := cache_manager_obd.o cmobd_reint.o cmobd_write.o \ + cmobd_oss_reint.o cmobd_mds_reint.o lproc_cm.o diff --git a/lustre/cmobd/autoMakefile.am b/lustre/cmobd/autoMakefile.am index 59d6abb..35dd6ef 100644 --- a/lustre/cmobd/autoMakefile.am +++ b/lustre/cmobd/autoMakefile.am @@ -8,4 +8,4 @@ modulefs_DATA = cmobd$(KMODEXT) endif MOSTLYCLEANFILES = *.o *.ko *.mod.c -DIST_SOURCES = $(cmobd-objs:%.o=%.c) cm_internal.h +DIST_SOURCES = $(cmobd-objs:%.o=%.c) cmobd_internal.h diff --git a/lustre/cmobd/cache_manager_obd.c b/lustre/cmobd/cache_manager_obd.c new file mode 100644 index 0000000..92d850f --- /dev/null +++ b/lustre/cmobd/cache_manager_obd.c @@ -0,0 +1,215 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * + * Copyright (c) 2002 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_CMOBD + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cmobd_internal.h" + +static int cmobd_attach(struct obd_device *obd, obd_count len, void *data) +{ + struct lprocfs_static_vars lvars; + + lprocfs_init_vars(cmobd, &lvars); + return lprocfs_obd_attach(obd, lvars.obd_vars); +} + +static int cmobd_detach(struct obd_device *obd) +{ + return lprocfs_obd_detach(obd); +} + +static void cmobd_find_master_client_obd(struct obd_device *obd, + struct obd_uuid *uuid) +{ + struct cache_manager_obd *cmobd = &obd->u.cmobd; + + cmobd->cm_master_obd = class_find_client_obd(NULL, OBD_LOV_DEVICENAME, + uuid); + if (cmobd->cm_master_obd == NULL) + cmobd->cm_master_obd = class_find_client_obd(NULL, + LUSTRE_MDC_NAME, + uuid); +} + +static int cmobd_setup(struct obd_device *obd, obd_count len, void *buf) +{ + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct lustre_cfg* lcfg = buf; + struct obd_uuid master_uuid, cache_uuid; + struct lustre_handle conn = { 0 }; + int rc; + ENTRY; + + if (lcfg->lcfg_inllen1 < 1 || !lcfg->lcfg_inlbuf1) { + CERROR("CMOBD setup requires master uuid\n"); + RETURN(-EINVAL); + } + if (lcfg->lcfg_inllen2 < 1 || !lcfg->lcfg_inlbuf2) { + CERROR("CMOBD setup requires cache uuid\n"); + RETURN(-EINVAL); + } + + obd_str2uuid(&master_uuid, lcfg->lcfg_inlbuf1); + obd_str2uuid(&cache_uuid, lcfg->lcfg_inlbuf2); + + cmobd_find_master_client_obd(obd, &master_uuid); + if (cmobd->cm_master_obd == NULL) { + CERROR("Can't find master obd %s\n", &master_uuid.uuid[0]); + RETURN(-EINVAL); + } + cmobd->cm_cache_obd = class_uuid2obd(&cache_uuid); + if (cmobd->cm_cache_obd == NULL) { + CERROR("Can't find cache obd %s\n", &cache_uuid.uuid[0]); + RETURN(-EINVAL); + } + + /* master lov connects to master ost here */ + rc = obd_connect(&conn, cmobd->cm_master_obd, &obd->obd_uuid, 0); + if (rc) + RETURN(rc); + cmobd->cm_master_exp = class_conn2export(&conn); + + memset(&conn, 0, sizeof(conn)); + rc = class_connect(&conn, cmobd->cm_cache_obd, &obd->obd_uuid); + if (rc) + GOTO(put_master, rc); + cmobd->cm_cache_exp = class_conn2export(&conn); + if (!strcmp(cmobd->cm_master_obd->obd_type->typ_name, + OBD_LOV_DEVICENAME)){ + /* for master osc remove the recovery flag of oscc */ + rc = obd_set_info(cmobd->cm_master_exp, strlen("unrecovery"), + "unrecovery", 0, NULL); + if (rc) + GOTO(put_master, rc); + + rc = cmobd_init_write_srv(obd); + if (rc) + GOTO(put_cache, rc); + + } else { + /*FIXME later temp fix here + *Assumation:cache mds only have one ost*/ + cmobd->cm_master_obd->u.cli.cl_max_mds_easize = + lov_mds_md_size(1); + } + /* start n threads for write replay */ + RETURN(0); +put_cache: + class_disconnect(cmobd->cm_cache_exp, 0); +put_master: + obd_disconnect(cmobd->cm_master_exp, 0); + RETURN(rc); +} + +static int cmobd_cleanup(struct obd_device *obd, int flags) +{ + struct cache_manager_obd *cmobd = &obd->u.cmobd; + ENTRY; + + if (!strcmp(cmobd->cm_master_obd->obd_type->typ_name, + OBD_LOV_DEVICENAME)) { + cmobd_cleanup_write_srv(obd); + } + class_disconnect(cmobd->cm_cache_exp, 0); + obd_disconnect(cmobd->cm_master_exp, 0); + + RETURN(0); +} + +static int cmobd_iocontrol(unsigned int cmd, struct obd_export *exp, int len, + void *karg, void *uarg) +{ + struct obd_device *obd = exp->exp_obd; + int rc = 0; + ENTRY; + + switch (cmd) { + case OBD_IOC_CMOBD_SYNC: /* trigger reintegration */ + rc = cmobd_reintegrate(obd); + break; + default: + CERROR("unrecognized ioctl %#x\n", cmd); + rc = -EINVAL; + break; + } + + RETURN(rc); +} + +static struct obd_ops cmobd_ops = { + o_owner: THIS_MODULE, + o_attach: cmobd_attach, + o_detach: cmobd_detach, + o_setup: cmobd_setup, + o_cleanup: cmobd_cleanup, + o_iocontrol: cmobd_iocontrol, +}; + +kmem_cache_t *cmobd_extent_slab; + +static int __init cmobd_init(void) +{ + struct lprocfs_static_vars lvars; + int rc; + ENTRY; + + printk(KERN_INFO "Lustre: Cache Manager OBD driver; info@clusterfs.com\n"); + + lprocfs_init_vars(cmobd, &lvars); + rc = class_register_type(&cmobd_ops, NULL, lvars.module_vars, + LUSTRE_CMOBD_NAME); + if (rc) + RETURN(rc); + cmobd_extent_slab = kmem_cache_create("cmobd_extents", + sizeof(struct cmobd_extent_info), 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if (cmobd_extent_slab == NULL) { + class_unregister_type(LUSTRE_CMOBD_NAME); + RETURN(-ENOMEM); + } + RETURN(0); +} + +static void /*__exit*/ cmobd_exit(void) +{ + class_unregister_type(LUSTRE_CMOBD_NAME); + if (kmem_cache_destroy(cmobd_extent_slab) != 0) + CERROR("couldn't free cmobd extent slab\n"); +} + +MODULE_AUTHOR("Cluster File Systems, Inc. "); +MODULE_DESCRIPTION("Lustre Cache Manager OBD driver"); +MODULE_LICENSE("GPL"); + +module_init(cmobd_init); +module_exit(cmobd_exit); diff --git a/lustre/cmobd/cm_internal.h b/lustre/cmobd/cm_internal.h deleted file mode 100644 index 5d32eb6..0000000 --- a/lustre/cmobd/cm_internal.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2003 Cluster File Systems, Inc. - * - * This code is issued under the GNU General Public License. - * See the file COPYING in this distribution - */ - -#ifndef CM_INTERNAL_H -#define CM_INTERNAL_H - -int cmobd_reintegrate(struct obd_device *); -int cmobd_dummy_lsm(struct lov_stripe_md **, int, struct obdo*, __u32); -void cmobd_free_lsm(struct lov_stripe_md **); - -int cmobd_replay_write(struct obd_device *, struct obdo *, - struct ldlm_extent *); - -int cmobd_init_write_srv(struct obd_device *); -void cmobd_cleanup_write_srv(struct obd_device *); - -int cmobd_reint_mds(struct obd_device*obd, void *record, int opcode); -int cmobd_reint_oss(struct obd_device *obd, void *record, int opcode); - -/* methods for updating/reading master lustre_id from local MDS inode EA.*/ -int mds_update_mid(struct obd_device *obd, struct lustre_id *id, - void *data, int data_len); - -int mds_read_mid(struct obd_device *obd, struct lustre_id *id, - void *data, int data_len); - -#endif /* CM_INTERNAL_H */ diff --git a/lustre/cmobd/cm_mds_reint.c b/lustre/cmobd/cm_mds_reint.c deleted file mode 100644 index d77acf2..0000000 --- a/lustre/cmobd/cm_mds_reint.c +++ /dev/null @@ -1,377 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (C) 2001-2003 Cluster File Systems, Inc. - * - * This file is part of Lustre, http://www.sf.net/projects/lustre/ - * - * 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_CMOBD - -#include -#include -#include -#include -#include -#include -#include - -#include "cm_internal.h" - -/* converts mds_rec_setattr to struct iattr. */ -static inline void cmobd_rec2iattr(struct mds_rec_setattr *rec, - struct iattr *iattr) -{ - iattr->ia_uid = rec->sa_uid; - iattr->ia_gid = rec->sa_gid; - iattr->ia_mode = rec->sa_mode; - iattr->ia_size = rec->sa_size; - iattr->ia_valid = rec->sa_valid; - LTIME_S(iattr->ia_atime) = rec->sa_atime; - LTIME_S(iattr->ia_mtime) = rec->sa_mtime; - LTIME_S(iattr->ia_ctime) = rec->sa_ctime; - iattr->ia_attr_flags = rec->sa_attr_flags; -} - -static void -cmobd_prepare_mdc_data(struct mdc_op_data *data, struct lustre_id *id1, - struct lustre_id *id2, const char *name, - int namelen, __u32 mode) -{ - LASSERT(id1); - LASSERT(data); - - memset(data, 0, sizeof(*data)); - - data->id1 = *id1; - if (id2) - data->id2 = *id2; - else - memset(&data->id2, 0, sizeof(data->id2)); - - data->valid = 0; - data->name = name; - data->namelen = namelen; - data->create_mode = mode; - data->mod_time = CURRENT_TIME; -} - -/* If mdc_setattr() is called with an 'iattr', then it is a normal RPC that - * should take the normal semaphore and go to the normal portal. - * - * If it is called with iattr->ia_valid & ATTR_FROM_OPEN, then it is a magic - * open-path setattr that should take the setattr semaphore and go to the - * setattr portal. */ -static int cmobd_reint_setattr(struct obd_device *obd, void *record) -{ - struct cm_obd *cmobd = &obd->u.cm; - struct ptlrpc_request *req = NULL; - struct mds_kml_pack_info *mkpi; - struct mds_rec_setattr *rec; - struct mdc_op_data op_data; - struct lustre_msg *msg; - int ea1len, ea2len; - struct iattr iattr; - void *ea1, *ea2; - int rc = 0; - ENTRY; - - mkpi = (struct mds_kml_pack_info *)record; - msg = (struct lustre_msg *)(record + sizeof(*mkpi)); - - rec = lustre_msg_buf(msg, 0, 0); - if (!rec) - RETURN(-EINVAL); - - /* converting setattr rec to struct iattr. */ - cmobd_rec2iattr(rec, &iattr); - - /* FIXME-UMKA: here should be handling of setattr() from open. Bug - * #249. Will be fixed later. */ - - /* converting localstore cookie to remote lustre_id. */ - rc = mds_read_mid(cmobd->cache_obd, &rec->sa_id, - &rec->sa_id, sizeof(rec->sa_id)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } - - cmobd_prepare_mdc_data(&op_data, &rec->sa_id, NULL, - NULL, 0, 0); - - /* handling possible EAs. */ - ea1 = lustre_msg_buf(msg, 1, 0); - ea1len = ea1 ? msg->buflens[1] : 0; - - ea2 = lustre_msg_buf(msg, 2, 0); - ea2len = ea2 ? msg->buflens[2] : 0; - - rc = md_setattr(cmobd->master_exp, &op_data, &iattr, - ea1, ea1len, ea2, ea2len, &req); - - if (req) - ptlrpc_req_finished(req); - RETURN(rc); -} - -static int cmobd_reint_create(struct obd_device *obd, void *record) -{ - struct cm_obd *cmobd = &obd->u.cm; - struct ptlrpc_request *req = NULL; - struct mds_kml_pack_info *mkpi; - int rc = 0, namelen, datalen; - struct mds_rec_create *rec; - struct mdc_op_data op_data; - struct lustre_msg *msg; - struct mds_body *body; - struct lustre_id lid; - char *name, *data; - ENTRY; - - mkpi = (struct mds_kml_pack_info *)record; - msg = (struct lustre_msg *)(record + sizeof(*mkpi)); - - rec = lustre_msg_buf(msg, 0, 0); - if (!rec) - RETURN(-EINVAL); - - lid = rec->cr_replayid; - - /* zeroing @rec->cr_replayid out in request, as master MDS should create - * own inode (with own store cookie). */ - memset(&rec->cr_replayid, 0, sizeof(rec->cr_replayid)); - - /* converting local inode store cookie to remote lustre_id. */ - rc = mds_read_mid(cmobd->cache_obd, &rec->cr_id, - &rec->cr_id, sizeof(rec->cr_id)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } - - /* getting name to be created and its length */ - name = lustre_msg_string(msg, 1, 0); - namelen = name ? msg->buflens[1] - 1 : 0; - - /* getting misc data (symlink) and its length */ - data = (char *)lustre_msg_buf(msg, 2, 0); - datalen = data ? msg->buflens[2] : 0; - - /* prepare mdc request data. */ - cmobd_prepare_mdc_data(&op_data, &rec->cr_id, &rec->cr_replayid, - name, namelen, rec->cr_mode); - - /* requesting to master to create object with passed attributes. */ - rc = md_create(cmobd->master_exp, &op_data, data, datalen, - rec->cr_mode, current->fsuid, current->fsgid, - rec->cr_rdev, &req); - - if (!rc) { - /* here we save store cookie from master MDS to local - * inode EA. */ - body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - - rc = mds_update_mid(cmobd->cache_obd, &lid, - &body->id1, sizeof(body->id1)); - } - - if (req) - ptlrpc_req_finished(req); - RETURN(rc); -} - -static int cmobd_reint_unlink(struct obd_device *obd, void *record) -{ - struct cm_obd *cmobd = &obd->u.cm; - struct ptlrpc_request *req = NULL; - struct mds_kml_pack_info *mkpi; - struct mdc_op_data op_data; - struct mds_rec_unlink *rec; - struct lustre_msg *msg; - int rc = 0, namelen; - char *name = NULL; - ENTRY; - - mkpi = (struct mds_kml_pack_info *)record; - msg = (struct lustre_msg *)(record + sizeof(*mkpi)); - - rec = lustre_msg_buf(msg, 0, 0); - if (!rec) - RETURN(-EINVAL); - - /* converting local store cookie to remote lustre_id. */ - rc = mds_read_mid(cmobd->cache_obd, &rec->ul_id1, - &rec->ul_id1, sizeof(rec->ul_id1)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } - - /* getting name to be created and its length */ - name = lustre_msg_string(msg, 1, 0); - namelen = name ? msg->buflens[1] - 1 : 0; - - /* prepare mdc request data. */ - cmobd_prepare_mdc_data(&op_data, &rec->ul_id1, NULL, - name, namelen, rec->ul_mode); - - rc = md_unlink(cmobd->master_exp, &op_data, &req); - - if (req) - ptlrpc_req_finished(req); - RETURN(rc); -} - -static int cmobd_reint_link(struct obd_device *obd, void *record) -{ - struct cm_obd *cmobd = &obd->u.cm; - struct ptlrpc_request *req = NULL; - struct mds_kml_pack_info *mkpi; - struct mdc_op_data op_data; - struct mds_rec_link *rec; - struct lustre_msg *msg; - int rc = 0, namelen; - char *name; - ENTRY; - - mkpi = (struct mds_kml_pack_info *)record; - msg = (struct lustre_msg *)(record + sizeof(*mkpi)); - - rec = lustre_msg_buf(msg, 0, 0); - if (!rec) - RETURN(-EINVAL); - - /* converting local store cookie for both ids to remote lustre_id. */ - rc = mds_read_mid(cmobd->cache_obd, &rec->lk_id1, - &rec->lk_id1, sizeof(rec->lk_id1)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } - - rc = mds_read_mid(cmobd->cache_obd, &rec->lk_id2, - &rec->lk_id2, sizeof(rec->lk_id2)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } - - /* getting name to be created and its length */ - name = lustre_msg_string(msg, 1, 0); - namelen = name ? msg->buflens[1] - 1: 0; - - /* prepare mdc request data. */ - cmobd_prepare_mdc_data(&op_data, &rec->lk_id1, &rec->lk_id2, - name, namelen, 0); - - rc = md_link(cmobd->master_exp, &op_data, &req); - - if (req) - ptlrpc_req_finished(req); - RETURN(rc); -} - -static int cmobd_reint_rename(struct obd_device *obd, void *record) -{ - struct cm_obd *cmobd = &obd->u.cm; - struct ptlrpc_request *req = NULL; - struct mds_kml_pack_info *mkpi; - struct mdc_op_data op_data; - struct mds_rec_rename *rec; - int rc = 0, oldlen, newlen; - struct lustre_msg *msg; - char *old, *new; - ENTRY; - - mkpi = (struct mds_kml_pack_info *)record; - msg = (struct lustre_msg *)(record + sizeof(*mkpi)); - - rec = lustre_msg_buf(msg, 0, 0); - if (!rec) - RETURN(-EINVAL); - - /* converting local store cookie for both ids to remote lustre_id. */ - rc = mds_read_mid(cmobd->cache_obd, &rec->rn_id1, - &rec->rn_id1, sizeof(rec->rn_id1)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } - - rc = mds_read_mid(cmobd->cache_obd, &rec->rn_id2, - &rec->rn_id2, sizeof(rec->rn_id2)); - if (rc) { - CERROR("Can't read master MDS store cookie " - "from local inode EA, err = %d.\n", rc); - RETURN(rc); - } - - /* getting old name and its length */ - old = lustre_msg_string(msg, 1, 0); - oldlen = old ? msg->buflens[1] - 1 : 0; - - /* getting new len and its length */ - new = lustre_msg_string(msg, 2, 0); - newlen = new ? msg->buflens[2] - 1: 0; - - /* prepare mdc request data. */ - cmobd_prepare_mdc_data(&op_data, &rec->rn_id1, &rec->rn_id1, - NULL, 0, 0); - - rc = md_rename(cmobd->master_exp, &op_data, old, oldlen, - new, newlen, &req); - - if (req) - ptlrpc_req_finished(req); - RETURN(rc); -} - -typedef int (*cmobd_reint_rec_func_t)(struct obd_device *, void *); - -static cmobd_reint_rec_func_t mds_reint_handler[REINT_MAX + 1] = { - [REINT_SETATTR] cmobd_reint_setattr, - [REINT_CREATE] cmobd_reint_create, - [REINT_LINK] cmobd_reint_link, - [REINT_UNLINK] cmobd_reint_unlink, - [REINT_RENAME] cmobd_reint_rename, -}; - -int cmobd_reint_mds(struct obd_device *obd, void *record, int dummy) -{ - struct mds_kml_pack_info *mkpi; - struct lustre_msg *msg; - __u32 opcode; - - mkpi = (struct mds_kml_pack_info *)record; - msg = (struct lustre_msg *)(record + sizeof(*mkpi)); - - opcode = *(__u32 *)lustre_msg_buf(msg, 0, 0); - - if (opcode > REINT_MAX || opcode <= 0) { - CERROR("Invalid mds reint opcode %u\n", - opcode); - return -EINVAL; - } - - return mds_reint_handler[opcode](obd, record); -} diff --git a/lustre/cmobd/cm_obd.c b/lustre/cmobd/cm_obd.c deleted file mode 100644 index 5d6592d..0000000 --- a/lustre/cmobd/cm_obd.c +++ /dev/null @@ -1,319 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * Copyright (c) 2002 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_CMOBD - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "cm_internal.h" - -static int cmobd_attach(struct obd_device *obd, - obd_count len, void *data) -{ - struct lprocfs_static_vars lvars; - - lprocfs_init_vars(cmobd, &lvars); - return lprocfs_obd_attach(obd, lvars.obd_vars); -} - -static int cmobd_detach(struct obd_device *obd) -{ - return lprocfs_obd_detach(obd); -} - -static struct obd_device *cmobd_find_master(struct obd_device *obd, - struct obd_uuid *uuid) -{ - struct obd_device *master_obd; - - CWARN("%s: looking for client obd %s\n", - obd->obd_uuid.uuid, uuid->uuid); - - master_obd = class_find_client_obd(NULL, - OBD_LOV_DEVICENAME, - uuid); - if (master_obd) - return master_obd; - - master_obd = class_find_client_obd(NULL, - OBD_LMV_DEVICENAME, - uuid); - if (master_obd) - return master_obd; - - master_obd = class_find_client_obd(NULL, LUSTRE_MDC_NAME, - uuid); - return master_obd; -} - -static inline int cmobd_lmv_obd(struct obd_device *obd) -{ - if (!strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) || - !strcmp(obd->obd_type->typ_name, OBD_LMV_DEVICENAME)) - return 1; - - return 0; -} - -static inline int cmobd_lov_obd(struct obd_device *obd) -{ - if (!strcmp(obd->obd_type->typ_name, OBD_LOV_DEVICENAME)) - return 1; - - return 0; -} - -static void cmobd_init_ea_size(struct obd_device *obd) -{ - int ost_count = 1, easize, cookiesize; - struct cm_obd *cmobd = &obd->u.cm; - ENTRY; - - /* FIXME-UMKA: here we should also take into account that there is - * possible to have few OSTs. */ - easize = lov_mds_md_size(ost_count); - cookiesize = ost_count * sizeof(struct llog_cookie); - - obd_init_ea_size(cmobd->master_exp, easize, cookiesize); - - cmobd->master_obd->u.cli.cl_max_mds_easize = easize; - cmobd->master_obd->u.cli.cl_max_mds_cookiesize = cookiesize; - - EXIT; -} - -static int cmobd_setup(struct obd_device *obd, obd_count len, void *buf) -{ - struct obd_uuid master_uuid, cache_uuid; - struct lustre_handle conn = { 0 }; - struct cm_obd *cmobd = &obd->u.cm; - struct lustre_cfg* lcfg = buf; - struct lustre_id mid, lid; - int valsize, rc; - ENTRY; - - if (lcfg->lcfg_inllen1 < 1 || !lcfg->lcfg_inlbuf1) { - CERROR("CMOBD setup requires master uuid\n"); - RETURN(-EINVAL); - } - if (lcfg->lcfg_inllen2 < 1 || !lcfg->lcfg_inlbuf2) { - CERROR("CMOBD setup requires cache uuid\n"); - RETURN(-EINVAL); - } - - obd_str2uuid(&master_uuid, lcfg->lcfg_inlbuf1); - obd_str2uuid(&cache_uuid, lcfg->lcfg_inlbuf2); - - /* FIXME-WANGDI: saving client obds here is not correct as they may - become invalid due to refcounter exhausting on cleanup. The prefer - way seems to be getting them each time we need them. */ - cmobd->master_obd = cmobd_find_master(obd, &master_uuid); - if (cmobd->master_obd == NULL) { - CERROR("Can't find master obd %s\n", &master_uuid.uuid[0]); - RETURN(-EINVAL); - } - - cmobd->cache_obd = class_uuid2obd(&cache_uuid); - if (cmobd->cache_obd == NULL) { - CERROR("Can't find cache obd %s\n", &cache_uuid.uuid[0]); - RETURN(-EINVAL); - } - - rc = obd_connect(&conn, cmobd->master_obd, &obd->obd_uuid, 0); - if (rc) - RETURN(rc); - cmobd->master_exp = class_conn2export(&conn); - - memset(&conn, 0, sizeof(conn)); - rc = class_connect(&conn, cmobd->cache_obd, &obd->obd_uuid); - if (rc) - GOTO(put_master, rc); - - cmobd->cache_exp = class_conn2export(&conn); - - if (cmobd_lov_obd(cmobd->master_obd)) { - /* for master osc remove the recovery flag. */ - rc = obd_set_info(cmobd->master_exp, strlen("unrecovery"), - "unrecovery", 0, NULL); - if (rc) - GOTO(put_master, rc); - - rc = cmobd_init_write_srv(obd); - if (rc) - GOTO(put_cache, rc); - } else { - cmobd_init_ea_size(obd); - cmobd->write_srv = NULL; - } - - if (cmobd_lmv_obd(cmobd->master_obd)) { - /* making sure, that both obds are ready. This is especially - * important in the case of using LMV as master. */ - rc = obd_getready(cmobd->master_exp); - if (rc) { - CERROR("Can't make %s obd ready.\n", - master_uuid.uuid); - GOTO(put_cache, rc); - } - - rc = obd_getready(cmobd->cache_exp); - if (rc) { - CERROR("Can't make %s obd ready.\n", - cache_uuid.uuid); - GOTO(put_cache, rc); - } - - /* requesting master obd to have its root inode store cookie to - * be able to save it to local root inode EA. */ - valsize = sizeof(struct lustre_id); - - rc = obd_get_info(cmobd->master_exp, strlen("rootid"), - "rootid", &valsize, &mid); - if (rc) { - CERROR("Can't get rootid from master MDS %s, " - "err= %d.\n", master_uuid.uuid, rc); - GOTO(put_cache, rc); - } - - /* getting rootid from cache MDS. It is needed to update local - * (cache) root inode by rootid value from master obd. */ - rc = obd_get_info(cmobd->cache_exp, strlen("rootid"), - "rootid", &valsize, &lid); - if (rc) { - CERROR("Can't get rootid from local MDS %s, " - "err= %d.\n", cache_uuid.uuid, rc); - GOTO(put_cache, rc); - } - - /* storing master MDS rootid to local root inode EA. */ - CWARN("storing "DLID4" to local inode "DLID4".\n", - OLID4(&mid), OLID4(&lid)); - - rc = mds_update_mid(cmobd->cache_obd, &lid, - &mid, sizeof(mid)); - if (rc) { - CERROR("Can't update local root inode by ID " - "from master MDS %s, err = %d.\n", - master_uuid.uuid, rc); - GOTO(put_cache, rc); - } - } - - RETURN(rc); -put_cache: - class_disconnect(cmobd->cache_exp, 0); -put_master: - obd_disconnect(cmobd->master_exp, 0); - RETURN(rc); -} - -static int cmobd_cleanup(struct obd_device *obd, int flags) -{ - struct cm_obd *cmobd = &obd->u.cm; - ENTRY; - - if (cmobd->write_srv) - cmobd_cleanup_write_srv(obd); - - class_disconnect(cmobd->cache_exp, 0); - obd_disconnect(cmobd->master_exp, 0); - - RETURN(0); -} - -static int cmobd_iocontrol(unsigned int cmd, struct obd_export *exp, - int len, void *karg, void *uarg) -{ - struct obd_device *obd = exp->exp_obd; - int rc = 0; - ENTRY; - - switch (cmd) { - case OBD_IOC_CMOBD_SYNC: /* trigger reintegration */ - rc = cmobd_reintegrate(obd); - break; - default: - CERROR("unrecognized ioctl %#x\n", cmd); - rc = -EINVAL; - break; - } - - RETURN(rc); -} - -static struct obd_ops cmobd_ops = { - o_owner: THIS_MODULE, - o_attach: cmobd_attach, - o_detach: cmobd_detach, - o_setup: cmobd_setup, - o_cleanup: cmobd_cleanup, - o_iocontrol: cmobd_iocontrol, -}; - -kmem_cache_t *cmobd_extent_slab; - -static int __init cmobd_init(void) -{ - struct lprocfs_static_vars lvars; - int rc; - ENTRY; - - printk(KERN_INFO "Lustre: Cache Manager OBD driver; info@clusterfs.com\n"); - - lprocfs_init_vars(cmobd, &lvars); - rc = class_register_type(&cmobd_ops, NULL, lvars.module_vars, - LUSTRE_CMOBD_NAME); - if (rc) - RETURN(rc); - cmobd_extent_slab = kmem_cache_create("cmobd_extents", - sizeof(struct cmobd_extent_info), 0, - SLAB_HWCACHE_ALIGN, NULL, NULL); - if (cmobd_extent_slab == NULL) { - class_unregister_type(LUSTRE_CMOBD_NAME); - RETURN(-ENOMEM); - } - RETURN(0); -} - -static void /*__exit*/ cmobd_exit(void) -{ - class_unregister_type(LUSTRE_CMOBD_NAME); - if (kmem_cache_destroy(cmobd_extent_slab) != 0) - CERROR("couldn't free cmobd extent slab\n"); -} - -MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Lustre Cache Manager OBD driver"); -MODULE_LICENSE("GPL"); - -module_init(cmobd_init); -module_exit(cmobd_exit); diff --git a/lustre/cmobd/cmobd_internal.h b/lustre/cmobd/cmobd_internal.h new file mode 100644 index 0000000..d245015 --- /dev/null +++ b/lustre/cmobd/cmobd_internal.h @@ -0,0 +1,28 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * + * Copyright (C) 2003 Cluster File Systems, Inc. + * + * This code is issued under the GNU General Public License. + * See the file COPYING in this distribution + */ + +#ifndef CMOBD_INTERNAL_H +#define CMOBD_INTERNAL_H + +/* cmobd_reint.c */ +int cmobd_reintegrate(struct obd_device *); +int cmobd_dummy_lsm(struct lov_stripe_md **, int, struct obdo*, __u32); +void cmobd_free_lsm(struct lov_stripe_md **); + +/* cmobd_write.c */ +int cmobd_replay_write(struct obd_device *, struct obdo*, struct ldlm_extent *); +int cmobd_init_write_srv(struct obd_device *); +void cmobd_cleanup_write_srv(struct obd_device *); + +int cmobd_reint_mds(struct obd_device*, void *record); +int cmobd_reint_setattr(struct obd_device *obd, void *rec); +int cmobd_reint_create(struct obd_device *obd, void *rec); +int cmobd_reint_write(struct obd_device *obd, void *rec); + +#endif /* CMOBD_INTERNAL_H */ diff --git a/lustre/cmobd/cmobd_mds_reint.c b/lustre/cmobd/cmobd_mds_reint.c new file mode 100644 index 0000000..0fb8e07 --- /dev/null +++ b/lustre/cmobd/cmobd_mds_reint.c @@ -0,0 +1,184 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * + * Copyright (C) 2001-2003 Cluster File Systems, Inc. + * + * This file is part of Lustre, http://www.sf.net/projects/lustre/ + * + * 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_CMOBD + +#include +#include +#include +#include +#include +#include +#include +#include "cmobd_internal.h" + +/* If mdc_setattr is called with an 'iattr', then it is a normal RPC that + * should take the normal semaphore and go to the normal portal. + * + * If it is called with iattr->ia_valid & ATTR_FROM_OPEN, then it is a + * magic open-path setattr that should take the setattr semaphore and + * go to the setattr portal. */ +int cmobd_setattr_reint(struct obd_device *obd, struct ptlrpc_request *req) +{ + struct mds_rec_setattr *rec; + int size[1], rc = 0; + + ENTRY; + + rec = (struct mds_rec_setattr *)lustre_msg_buf(req->rq_reqmsg, 0, 0); + if (!rec) + RETURN (-EINVAL); + if (rec->sa_valid & ATTR_FROM_OPEN) + req->rq_request_portal = MDS_SETATTR_PORTAL; //XXX FIXME bug 249 + + if (rec->sa_valid & (ATTR_MTIME | ATTR_CTIME)) + CDEBUG(D_INODE, "setting mtime %lu, ctime %lu\n", + ((time_t)rec->sa_mtime), + ((time_t)rec->sa_ctime)); + size[0] = sizeof(struct mds_body); + req->rq_replen = lustre_msg_size(1, size); + + rc = mdc_reint(req, NULL, LUSTRE_IMP_FULL); + + if (rc == -ERESTARTSYS) + rc = 0; + + RETURN(rc); +} + +int cmobd_create_reint(struct obd_device *obd, struct ptlrpc_request *req) +{ + int rc = 0, level, size[1]; + ENTRY; + + size[0] = sizeof(struct mds_body); + req->rq_replen = lustre_msg_size(1, size); + + level = LUSTRE_IMP_FULL; + resend: + rc = mdc_reint(req, NULL, level); + /* Resend if we were told to. */ + if (rc == -ERESTARTSYS) { + level = LUSTRE_IMP_RECOVER; + goto resend; + } + + if (!rc) + mdc_store_inode_generation(NULL, req, 0, 0); + + RETURN(rc); +} + +int cmobd_unlink_reint(struct obd_device *obd, struct ptlrpc_request *req) +{ + int rc = 0, size[3]; + ENTRY; + + size[0] = sizeof(struct mds_body); + size[1] = obd->u.cli.cl_max_mds_easize; + size[2] = obd->u.cli.cl_max_mds_cookiesize; + req->rq_replen = lustre_msg_size(3, size); + + rc = mdc_reint(req, NULL, LUSTRE_IMP_FULL); + if (rc == -ERESTARTSYS) + rc = 0; + RETURN(rc); +} + +int cmobd_link_reint(struct obd_device *obd, struct ptlrpc_request *req) +{ + int rc = 0, size[1]; + ENTRY; + + size[0] = sizeof(struct mds_body); + req->rq_replen = lustre_msg_size(1, size); + + rc = mdc_reint(req, NULL, LUSTRE_IMP_FULL); + if (rc == -ERESTARTSYS) + rc = 0; + + RETURN(rc); +} + +int cmobd_rename_reint(struct obd_device *obd, struct ptlrpc_request *req) +{ + int rc = 0, size[2]; + ENTRY; + + size[0] = sizeof(struct mds_body); + size[1] = obd->u.cli.cl_max_mds_easize; + req->rq_replen = lustre_msg_size(2, size); + + rc = mdc_reint(req, NULL, LUSTRE_IMP_FULL); + if (rc == -ERESTARTSYS) + rc = 0; + + RETURN(rc); +} + +typedef int (*cmobd_reint_mds_rec)(struct obd_device*, + struct ptlrpc_request *req); + +static cmobd_reint_mds_rec cmobd_mds_reint[REINT_MAX + 1] = { + [REINT_SETATTR] cmobd_setattr_reint, + [REINT_CREATE] cmobd_create_reint, + [REINT_LINK] cmobd_link_reint, + [REINT_UNLINK] cmobd_unlink_reint, + [REINT_RENAME] cmobd_rename_reint, +}; + +int cmobd_reint_mds(struct obd_device *obd, void* record) +{ + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct ptlrpc_request *req; + struct lustre_msg *msg; + struct mds_kml_pack_info *mkpi; + __u32 opcode; + int rc = 0; + mkpi = (struct mds_kml_pack_info *)record; + + req = ptlrpc_prep_req(class_exp2cliimp(cmobd->cm_master_exp), + LUSTRE_MDS_VERSION, MDS_REINT, + mkpi->mpi_bufcount, mkpi->mpi_size, NULL); + if (req == NULL) + RETURN(-ENOMEM); + record += sizeof(*mkpi); + msg = (struct lustre_msg *)record; + opcode = (__u32)*(int*)lustre_msg_buf(msg, 0, 0); + if (opcode > REINT_MAX || opcode <= 0) { + CERROR("Unrecorgnized reint opcode %u in cmobd mds reint\n", + opcode); + GOTO(out, rc=-EINVAL); + } + + memcpy(req->rq_reqmsg, record, mkpi->mpi_total_size); + /*flags and opc will be rewrite, so reset here + *FIXME maybe should set some flags in reint process*/ + + req->rq_reqmsg->opc = MDS_REINT; + req->rq_reqmsg->flags = 0; + + rc = cmobd_mds_reint[opcode](cmobd->cm_master_obd, req); +out: + ptlrpc_req_finished(req); + return rc; +} + diff --git a/lustre/cmobd/cm_oss_reint.c b/lustre/cmobd/cmobd_oss_reint.c similarity index 82% rename from lustre/cmobd/cm_oss_reint.c rename to lustre/cmobd/cmobd_oss_reint.c index aec0557..41d5369 100644 --- a/lustre/cmobd/cm_oss_reint.c +++ b/lustre/cmobd/cmobd_oss_reint.c @@ -33,15 +33,12 @@ #include #include -#include "cm_internal.h" +#include "cmobd_internal.h" +int lov_alloc_memmd(struct lov_stripe_md **lsmp, int stripe_count, int pattern); void lov_free_memmd(struct lov_stripe_md **lsmp); - -int lov_alloc_memmd(struct lov_stripe_md **lsmp, int stripe_count, - int pattern); - -int smfs_rec_unpack(struct smfs_proc_args *args, char *record, - char **pbuf, int *opcode); +int smfs_rec_unpack(struct smfs_proc_args *args, char *record, char **pbuf, + int *opcode); /* helper functions for cmobd to construct pseudo lsm */ int cmobd_dummy_lsm(struct lov_stripe_md **lsmp, int stripe_cnt, @@ -75,11 +72,11 @@ void cmobd_free_lsm(struct lov_stripe_md **lsmp) } /* reintegration functions */ -static int cmobd_setattr_reint(struct obd_device *obd, void *rec) +int cmobd_reint_setattr(struct obd_device *obd, void *rec) { - struct cm_obd *cmobd = &obd->u.cm; - struct lov_obd *lov = &cmobd->master_obd->u.lov; - struct obd_export *exp = cmobd->master_exp; + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct lov_obd *lov = &cmobd->cm_master_obd->u.lov; + struct obd_export *exp = cmobd->cm_master_exp; struct lov_stripe_md *lsm; struct obdo *oa = (struct obdo*)rec; int rc; @@ -97,11 +94,11 @@ out: RETURN(rc); } -static int cmobd_create_reint(struct obd_device *obd, void *rec) +int cmobd_reint_create(struct obd_device *obd, void *rec) { - struct cm_obd *cmobd = &obd->u.cm; - struct lov_obd *lov = &cmobd->master_obd->u.lov; - struct obd_export *exp = cmobd->master_exp; + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct lov_obd *lov = &cmobd->cm_master_obd->u.lov; + struct obd_export *exp = cmobd->cm_master_exp; struct lov_stripe_md *lsm; struct obd_trans_info oti = { 0 }; struct obdo *oa=(struct obdo*)rec; @@ -112,14 +109,14 @@ static int cmobd_create_reint(struct obd_device *obd, void *rec) (__u32)lov->desc.ld_default_stripe_size); if (rc) GOTO(out, rc); - if (cmobd->master_group != oa->o_gr) { + if (cmobd->cm_master_group != oa->o_gr) { int group = oa->o_gr; int valsize = sizeof(group); rc = obd_set_info(exp, strlen("mds_conn"), "mds_conn", valsize, &group); if (rc) GOTO(out, rc = -EINVAL); - cmobd->master_group = oa->o_gr; + cmobd->cm_master_group = oa->o_gr; } rc = obd_create(exp, oa, &lsm, &oti); @@ -202,9 +199,9 @@ static int master_blocking_ast(struct ldlm_lock *lock, static int cmobd_write_extents(struct obd_device *obd, struct obdo *oa, struct ldlm_extent *extent) { - struct cm_obd *cmobd = &obd->u.cm; - struct obd_device *cache = cmobd->cache_obd; - struct lov_obd *lov = &cmobd->master_obd->u.lov; + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct obd_device *cache = cmobd->cm_cache_obd; + struct lov_obd *lov = &cmobd->cm_master_obd->u.lov; struct ldlm_res_id res_id; ldlm_policy_data_t policy; struct lustre_handle lockh_src = { 0 }; @@ -233,7 +230,7 @@ static int cmobd_write_extents(struct obd_device *obd, struct obdo *oa, if (rc) GOTO(out_lock, rc); - rc = obd_enqueue(cmobd->master_exp, lsm, LDLM_EXTENT, &policy, + rc = obd_enqueue(cmobd->cm_master_exp, lsm, LDLM_EXTENT, &policy, LCK_PW, &flags, master_blocking_ast, ldlm_completion_ast, NULL, NULL, 0, NULL, &lockh_dst); @@ -242,12 +239,12 @@ static int cmobd_write_extents(struct obd_device *obd, struct obdo *oa, err = cmobd_replay_write(obd, oa, &policy.l_extent); - rc = obd_cancel(cmobd->master_exp, lsm, LCK_PW, &lockh_dst); + rc = obd_cancel(cmobd->cm_master_exp, lsm, LCK_PW, &lockh_dst); if (rc) GOTO(out_lsm, rc); /* XXX in fact, I just want to cancel the only lockh_dst * instantly. */ - rc = obd_cancel_unused(cmobd->master_exp, lsm, 0, NULL); + rc = obd_cancel_unused(cmobd->cm_master_exp, lsm, 0, NULL); if (err) rc = err; out_lsm: @@ -256,11 +253,10 @@ out_lock: ldlm_lock_decref(&lockh_src, LCK_PR); RETURN(rc); } - -static int cmobd_write_reint(struct obd_device *obd, void *rec) +int cmobd_reint_write(struct obd_device *obd, void *rec) { - struct cm_obd *cmobd = &obd->u.cm; - struct obd_device *cache = cmobd->cache_obd; + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct obd_device *cache = cmobd->cm_cache_obd; struct obdo *oa = (struct obdo *)rec; struct ldlm_extent *extent = NULL; unsigned long csb, ino; @@ -270,7 +266,7 @@ static int cmobd_write_reint(struct obd_device *obd, void *rec) size = sizeof(csb); - obd_get_info(cmobd->cache_exp, strlen("cache_sb") + 1, + obd_get_info(cmobd->cm_cache_exp, strlen("cache_sb") + 1, "cache_sb", &size, &csb); ino = *(int*)(&oa->o_inline[0]); @@ -288,23 +284,8 @@ static int cmobd_write_reint(struct obd_device *obd, void *rec) } out: if (extents_buf) - fsfilt_free_write_extents(cache, (struct super_block *)csb, - ino, extents_buf, ext_num); + fsfilt_free_write_extents(cache, (struct super_block *)csb, ino, + extents_buf, ext_num); RETURN(rc); } -int cmobd_reint_oss(struct obd_device *obd, void *record, int opcode) -{ - switch (opcode) { - case OST_CREATE: - return cmobd_create_reint(obd, record); - case OST_SETATTR: - return cmobd_setattr_reint(obd, record); - case OST_WRITE: - return cmobd_write_reint(obd, record); - default: - CERROR("unrecognized oss reint opcode %d\n", - opcode); - return -EINVAL; - } -} diff --git a/lustre/cmobd/cm_reint.c b/lustre/cmobd/cmobd_reint.c similarity index 70% rename from lustre/cmobd/cm_reint.c rename to lustre/cmobd/cmobd_reint.c index 230f6f1..f68132f 100644 --- a/lustre/cmobd/cm_reint.c +++ b/lustre/cmobd/cmobd_reint.c @@ -33,35 +33,33 @@ #include #include -#include "cm_internal.h" +#include "cmobd_internal.h" -#define OSS_REINT(opcode) \ -({ \ - int _opcode = (opcode); \ - \ - (_opcode == OST_CREATE || \ - _opcode == OST_SETATTR || \ - _opcode == OST_WRITE); \ -}) - -#define MDS_REINT(opcode) \ - ((opcode) == MDS_REINT) - -static int cmobd_reint_record(struct obd_device *obd, - void *record, int opcode) +static int cmobd_reint_record(int opcode, struct obd_device *obd, char *record) { - if (OSS_REINT(opcode)) - return cmobd_reint_oss(obd, record, opcode); + int rc = 0; - if (MDS_REINT(opcode)) - return cmobd_reint_mds(obd, record, opcode); - - CERROR("unrecognized reint opcode %d\n", opcode); - return -EINVAL; -} - -static int cmobd_reint_cb(struct llog_handle *llh, - struct llog_rec_hdr *rec, + switch (opcode) { + case OST_CREATE: + rc = cmobd_reint_create(obd, record); + break; + case OST_SETATTR: + rc = cmobd_reint_setattr(obd, record); + break; + case OST_WRITE: + rc = cmobd_reint_write(obd, record); + break; + case MDS_REINT: + rc = cmobd_reint_mds(obd, record); + break; + default: + CERROR("unrecognized format %d\n", opcode); + rc = -EINVAL; + break; + } + return rc; +} +static int cmobd_reint_cb(struct llog_handle *llh, struct llog_rec_hdr *rec, void *data) { struct obd_device *obd = (struct obd_device*)data; @@ -74,7 +72,6 @@ static int cmobd_reint_cb(struct llog_handle *llh, CERROR("log is not plain log\n"); RETURN(-EINVAL); } - if (rec->lrh_type != SMFS_UPDATE_REC) RETURN(-EINVAL); @@ -82,12 +79,10 @@ static int cmobd_reint_cb(struct llog_handle *llh, rc = smfs_rec_unpack(NULL, buf, &pbuf, &opcode); if (rc) GOTO(out, rc); - - rc = cmobd_reint_record(obd, pbuf, opcode); + rc = cmobd_reint_record(opcode, obd, pbuf); if (rc) GOTO(out, rc); - - /* delete this record. */ + /*delete this record*/ rc = LLOG_DEL_RECORD; out: RETURN(rc); @@ -95,7 +90,7 @@ out: int cmobd_reintegrate(struct obd_device *obd) { - struct cm_obd *cmobd = &obd->u.cm; + struct cache_manager_obd *cmobd = &obd->u.cmobd; struct llog_ctxt *ctxt = NULL; struct llog_handle *llh; int val_size, rc = 0; @@ -104,7 +99,7 @@ int cmobd_reintegrate(struct obd_device *obd) /* XXX just fetch the reintegration log context from * cache ost directly, use logid later ?? */ val_size = sizeof(ctxt); - rc = obd_get_info(cmobd->cache_exp, strlen("reint_log") + 1, + rc = obd_get_info(cmobd->cm_cache_exp, strlen("reint_log") + 1, "reint_log", &val_size, &ctxt); if (rc) RETURN(rc); @@ -120,3 +115,5 @@ int cmobd_reintegrate(struct obd_device *obd) RETURN(rc); } + + diff --git a/lustre/cmobd/cm_write.c b/lustre/cmobd/cmobd_write.c similarity index 91% rename from lustre/cmobd/cm_write.c rename to lustre/cmobd/cmobd_write.c index 833cc8c..815efc6 100644 --- a/lustre/cmobd/cm_write.c +++ b/lustre/cmobd/cmobd_write.c @@ -34,7 +34,7 @@ #include #include -#include "cm_internal.h" +#include "cmobd_internal.h" extern kmem_cache_t *cmobd_extent_slab; @@ -108,10 +108,8 @@ static void cmobd_ap_fill_obdo(void *data, int cmd, struct obdo *oa) valid_flags = OBD_MD_FLTYPE | OBD_MD_FLATIME; if (cmd == OBD_BRW_WRITE) { oa->o_valid |= OBD_MD_FLIFID; - - /* FIXME-UMKA: should be here some mds num and mds id? */ - mdc_pack_id(obdo_id(oa), inode->i_ino, 0, - inode->i_mode, 0, 0); + mdc_pack_fid(obdo_fid(oa), inode->i_ino, 0, inode->i_mode); + valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME; } @@ -171,8 +169,8 @@ static int cmobd_send_pages(struct obd_device *obd, obd_count oa_bufs, struct cmobd_extent_set *set) { - struct cm_obd *cmobd = &obd->u.cm; - struct obd_export *exp = cmobd->master_exp; + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct obd_export *exp = cmobd->cm_master_exp; struct cmobd_async_page *cmap = NULL; obd_count i; int rc = 0; @@ -261,7 +259,7 @@ static int cmobd_write_extent(struct obd_device *obd, struct cmobd_extent_info *ei) { struct cmobd_extent_set *set = ei->ei_set; - struct cm_obd *cmobd = &obd->u.cm; + struct cache_manager_obd *cmobd = &obd->u.cmobd; unsigned long flags; struct obd_ioobj ioo; struct niobuf_local *lnb; @@ -295,7 +293,7 @@ static int cmobd_write_extent(struct obd_device *obd, obdo_to_ioobj(oa, &ioo); ioo.ioo_bufcnt = oa_bufs; - ret = obd_preprw(OBD_BRW_READ, cmobd->cache_exp, oa, 1, &ioo, + ret = obd_preprw(OBD_BRW_READ, cmobd->cm_cache_exp, oa, 1, &ioo, oa_bufs, rnb, lnb, NULL); if (ret) GOTO(out, rc = ret); @@ -304,7 +302,7 @@ static int cmobd_write_extent(struct obd_device *obd, if (rc) CERROR("cmobd_send_pages failed %d\n", rc); - rc = obd_commitrw(OBD_BRW_READ, cmobd->cache_exp, oa, 1, &ioo, + rc = obd_commitrw(OBD_BRW_READ, cmobd->cm_cache_exp, oa, 1, &ioo, oa_bufs, lnb, NULL, ret); /* countdown and wake up */ @@ -357,24 +355,16 @@ static int cmobd_write_main(void *arg) struct ptlrpc_svc_data *data = (struct ptlrpc_svc_data *)arg; struct ptlrpc_thread *thread = data->thread; struct obd_device *obd = data->dev; - struct cm_obd *cmobd = &obd->u.cm; - struct cmobd_write_service *ws = cmobd->write_srv; + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct cmobd_write_service *ws = cmobd->cm_write_srv; struct cmobd_extent_info *extent = NULL; unsigned long flags; int rc; ENTRY; lock_kernel(); - /* vv ptlrpc_daemonize(); vv */ - exit_mm(current); - - current->session = 1; - current->pgrp = 1; - current->tty = NULL; - - exit_files(current); - reparent_to_init(); - /* ^^ ptlrpc_daemonize(); ^^ */ + + ptlrpc_daemonize(); SIGNAL_MASK_LOCK(current, flags); sigfillset(¤t->blocked); @@ -426,8 +416,8 @@ static int cmobd_write_main(void *arg) * ptlrpc threads functions */ static int cmobd_start_thread(struct obd_device *obd, char *name) { - struct cm_obd *cmobd = &obd->u.cm; - struct cmobd_write_service *ws = cmobd->write_srv; + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct cmobd_write_service *ws = cmobd->cm_write_srv; struct l_wait_info lwi = { 0 }; struct ptlrpc_svc_data d; struct ptlrpc_thread *thread; @@ -470,8 +460,8 @@ static int cmobd_start_thread(struct obd_device *obd, char *name) static void cmobd_stop_thread(struct obd_device *obd, struct ptlrpc_thread *thread) { - struct cm_obd *cmobd = &obd->u.cm; - struct cmobd_write_service *ws = cmobd->write_srv; + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct cmobd_write_service *ws = cmobd->cm_write_srv; struct l_wait_info lwi = { 0 }; unsigned long flags; ENTRY; @@ -492,8 +482,8 @@ static void cmobd_stop_thread(struct obd_device *obd, static void cmobd_stop_all_threads(struct obd_device *obd) { - struct cm_obd *cmobd = &obd->u.cm; - struct cmobd_write_service *ws = cmobd->write_srv; + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct cmobd_write_service *ws = cmobd->cm_write_srv; unsigned long flags; struct ptlrpc_thread *thread; ENTRY; @@ -533,33 +523,33 @@ static int cmobd_start_n_threads(struct obd_device *obd, int num_threads, void cmobd_cleanup_write_srv(struct obd_device *obd) { - struct cm_obd *cmobd = &obd->u.cm; + struct cache_manager_obd *cmobd = &obd->u.cmobd; struct list_head *pos, *n; struct cmobd_extent_info *ei; ENTRY; cmobd_stop_all_threads(obd); - list_for_each_safe(pos, n, &cmobd->write_srv->ws_extents) { + list_for_each_safe(pos, n, &cmobd->cm_write_srv->ws_extents) { ei = list_entry(pos, struct cmobd_extent_info, ei_link); list_del_init(&ei->ei_link); OBD_FREE(ei, sizeof(*ei)); } - OBD_FREE(cmobd->write_srv, sizeof(*cmobd->write_srv)); + OBD_FREE(cmobd->cm_write_srv, sizeof(*cmobd->cm_write_srv)); EXIT; } int cmobd_init_write_srv(struct obd_device *obd) { - struct cm_obd *cmobd = &obd->u.cm; + struct cache_manager_obd *cmobd = &obd->u.cmobd; struct cmobd_write_service *ws; int rc; ENTRY; - OBD_ALLOC(cmobd->write_srv, sizeof(*cmobd->write_srv)); - if (cmobd->write_srv == NULL) + OBD_ALLOC(cmobd->cm_write_srv, sizeof(*cmobd->cm_write_srv)); + if (cmobd->cm_write_srv == NULL) RETURN(-ENOMEM); - ws = cmobd->write_srv; + ws = cmobd->cm_write_srv; INIT_LIST_HEAD(&ws->ws_threads); spin_lock_init(&ws->ws_thread_lock); @@ -593,8 +583,8 @@ static int extent_queue_full(struct cmobd_write_service *ws) static void cmobd_queue_extent(struct obd_device *obd, struct cmobd_extent_info *ex) { - struct cm_obd *cmobd = &obd->u.cm; - struct cmobd_write_service *ws = cmobd->write_srv; + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct cmobd_write_service *ws = cmobd->cm_write_srv; struct cmobd_extent_set *set = ex->ei_set; unsigned long flags; struct l_wait_info lwi = { 0 }; @@ -621,7 +611,7 @@ wait: EXIT; } -static obd_size cmobd_id2size(struct obd_export *exp, obd_id id, obd_gr grp) +static obd_size cmobd_fid2size(struct obd_export *exp, obd_id id, obd_gr grp) { struct lvfs_run_ctxt saved; struct dentry *de = NULL; @@ -630,7 +620,7 @@ static obd_size cmobd_id2size(struct obd_export *exp, obd_id id, obd_gr grp) push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL); - de = obd_lvfs_id2dentry(exp, id, 0, grp); + de = obd_lvfs_fid2dentry(exp, id, 0, grp); LASSERT(de); size = de->d_inode->i_size; @@ -659,8 +649,8 @@ static int extent_set_done(struct cmobd_extent_set *set, int phase) int cmobd_replay_write(struct obd_device *obd, struct obdo *oa, struct ldlm_extent *ext) { - struct cm_obd *cmobd = &obd->u.cm; - struct lov_obd *lov = &cmobd->master_obd->u.lov; + struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct lov_obd *lov = &cmobd->cm_master_obd->u.lov; struct lov_stripe_md *lsm = NULL; struct cmobd_extent_set set; struct cmobd_extent_info *ex; @@ -681,7 +671,7 @@ int cmobd_replay_write(struct obd_device *obd, struct obdo *oa, set.es_extent.start = ext->start; set.es_extent.end = ext->end; set.es_lsm = lsm; - set.es_exp = cmobd->master_exp; + set.es_exp = cmobd->cm_master_exp; set.es_ext_sz = CMOBD_MAX_EXTENT_SZ; set.es_count = 0; memcpy(&set.es_oa, oa, sizeof(*oa)); @@ -698,8 +688,8 @@ int cmobd_replay_write(struct obd_device *obd, struct obdo *oa, set.es_extent.start -= set.es_extent.start & ~PAGE_MASK; /* if the end of extent is EOF, set it as file size */ if (set.es_extent.end == OBD_OBJECT_EOF) { - set.es_extent.end = cmobd_id2size(cmobd->cache_exp, - oa->o_id, oa->o_gr) - 1; + set.es_extent.end = cmobd_fid2size(cmobd->cm_cache_exp, + oa->o_id, oa->o_gr) - 1; if (set.es_extent.end <= 0) GOTO(out, rc = 0); } diff --git a/lustre/cobd/cache_obd.c b/lustre/cobd/cache_obd.c index a081fc1..f4072eb 100644 --- a/lustre/cobd/cache_obd.c +++ b/lustre/cobd/cache_obd.c @@ -66,24 +66,22 @@ static int cobd_setup(struct obd_device *obd, obd_count len, void *buf) { struct lustre_cfg *lcfg = (struct lustre_cfg *)buf; struct cache_obd *cobd = &obd->u.cobd; -#if 0 - struct lustre_handle master_conn = {0,}; -#endif - struct lustre_handle cache_conn = {0,}; - struct obd_device *master; +// struct lustre_handle real_conn = {0,}, cache_conn = {0,}; + struct lustre_handle cache_conn = {0,}; + struct obd_device *real; struct obd_device *cache; int rc; ENTRY; if (lcfg->lcfg_inllen1 == 0 || lcfg->lcfg_inlbuf1 == NULL) { - CERROR("%s: setup requires master device name\n", + CERROR("%s: setup requires real device name\n", obd->obd_name); RETURN(-EINVAL); } - master = class_name2obd(lcfg->lcfg_inlbuf1); - if (master == NULL) { - CERROR("%s: unable to find a client for master: %s\n", + real = class_name2obd(lcfg->lcfg_inlbuf1); + if (real == NULL) { + CERROR("%s: unable to find a client for real: %s\n", obd->obd_name, lcfg->lcfg_inlbuf1); RETURN(-EINVAL); } @@ -93,60 +91,60 @@ static int cobd_setup(struct obd_device *obd, obd_count len, void *buf) RETURN(-EINVAL); } - cache = class_name2obd(lcfg->lcfg_inlbuf2); + cache = class_name2obd(lcfg->lcfg_inlbuf2); if (cache == NULL) { CERROR("%s: unable to find a client for cache: %s\n", obd->obd_name, lcfg->lcfg_inlbuf2); RETURN(-EINVAL); } - OBD_ALLOC(cobd->master_name, strlen(lcfg->lcfg_inlbuf1) + 1); - if (!cobd->master_name) + OBD_ALLOC(cobd->cobd_real_name, strlen(lcfg->lcfg_inlbuf1) + 1); + if (!cobd->cobd_real_name) GOTO(exit, rc = -ENOMEM); - memcpy(cobd->master_name, lcfg->lcfg_inlbuf1, + memcpy(cobd->cobd_real_name, lcfg->lcfg_inlbuf1, strlen(lcfg->lcfg_inlbuf1)); - OBD_ALLOC(cobd->cache_name, strlen(lcfg->lcfg_inlbuf2) + 1); - if (!cobd->cache_name) + OBD_ALLOC(cobd->cobd_cache_name, strlen(lcfg->lcfg_inlbuf2) + 1); + if (!cobd->cobd_cache_name) GOTO(exit, rc = -ENOMEM); - memcpy(cobd->cache_name, lcfg->lcfg_inlbuf2, + memcpy(cobd->cobd_cache_name, lcfg->lcfg_inlbuf2, strlen(lcfg->lcfg_inlbuf2)); #if 0 - /* don't bother checking attached/setup; obd_connect() should, and it - * can change underneath us */ - rc = connect_to_obd(cobd->master_name, &master_conn); + /* don't bother checking attached/setup; + * obd_connect() should, and it can change underneath us */ + rc = connect_to_obd(cobd->cobd_real_name, &real_conn); if (rc != 0) GOTO(exit, rc); - cobd->master_exp = class_conn2export(&master_conn); + cobd->cobd_real_exp = class_conn2export(&real_conn); #endif - rc = connect_to_obd(cobd->cache_name, &cache_conn); + rc = connect_to_obd(cobd->cobd_cache_name, &cache_conn); if (rc != 0) { - obd_disconnect(cobd->cache_exp, 0); + obd_disconnect(cobd->cobd_cache_exp, 0); GOTO(exit, rc); } - cobd->cache_exp = class_conn2export(&cache_conn); + cobd->cobd_cache_exp = class_conn2export(&cache_conn); + cobd->cache_on = 1; - - if (!strcmp(master->obd_type->typ_name, LUSTRE_MDC_NAME)) { - int mds_type; - - mds_type = MDS_MASTER_OBD; - obd_set_info(cobd->master_exp, strlen("mds_type"), - "mds_type", sizeof(mds_type), &mds_type); - - mds_type = MDS_CACHE_OBD; - obd_set_info(cobd->cache_exp, strlen("mds_type"), - "mds_type", sizeof(mds_type), &mds_type); + if (!strcmp(real->obd_type->typ_name, LUSTRE_MDC_NAME)) { + /* set mds_num for lustre */ + int mds_num; + mds_num = REAL_MDS_NUMBER; + obd_set_info(cobd->cobd_real_exp, strlen("mds_num"), + "mds_num", sizeof(mds_num), &mds_num); + mds_num = CACHE_MDS_NUMBER; + obd_set_info(cobd->cobd_cache_exp, strlen("mds_num"), + "mds_num", sizeof(mds_num), &mds_num); } + /*default write to real obd*/ exit: if (rc) { - if (cobd->cache_name) - OBD_FREE(cobd->cache_name, - strlen(cobd->cache_name) + 1); - if (cobd->master_name) - OBD_FREE(cobd->master_name, - strlen(cobd->master_name) + 1); + if (cobd->cobd_cache_name) + OBD_FREE(cobd->cobd_cache_name, + strlen(cobd->cobd_cache_name) + 1); + if (cobd->cobd_real_name) + OBD_FREE(cobd->cobd_real_name, + strlen(cobd->cobd_real_name) + 1); } RETURN(rc); } @@ -159,20 +157,20 @@ static int cobd_cleanup(struct obd_device *obd, int flags) if (!list_empty(&obd->obd_exports)) return (-EBUSY); - if (cobd->cache_name) - OBD_FREE(cobd->cache_name, - strlen(cobd->cache_name) + 1); - if (cobd->master_name) - OBD_FREE(cobd->master_name, - strlen(cobd->master_name) + 1); + if (cobd->cobd_cache_name) + OBD_FREE(cobd->cobd_cache_name, + strlen(cobd->cobd_cache_name) + 1); + if (cobd->cobd_real_name) + OBD_FREE(cobd->cobd_real_name, + strlen(cobd->cobd_real_name) + 1); if (cobd->cache_on) { - rc = obd_disconnect(cobd->cache_exp, flags); + rc = obd_disconnect(cobd->cobd_cache_exp, flags); if (rc != 0) CERROR("error %d disconnecting cache\n", rc); } - rc = obd_disconnect(cobd->master_exp, flags); + rc = obd_disconnect(cobd->cobd_real_exp, flags); if (rc != 0) - CERROR("error %d disconnecting master\n", rc); + CERROR("error %d disconnecting real\n", rc); return (rc); } @@ -182,21 +180,25 @@ struct obd_export *cobd_get_exp(struct obd_device *obd) struct cache_obd *cobd = &obd->u.cobd; if (cobd->cache_on) - return cobd->cache_exp; + return cobd->cobd_cache_exp; else - return cobd->master_exp; + return cobd->cobd_real_exp; } static int cobd_connect(struct lustre_handle *conn, struct obd_device *obd, struct obd_uuid *cluuid, unsigned long connect_flags) { - return class_connect(conn, obd, cluuid); + int rc; + rc = class_connect(conn, obd, cluuid); + return rc; } static int cobd_disconnect(struct obd_export *exp, int flags) { - return class_disconnect(exp, 0); + int rc; + rc = class_disconnect(exp, 0); + return rc; } static int cobd_get_info(struct obd_export *exp, obd_count keylen, @@ -204,15 +206,14 @@ static int cobd_get_info(struct obd_export *exp, obd_count keylen, { struct obd_device *obd = class_exp2obd(exp); struct obd_export *cobd_exp; - if (obd == NULL) { CERROR("invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); return -EINVAL; } cobd_exp = cobd_get_exp(obd); - /* intercept cache utilisation info? */ + return obd_get_info(cobd_exp, keylen, key, vallen, val); } @@ -228,8 +229,8 @@ static int cobd_set_info(struct obd_export *exp, obd_count keylen, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - /* intercept cache utilisation info? */ + return obd_set_info(cobd_exp, keylen, key, vallen, val); } @@ -310,7 +311,7 @@ static int cobd_destroy(struct obd_export *exp, struct obdo *obdo, static int cobd_precleanup(struct obd_device *obd, int flags) { - /* FIXME-WANGDI: do we need some cleanup here? */ + /*FIXME Do we need some cleanup here?*/ return 0; } @@ -330,8 +331,8 @@ static int cobd_getattr(struct obd_export *exp, struct obdo *oa, } static int cobd_getattr_async(struct obd_export *exp, - struct obdo *obdo, struct lov_stripe_md *ea, - struct ptlrpc_request_set *set) + struct obdo *obdo, struct lov_stripe_md *ea, + struct ptlrpc_request_set *set) { struct obd_device *obd = class_exp2obd(exp); struct obd_export *cobd_exp; @@ -361,8 +362,7 @@ static int cobd_setattr(struct obd_export *exp, struct obdo *obdo, return obd_setattr(cobd_exp, obdo, ea, oti); } -static int cobd_md_getstatus(struct obd_export *exp, - struct lustre_id *rootid) +static int cobd_md_getstatus(struct obd_export *exp, struct ll_fid *rootfid) { struct obd_device *obd = class_exp2obd(exp); struct obd_export *cobd_exp; @@ -373,7 +373,7 @@ static int cobd_md_getstatus(struct obd_export *exp, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_getstatus(cobd_exp, rootid); + return md_getstatus(cobd_exp, rootfid); } static int cobd_brw(int cmd, struct obd_export *exp, struct obdo *oa, @@ -675,7 +675,8 @@ static int cobd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa, static int cobd_flush(struct obd_device *obd) { - /* flush the filesystem from the cache to the real device. */ + /*FLUSH the filesystem from the cache + *to the real device */ return 0; } @@ -684,7 +685,7 @@ static int cobd_iocontrol(unsigned int cmd, struct obd_export *exp, int len, { struct obd_device *obd = class_exp2obd(exp); struct cache_obd *cobd = &obd->u.cobd; - struct obd_device *master_dev = NULL; + struct obd_device *real_dev = NULL; struct obd_export *cobd_exp; int rc = 0; @@ -693,39 +694,39 @@ static int cobd_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (!cobd->cache_on) { struct lustre_handle cache_conn = {0,}; - rc = obd_disconnect(cobd->master_exp, 0); + rc = obd_disconnect(cobd->cobd_real_exp, 0); if (rc != 0) - CERROR("error %d disconnecting master\n", rc); - rc = connect_to_obd(cobd->cache_name, &cache_conn); + CERROR("error %d disconnecting real\n", rc); + rc = connect_to_obd(cobd->cobd_cache_name, &cache_conn); if (rc != 0) RETURN(rc); - cobd->cache_exp = class_conn2export(&cache_conn); + cobd->cobd_cache_exp = class_conn2export(&cache_conn); cobd->cache_on = 1; } break; case OBD_IOC_COBD_COFF: if (cobd->cache_on) { - struct lustre_handle master_conn = {0,}; + struct lustre_handle real_conn = {0,}; struct obd_device *cache_dev = NULL; int m_easize, m_cooksize; - cache_dev = class_exp2obd(cobd->cache_exp); + cache_dev = class_exp2obd(cobd->cobd_cache_exp); m_easize = cache_dev->u.cli.cl_max_mds_easize; m_cooksize = cache_dev->u.cli.cl_max_mds_cookiesize; - rc = obd_disconnect(cobd->cache_exp, 0); + rc = obd_disconnect(cobd->cobd_cache_exp, 0); if (rc != 0) - CERROR("error %d disconnecting master\n", rc); + CERROR("error %d disconnecting real\n", rc); - /* FIXME-WANGDI: should we read from master_dev? */ + /*FIXME, should read from real_dev*/ - rc = connect_to_obd(cobd->master_name, &master_conn); + rc = connect_to_obd(cobd->cobd_real_name, &real_conn); if (rc != 0) RETURN(rc); - cobd->master_exp = class_conn2export(&master_conn); - master_dev = class_exp2obd(cobd->master_exp); - master_dev->u.cli.cl_max_mds_easize = m_easize; - master_dev->u.cli.cl_max_mds_cookiesize = m_cooksize; + cobd->cobd_real_exp = class_conn2export(&real_conn); + real_dev = class_exp2obd(cobd->cobd_real_exp); + real_dev->u.cli.cl_max_mds_easize = m_easize; + real_dev->u.cli.cl_max_mds_cookiesize = m_cooksize; cobd->cache_on = 0; } break; @@ -832,7 +833,7 @@ static int cobd_import_event(struct obd_device *obd, return 0; } -static int cobd_md_getattr(struct obd_export *exp, struct lustre_id *id, +static int cobd_md_getattr(struct obd_export *exp, struct ll_fid *fid, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request) { @@ -845,7 +846,7 @@ static int cobd_md_getattr(struct obd_export *exp, struct lustre_id *id, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_getattr(cobd_exp, id, valid, ea_size, request); + return md_getattr(cobd_exp, fid, valid, ea_size, request); } static int cobd_md_req2lustre_md (struct obd_export *mdc_exp, @@ -864,7 +865,7 @@ static int cobd_md_req2lustre_md (struct obd_export *mdc_exp, return md_req2lustre_md(cobd_exp, req, offset, osc_exp, md); } -static int cobd_md_change_cbdata(struct obd_export *exp, struct lustre_id *id, +static int cobd_md_change_cbdata(struct obd_export *exp, struct ll_fid *fid, ldlm_iterator_t it, void *data) { struct obd_device *obd = class_exp2obd(exp); @@ -876,12 +877,14 @@ static int cobd_md_change_cbdata(struct obd_export *exp, struct lustre_id *id, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_change_cbdata(cobd_exp, id, it, data); + return md_change_cbdata(cobd_exp, fid, it, data); } -static int cobd_md_getattr_name(struct obd_export *exp, struct lustre_id *id, - char *filename, int namelen, unsigned long valid, - unsigned int ea_size, struct ptlrpc_request **request) +static int cobd_md_getattr_name(struct obd_export *exp, struct ll_fid *fid, + char *filename, int namelen, + unsigned long valid, + unsigned int ea_size, + struct ptlrpc_request **request) { struct obd_device *obd = class_exp2obd(exp); struct obd_export *cobd_exp; @@ -892,7 +895,7 @@ static int cobd_md_getattr_name(struct obd_export *exp, struct lustre_id *id, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_getattr_name(cobd_exp, id, filename, namelen, valid, + return md_getattr_name(cobd_exp, fid, filename, namelen, valid, ea_size, request); } @@ -929,8 +932,7 @@ static int cobd_md_unlink(struct obd_export *exp, struct mdc_op_data *data, return md_unlink(cobd_exp, data, request); } -static int cobd_md_valid_attrs(struct obd_export *exp, - struct lustre_id *id) +static int cobd_md_valid_attrs(struct obd_export *exp, struct ll_fid *fid) { struct obd_device *obd = class_exp2obd(exp); struct obd_export *cobd_exp; @@ -941,7 +943,7 @@ static int cobd_md_valid_attrs(struct obd_export *exp, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_valid_attrs(cobd_exp, id); + return md_valid_attrs(cobd_exp, fid); } static int cobd_md_rename(struct obd_export *exp, struct mdc_op_data *data, @@ -991,8 +993,7 @@ static int cobd_md_setattr(struct obd_export *exp, struct mdc_op_data *data, return md_setattr(cobd_exp, data, iattr, ea, ealen, ea2, ea2len, request); } -static int cobd_md_readpage(struct obd_export *exp, - struct lustre_id *mdc_id, +static int cobd_md_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, __u64 offset, struct page *page, struct ptlrpc_request **request) { @@ -1005,7 +1006,7 @@ static int cobd_md_readpage(struct obd_export *exp, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_readpage(cobd_exp, mdc_id, offset, page, request); + return md_readpage(cobd_exp, mdc_fid, offset, page, request); } static int cobd_md_close(struct obd_export *exp, struct obdo *obdo, @@ -1038,7 +1039,7 @@ static int cobd_md_done_writing(struct obd_export *exp, struct obdo *obdo) return md_done_writing(cobd_exp, obdo); } -static int cobd_md_sync(struct obd_export *exp, struct lustre_id *id, +static int cobd_md_sync(struct obd_export *exp, struct ll_fid *fid, struct ptlrpc_request **request) { struct obd_device *obd = class_exp2obd(exp); @@ -1051,7 +1052,7 @@ static int cobd_md_sync(struct obd_export *exp, struct lustre_id *id, } cobd_exp = cobd_get_exp(obd); - return md_sync(cobd_exp, id, request); + return md_sync(cobd_exp, fid, request); } static int cobd_md_set_open_replay_data(struct obd_export *exp, @@ -1140,9 +1141,10 @@ static int cobd_md_enqueue(struct obd_export *exp, int lock_type, cb_data); } -static int cobd_md_intent_lock(struct obd_export *exp, struct lustre_id *pid, - const char *name, int len, void *lmm, int lmmsize, - struct lustre_id *cid, struct lookup_intent *it, +static int cobd_md_intent_lock(struct obd_export *exp, + struct ll_fid *pfid, const char *name, int len, + void *lmm, int lmmsize, + struct ll_fid *cfid, struct lookup_intent *it, int lookup_flags, struct ptlrpc_request **reqp, ldlm_blocking_callback cb_blocking) { @@ -1155,12 +1157,12 @@ static int cobd_md_intent_lock(struct obd_export *exp, struct lustre_id *pid, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_intent_lock(cobd_exp, pid, name, len, lmm, lmmsize, - cid, it, lookup_flags, reqp, cb_blocking); + return md_intent_lock(cobd_exp, pfid, name, len, lmm, lmmsize, + cfid, it, lookup_flags, reqp, cb_blocking); } -static struct obd_device *cobd_md_get_real_obd(struct obd_export *exp, - char *name, int len) +static struct obd_device * cobd_md_get_real_obd(struct obd_export *exp, + char *name, int len) { struct obd_device *obd = class_exp2obd(exp); struct obd_export *cobd_exp; @@ -1175,8 +1177,8 @@ static struct obd_device *cobd_md_get_real_obd(struct obd_export *exp, } static int cobd_md_change_cbdata_name(struct obd_export *exp, - struct lustre_id *id, char *name, - int namelen, struct lustre_id *id2, + struct ll_fid *fid, char *name, + int namelen, struct ll_fid *fid2, ldlm_iterator_t it, void *data) { struct obd_device *obd = class_exp2obd(exp); @@ -1188,8 +1190,8 @@ static int cobd_md_change_cbdata_name(struct obd_export *exp, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_change_cbdata_name(cobd_exp, id, name, namelen, - id2, it, data); + return md_change_cbdata_name(cobd_exp, fid, name, namelen, fid2, it, + data); } static struct obd_ops cobd_obd_ops = { .o_owner = THIS_MODULE, diff --git a/lustre/cobd/lproc_cache.c b/lustre/cobd/lproc_cache.c index a40f42d..25b1e3a 100644 --- a/lustre/cobd/lproc_cache.c +++ b/lustre/cobd/lproc_cache.c @@ -41,7 +41,7 @@ static int cobd_rd_target(char *page, char **start, off_t off, int count, rc = snprintf(page, count, "not set up\n"); } else { struct obd_device *tgt = - class_exp2obd(cobd->u.cobd.master_exp); + class_exp2obd(cobd->u.cobd.cobd_real_exp); LASSERT(tgt != NULL); rc = snprintf(page, count, "%s\n", tgt->obd_uuid.uuid); } @@ -60,7 +60,7 @@ static int cobd_rd_cache(char *page, char **start, off_t off, int count, rc = snprintf(page, count, "not set up\n"); } else { struct obd_device *cache = - class_exp2obd(cobd->u.cobd.cache_exp); + class_exp2obd(cobd->u.cobd.cobd_cache_exp); LASSERT(cache != NULL); rc = snprintf(page, count, "%s\n", cache->obd_uuid.uuid); } diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h index f32b34e..3c602cd 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -363,7 +363,6 @@ struct page { #define PAGE_LIST_ENTRY list #define PAGE_LIST(page) ((page)->list) -#define page_address(page) ((page)->addr) #define kmap(page) (page)->addr #define kunmap(a) do {} while (0) @@ -675,6 +674,13 @@ typedef struct { volatile int counter; } atomic_t; #define atomic_add(b,a) do {(a)->counter += b;} while (0) #define atomic_sub(b,a) do {(a)->counter -= b;} while (0) +#ifndef likely +#define likely(exp) (exp) +#endif +#ifndef unlikely +#define unlikely(exp) (exp) +#endif + /* FIXME sys/capability will finally included linux/fs.h thus * cause numerous trouble on x86-64. as temporary solution for * build broken at cary, we copy definition we need from capability.h diff --git a/lustre/include/linux/lustre_fsfilt.h b/lustre/include/linux/lustre_fsfilt.h index 32cd252..0287964 100644 --- a/lustre/include/linux/lustre_fsfilt.h +++ b/lustre/include/linux/lustre_fsfilt.h @@ -57,24 +57,10 @@ struct fsfilt_operations { struct iattr *iattr, int do_trunc); int (* fs_iocontrol)(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); - - /* two methods for getting lov EA and setting it back to inode xattr. */ int (* fs_set_md)(struct inode *inode, void *handle, void *md, int size); int (* fs_get_md)(struct inode *inode, void *md, int size); - /* two methods for getting MID (master id) EA and setting it back to - * inode xattr. */ - int (* fs_set_mid)(struct inode *inode, void *handle, void *fid, - int size); - int (* fs_get_mid)(struct inode *inode, void *fid, int size); - - /* two methods for getting self id EA and setting it back to inode - * xattr. */ - int (* fs_set_sid)(struct inode *inode, void *handle, void *sid, - int size); - int (* fs_get_sid)(struct inode *inode, void *sid, int size); - /* this method is needed to make IO operation fsfilt nature depend. */ int (* fs_send_bio)(int rw, struct inode *inode,struct kiobuf *bio); @@ -139,7 +125,7 @@ struct fsfilt_operations { int (* fs_get_op_len)(int, struct fsfilt_objinfo *, int); int (* fs_add_dir_entry)(struct obd_device *, struct dentry *, char *, int, unsigned long, unsigned long, - unsigned long, unsigned long); + unsigned); int (* fs_del_dir_entry)(struct obd_device *, struct dentry *); /*snap operations*/ int (* fs_is_redirector)(struct inode *inode); @@ -389,7 +375,6 @@ static inline int fsfilt_setup(struct obd_device *obd, return obd->obd_fsops->fs_setup(obd, fs); return 0; } - static inline int fsfilt_set_md(struct obd_device *obd, struct inode *inode, void *handle, void *md, int size) @@ -404,34 +389,6 @@ fsfilt_get_md(struct obd_device *obd, struct inode *inode, return obd->obd_fsops->fs_get_md(inode, md, size); } -static inline int -fsfilt_set_mid(struct obd_device *obd, struct inode *inode, - void *handle, void *mid, int size) -{ - return obd->obd_fsops->fs_set_mid(inode, handle, mid, size); -} - -static inline int -fsfilt_get_mid(struct obd_device *obd, struct inode *inode, - void *mid, int size) -{ - return obd->obd_fsops->fs_get_mid(inode, mid, size); -} - -static inline int -fsfilt_set_sid(struct obd_device *obd, struct inode *inode, - void *handle, void *sid, int size) -{ - return obd->obd_fsops->fs_set_sid(inode, handle, sid, size); -} - -static inline int -fsfilt_get_sid(struct obd_device *obd, struct inode *inode, - void *sid, int size) -{ - return obd->obd_fsops->fs_get_sid(inode, sid, size); -} - static inline int fsfilt_send_bio(int rw, struct obd_device *obd, struct inode *inode, void *bio) { @@ -502,10 +459,10 @@ fsfilt_readpage(struct obd_device *obd, struct file *file, char *buf, static inline int fsfilt_add_journal_cb(struct obd_device *obd, struct super_block *sb, - __u64 last_num, void *handle, fsfilt_cb_t cb_func, + __u64 last_rcvd, void *handle, fsfilt_cb_t cb_func, void *cb_data) { - return obd->obd_fsops->fs_add_journal_cb(obd, sb, last_num, handle, + return obd->obd_fsops->fs_add_journal_cb(obd, sb, last_rcvd, handle, cb_func, cb_data); } @@ -701,15 +658,11 @@ fsfilt_set_mds_flags(struct obd_device *obd, struct super_block *sb) static inline int fsfilt_add_dir_entry(struct obd_device *obd, struct dentry *dir, char *name, int namelen, unsigned long ino, - unsigned long generation, unsigned long mds, - unsigned long fid) + unsigned long generation, unsigned mds) { LASSERT(obd->obd_fsops->fs_add_dir_entry); - return obd->obd_fsops->fs_add_dir_entry(obd, dir, name, - namelen, ino, - generation, mds, - fid); + namelen, ino, generation, mds); } static inline int diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index 5c7d80d..66e79f1 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -267,9 +267,7 @@ typedef uint32_t obd_count; #define OBD_FL_RECREATE_OBJS (0x00000020) // recreate missing obj #define OBD_FL_DEBUG_CHECK (0x00000040) /* echo client/server debug check */ -/* this should be sizeof(struct lustre_handle) + sizeof(struct llog_cookie) + - * sizeof(struct lustre_id). */ -#define OBD_INLINESZ (80) +#define OBD_INLINESZ 64 /* Note: 64-bit types are 64-bit aligned in structure */ struct obdo { @@ -292,7 +290,6 @@ struct obdo { obd_count o_misc; /* brw: o_dropped */ __u32 o_easize; /* epoch in ost writes */ __u32 o_mds; - __u64 o_fid; __u32 o_padding; char o_inline[OBD_INLINESZ]; /* fid in ost writes */ }; @@ -377,8 +374,7 @@ struct lov_mds_md_v0 { /* LOV EA mds/wire data (little-endian) */ #define OBD_MD_FLGRANT (0x08000000) /* ost preallocation space grant */ #define OBD_MD_MDS (0x10000000) /* where an inode lives on */ #define OBD_MD_FLDIREA (0x20000000) /* dir's extended attribute data */ -#define OBD_MD_REINT (0x40000000) /* reintegrate oa */ -#define OBD_MD_FID (0x80000000) /* take care about fid component */ +#define OBD_MD_REINT (0x40000000) /* reintegrate oa*/ #define OBD_MD_FLNOTOBD (~(OBD_MD_FLBLOCKS | OBD_MD_LINKNAME|\ OBD_MD_FLEASIZE | OBD_MD_FLHANDLE | OBD_MD_FLCKSUM|\ OBD_MD_FLQOS | OBD_MD_FLOSCOPQ | OBD_MD_FLCOOKIE|\ @@ -395,9 +391,8 @@ static inline struct llog_cookie *obdo_logcookie(struct obdo *oa) return (struct llog_cookie *)(oa->o_inline + sizeof(struct lustre_handle)); } - -/* don't forget obdo_fid which is way down at the bottom so it can come after - * the definition of llog_cookie */ +/* don't forget obdo_fid which is way down at the bottom so it can + * come after the definition of llog_cookie */ struct obd_statfs { __u64 os_type; @@ -455,7 +450,6 @@ struct ost_body { extern void lustre_swab_ost_body (struct ost_body *b); extern void lustre_swab_ost_last_id(obd_id *id); -extern void lustre_swab_generic_32s(__u32 *val); /* lock value block communicated between the filter and llite */ @@ -529,58 +523,43 @@ typedef enum { * Do not exceed 63 */ -#define REINT_SETATTR 1 -#define REINT_CREATE 2 -#define REINT_LINK 3 -#define REINT_UNLINK 4 -#define REINT_RENAME 5 -#define REINT_OPEN 6 -#define REINT_CLOSE 7 -#define REINT_WRITE 8 -#define REINT_MAX 8 +#define REINT_SETATTR 1 +#define REINT_CREATE 2 +#define REINT_LINK 3 +#define REINT_UNLINK 4 +#define REINT_RENAME 5 +#define REINT_OPEN 6 +#define REINT_CLOSE 7 +#define REINT_WRITE 8 +#define REINT_MAX 8 /* the disposition of the intent outlines what was executed */ -#define DISP_IT_EXECD (1 << 0) -#define DISP_LOOKUP_EXECD (1 << 1) -#define DISP_LOOKUP_NEG (1 << 2) -#define DISP_LOOKUP_POS (1 << 3) -#define DISP_OPEN_CREATE (1 << 4) -#define DISP_OPEN_OPEN (1 << 5) -#define DISP_ENQ_COMPLETE (1 << 6) +#define DISP_IT_EXECD 0x01 +#define DISP_LOOKUP_EXECD 0x02 +#define DISP_LOOKUP_NEG 0x04 +#define DISP_LOOKUP_POS 0x08 +#define DISP_OPEN_CREATE 0x10 +#define DISP_OPEN_OPEN 0x20 +#define DISP_ENQ_COMPLETE 0x40 /* INODE LOCK PARTS */ -#define MDS_INODELOCK_LOOKUP 0x000001 /* dentry, mode, owner, group */ -#define MDS_INODELOCK_UPDATE 0x000002 /* size, links, timestamps */ - -/* lustre store cookie */ -struct lustre_stc { - union { - struct { - __u64 l3s_ino; /* inode number on local MDS */ - __u32 l3s_gen; /* inode generation */ - __u32 l3s_type; /* inode type */ - } e3s; - } u; -}; - -/* lustre file id */ -struct lustre_fid { - __u64 lf_id; /* fid counter maintained on per - group basis */ - __u64 lf_group; /* sequence group num */ - __u32 lf_version; /* what snapfs version of inode */ - __u32 lf_padding; -}; - -struct lustre_id { - struct lustre_stc li_stc; /* store cookie */ - struct lustre_fid li_fid; /* fid cookie */ +#define MDS_INODELOCK_LOOKUP 0x000001 /* dentry, mode, owner, group */ +#define MDS_INODELOCK_UPDATE 0x000002 /* size, links, timestamps */ +//#define MDS_INODELOCK_MAXSHIFT 1 +//#define MDS_INODELOCK_FULL ((1<<(MDS_INODELOCK_MAXSHIFT+1))-1) + +struct ll_fid { + __u64 id; + __u32 generation; + __u32 f_type; + __u32 mds; + __u32 padding; }; struct mea_old { __u32 mea_count; __u32 mea_master; - struct lustre_id mea_ids[0]; + struct ll_fid mea_fids[0]; }; #define MEA_MAGIC_LAST_CHAR 0xb2221ca1 @@ -590,9 +569,11 @@ struct mea { __u32 mea_magic; __u32 mea_count; __u32 mea_master; - struct lustre_id mea_ids[0]; + struct ll_fid mea_fids[0]; }; +extern void lustre_swab_ll_fid (struct ll_fid *fid); + #define MDS_STATUS_CONN 1 #define MDS_STATUS_LOV 2 @@ -601,20 +582,18 @@ struct mds_status_req { __u32 repbuf; }; -extern void lustre_swab_lustre_id(struct lustre_id *id); -extern void lustre_swab_lustre_stc(struct lustre_stc *stc); -extern void lustre_swab_lustre_fid(struct lustre_fid *fid); extern void lustre_swab_mds_status_req (struct mds_status_req *r); #define MDS_BFLAG_UNCOMMITTED_WRITES 0x1 struct mds_body { - struct lustre_id id1; - struct lustre_id id2; + struct ll_fid fid1; + struct ll_fid fid2; struct lustre_handle handle; __u64 size; /* Offset, in the case of MDS_READPAGE */ __u64 blocks; /* XID, in the case of MDS_READPAGE */ __u64 io_epoch; + __u32 ino; /* make this a __u64 */ __u32 valid; __u32 mode; __u32 uid; @@ -622,10 +601,12 @@ struct mds_body { __u32 mtime; __u32 ctime; __u32 atime; - __u32 flags; /* from vfs for pin/unpin, MDS_BFLAG for close */ + __u32 flags; /* from vfs for pin/unpin, MDS_BFLAG for close */ __u32 rdev; - __u32 nlink; /* #bytes to read in the case of MDS_READPAGE */ + __u32 nlink; /* #bytes to read in the case of MDS_READPAGE */ + __u32 generation; __u32 eadatasize; + __u32 mds; }; extern void lustre_swab_mds_body (struct mds_body *b); @@ -637,32 +618,31 @@ struct lustre_md { }; struct mdc_op_data { - struct lustre_id id1; - struct lustre_id id2; + struct ll_fid fid1; + struct ll_fid fid2; __u64 mod_time; const char *name; int namelen; __u32 create_mode; struct mea *mea1; /* mea of inode1 */ struct mea *mea2; /* mea of inode2 */ - __u32 valid; }; #define MDS_MODE_DONT_LOCK (1 << 30) #define MDS_MODE_REPLAY (1 << 31) struct mds_rec_setattr { - __u32 sa_opcode; - __u32 sa_valid; - struct lustre_id sa_id; - __u32 sa_mode; - __u32 sa_uid; - __u32 sa_gid; - __u32 sa_attr_flags; - __u64 sa_size; - __u64 sa_atime; - __u64 sa_mtime; - __u64 sa_ctime; + __u32 sa_opcode; + __u32 sa_valid; + struct ll_fid sa_fid; + __u32 sa_mode; + __u32 sa_uid; + __u32 sa_gid; + __u32 sa_attr_flags; + __u64 sa_size; + __u64 sa_atime; + __u64 sa_mtime; + __u64 sa_ctime; }; /* Remove this once we declare it in include/linux/fs.h (v21 kernel patch?) */ @@ -686,49 +666,49 @@ extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa); #define MDS_OPEN_SYNC 00010000 #define MDS_OPEN_DIRECTORY 00200000 -#define MDS_OPEN_DELAY_CREATE 0100000000 /* delay initial object create */ -#define MDS_OPEN_HAS_EA 010000000000 /* specify object create pattern */ -#define MDS_OPEN_HAS_OBJS 020000000000 /* Just set the EA the obj exist */ +#define MDS_OPEN_DELAY_CREATE 0100000000 /* delay initial object create */ +#define MDS_OPEN_HAS_EA 010000000000 /* specify object create pattern */ +#define MDS_OPEN_HAS_OBJS 020000000000 /* Just set the EA the obj exist */ struct mds_rec_create { - __u32 cr_opcode; - __u32 cr_flags; /* for use with open */ - __u32 cr_mode; - __u32 cr_padding; - struct lustre_id cr_id; - struct lustre_id cr_replayid; - __u64 cr_time; - __u64 cr_rdev; + __u32 cr_opcode; + __u32 cr_flags; /* for use with open */ + __u32 cr_mode; + __u32 cr_padding; + struct ll_fid cr_fid; + struct ll_fid cr_replayfid; + __u64 cr_time; + __u64 cr_rdev; }; extern void lustre_swab_mds_rec_create (struct mds_rec_create *cr); struct mds_rec_link { - __u32 lk_opcode; - __u32 lk_padding; - struct lustre_id lk_id1; - struct lustre_id lk_id2; - __u64 lk_time; + __u32 lk_opcode; + __u32 lk_padding; + struct ll_fid lk_fid1; + struct ll_fid lk_fid2; + __u64 lk_time; }; extern void lustre_swab_mds_rec_link (struct mds_rec_link *lk); struct mds_rec_unlink { - __u32 ul_opcode; - __u32 ul_mode; - struct lustre_id ul_id1; - struct lustre_id ul_id2; - __u64 ul_time; + __u32 ul_opcode; + __u32 ul_mode; + struct ll_fid ul_fid1; + struct ll_fid ul_fid2; + __u64 ul_time; }; extern void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul); struct mds_rec_rename { - __u32 rn_opcode; - __u32 rn_padding; - struct lustre_id rn_id1; - struct lustre_id rn_id2; - __u64 rn_time; + __u32 rn_opcode; + __u32 rn_padding; + struct ll_fid rn_fid1; + struct ll_fid rn_fid2; + __u64 rn_time; }; extern void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn); @@ -872,11 +852,11 @@ extern void lustre_swab_ldlm_reply (struct ldlm_reply *r); * ptlbd, portal block device requests */ typedef enum { - PTLBD_QUERY = 200, - PTLBD_READ = 201, - PTLBD_WRITE = 202, - PTLBD_FLUSH = 203, - PTLBD_CONNECT = 204, + PTLBD_QUERY = 200, + PTLBD_READ = 201, + PTLBD_WRITE = 202, + PTLBD_FLUSH = 203, + PTLBD_CONNECT = 204, PTLBD_DISCONNECT = 205, PTLBD_LAST_OPC } ptlbd_cmd_t; @@ -987,7 +967,7 @@ struct llog_logid_rec { struct llog_create_rec { struct llog_rec_hdr lcr_hdr; - struct lustre_id lcr_id; + struct ll_fid lcr_fid; obd_id lcr_oid; obd_count lcr_ogen; __u32 padding; @@ -1012,7 +992,7 @@ struct llog_unlink_rec { struct llog_size_change_rec { struct llog_rec_hdr lsc_hdr; - struct lustre_id lsc_id; + struct ll_fid lsc_fid; __u32 lsc_io_epoch; __u32 padding; struct llog_rec_tail lsc_tail; @@ -1031,8 +1011,8 @@ struct llog_gen_rec { struct llog_lru_rec { struct llog_rec_hdr llr_hdr; - struct lustre_id llr_cid; - struct lustre_id llr_pid; + struct ll_fid llr_cfid; + struct ll_fid llr_pfid; struct llog_rec_tail llr_tail; } __attribute__((packed)); @@ -1107,12 +1087,10 @@ extern void lustre_swab_llogd_body (struct llogd_body *d); extern void lustre_swab_llog_hdr (struct llog_log_hdr *h); extern void lustre_swab_llogd_conn_body (struct llogd_conn_body *d); -static inline struct lustre_id *obdo_id(struct obdo *oa) +static inline struct ll_fid *obdo_fid(struct obdo *oa) { - void *raw_id = oa->o_inline + sizeof(struct lustre_handle) + - sizeof(struct llog_cookie); - - return (struct lustre_id *)raw_id; + return (struct ll_fid *)(oa->o_inline + sizeof(struct lustre_handle) + + sizeof(struct llog_cookie)); } #endif diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index 868a4dd..7a9d350 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -64,15 +64,6 @@ #endif #endif -/* lustre_id output helper macros */ -#define DLID4 "%lu/%lu/%lu/%lu" - -#define OLID4(id) \ - (unsigned long)(id)->li_fid.lf_id, \ - (unsigned long)(id)->li_fid.lf_group, \ - (unsigned long)(id)->li_stc.u.e3s.l3s_ino, \ - (unsigned long)(id)->li_stc.u.e3s.l3s_gen - /* target.c */ struct ptlrpc_request; struct recovd_data; diff --git a/lustre/include/linux/lustre_lite.h b/lustre/include/linux/lustre_lite.h index bd8341b..1c34c4c 100644 --- a/lustre/include/linux/lustre_lite.h +++ b/lustre/include/linux/lustre_lite.h @@ -40,6 +40,15 @@ /* careful, this is easy to screw up */ #define PAGE_CACHE_MAXBYTES ((__u64)(~0UL) << PAGE_CACHE_SHIFT) + +/* +struct lustre_intent_data { + __u64 it_lock_handle[2]; + __u32 it_disposition; + __u32 it_status; + __u32 it_lock_mode; + }; */ + #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0") static inline struct lookup_intent *ll_nd2it(struct nameidata *nd) @@ -67,17 +76,16 @@ extern struct file_operations ll_pgcache_seq_fops; #define LLI_F_HAVE_OST_SIZE_LOCK 0 #define LLI_F_HAVE_MDS_SIZE_LOCK 1 #define LLI_F_PREFER_EXTENDED_SIZE 2 - struct ll_inode_info { int lli_inode_magic; struct lov_stripe_md *lli_smd; struct mea *lli_mea; - struct lustre_id lli_id; /* full lustre_id */ char *lli_symlink_name; struct semaphore lli_open_sem; __u64 lli_maxbytes; __u64 lli_io_epoch; unsigned long lli_flags; + __u32 lli_mds; /* this lock protects s_d_w and p_w_ll */ spinlock_t lli_lock; @@ -143,34 +151,31 @@ enum { LPROC_LL_FILE_OPCODES }; -static inline void -ll_inode2id(struct lustre_id *id, struct inode *inode) +static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode) { - struct lustre_id *lid = &ll_i2info(inode)->lli_id; - - mdc_pack_id(id, inode->i_ino, inode->i_generation, - (inode->i_mode & S_IFMT), id_group(lid), - id_fid(lid)); + mdc_pack_fid(fid, inode->i_ino, inode->i_generation, + inode->i_mode & S_IFMT); + LASSERT(ll_i2info(inode)); + fid->mds = ll_i2info(inode)->lli_mds; } static inline void -ll_prepare_mdc_data(struct mdc_op_data *data, struct inode *i1, - struct inode *i2, const char *name, int namelen, - int mode) +ll_prepare_mdc_op_data(struct mdc_op_data *data, struct inode *i1, + struct inode *i2, const char *name, int namelen, + int mode) { LASSERT(i1); - ll_inode2id(&data->id1, i1); + ll_inode2fid(&data->fid1, i1); /* it could be directory with mea */ data->mea1 = ll_i2info(i1)->lli_mea; if (i2) { - ll_inode2id(&data->id2, i2); + ll_inode2fid(&data->fid2, i2); data->mea2 = ll_i2info(i2)->lli_mea; } - data->valid = 0; data->name = name; data->namelen = namelen; data->create_mode = mode; diff --git a/lustre/include/linux/lustre_mds.h b/lustre/include/linux/lustre_mds.h index 2db1dcc..c125662 100644 --- a/lustre/include/linux/lustre_mds.h +++ b/lustre/include/linux/lustre_mds.h @@ -53,29 +53,29 @@ struct ll_file_data; #define LUSTRE_MDC_NAME "mdc" struct mds_update_record { - __u32 ur_opcode; - struct lustre_id *ur_id1; - struct lustre_id *ur_id2; - int ur_namelen; - char *ur_name; - int ur_tgtlen; - char *ur_tgt; - int ur_eadatalen; - void *ur_eadata; - int ur_cookielen; + __u32 ur_opcode; + struct ll_fid *ur_fid1; + struct ll_fid *ur_fid2; + int ur_namelen; + char *ur_name; + int ur_tgtlen; + char *ur_tgt; + int ur_eadatalen; + void *ur_eadata; + int ur_cookielen; struct llog_cookie *ur_logcookies; - struct iattr ur_iattr; - struct lvfs_ucred ur_uc; - __u64 ur_rdev; - __u32 ur_mode; - __u64 ur_time; - __u32 ur_flags; + struct iattr ur_iattr; + struct lvfs_ucred ur_uc; + __u64 ur_rdev; + __u32 ur_mode; + __u64 ur_time; + __u32 ur_flags; }; -#define ur_fsuid ur_uc.luc_fsuid -#define ur_fsgid ur_uc.luc_fsgid -#define ur_cap ur_uc.luc_cap -#define ur_uid ur_uc.luc_uid +#define _ur_fsuid ur_uc.luc_fsuid +#define _ur_fsgid ur_uc.luc_fsgid +#define _ur_cap ur_uc.luc_cap +#define _ur_uid ur_uc.luc_uid #define MDS_LR_SERVER_SIZE 512 @@ -93,12 +93,12 @@ struct mds_update_record { #define MDS_INCOMPAT_SUPP (0) -#define MDS_MASTER_OBD 1 -#define MDS_CACHE_OBD 0 +#define REAL_MDS_NUMBER 1 +#define CACHE_MDS_NUMBER 0 /*flags for indicate the record are come from cmobd reint or mdc create */ -#define REC_REINT_CREATE 0x0001 +#define REC_REINT_CREATE 0x0001 /* Data stored per server at the head of the last_rcvd file. In le32 order. * Try to keep this the same as fsd_server_data so we might one day merge. */ @@ -172,17 +172,13 @@ int mds_reint_rec(struct mds_update_record *r, int offset, /* mds/handler.c */ #ifdef __KERNEL__ -struct dentry * -mds_id2dentry(struct obd_device *obd, struct lustre_id *id, - struct vfsmount **mnt); - -struct dentry * -mds_id2locked_dentry(struct obd_device *obd, struct lustre_id *id, - struct vfsmount **mnt, int lock_mode, - struct lustre_handle *lockh, int *pmode, - char *name, int namelen, __u64 lockpart); +struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid, + struct vfsmount **mnt, int lock_mode, + struct lustre_handle *lockh, int *pmode, + char *name, int namelen, __u64 lockpart); +struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, + struct vfsmount **mnt); int mds_update_server_data(struct obd_device *, int force_sync); -int mds_update_last_fid(struct obd_device *obd, int force_sync); /* mds/mds_fs.c */ int mds_fs_setup(struct obd_device *obddev, struct vfsmount *mnt); @@ -196,12 +192,13 @@ int it_disposition(struct lookup_intent *it, int flag); void it_set_disposition(struct lookup_intent *it, int flag); int it_open_error(int phase, struct lookup_intent *it); int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data); -int mdc_change_cbdata(struct obd_export *exp, struct lustre_id *id, +int mdc_change_cbdata(struct obd_export *exp, struct ll_fid *fid, ldlm_iterator_t it, void *data); -int mdc_intent_lock(struct obd_export *exp, struct lustre_id *parent, - const char *name, int len, void *lmm, int lmmsize, - struct lustre_id *child, struct lookup_intent *, int, - struct ptlrpc_request **reqp, +int mdc_intent_lock(struct obd_export *exp, struct ll_fid *parent, + const char *name, int len, void *lmm, int lmmsize, + struct ll_fid *child, + struct lookup_intent *, int, + struct ptlrpc_request **reqp, ldlm_blocking_callback cb_blocking); int mdc_enqueue(struct obd_export *exp, int lock_type, @@ -221,11 +218,11 @@ void mdc_pack_secdesc(struct ptlrpc_request *req, int size); int mdc_req2lustre_md(struct obd_export *exp_mdc, struct ptlrpc_request *req, unsigned int offset, struct obd_export *exp_osc, struct lustre_md *md); -int mdc_getstatus(struct obd_export *exp, struct lustre_id *rootid); -int mdc_getattr(struct obd_export *exp, struct lustre_id *id, +int mdc_getstatus(struct obd_export *exp, struct ll_fid *rootfid); +int mdc_getattr(struct obd_export *exp, struct ll_fid *fid, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request); -int mdc_getattr_name(struct obd_export *exp, struct lustre_id *id, +int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid, char *filename, int namelen, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request); int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data, @@ -234,9 +231,7 @@ int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data, int mdc_open(struct obd_export *exp, obd_id ino, int type, int flags, struct lov_mds_md *lmm, int lmm_size, struct lustre_handle *fh, struct ptlrpc_request **); - struct obd_client_handle; - int mdc_set_open_replay_data(struct obd_export *exp, struct obd_client_handle *och, struct ptlrpc_request *open_req); @@ -244,7 +239,7 @@ int mdc_clear_open_replay_data(struct obd_export *exp, struct obd_client_handle *och); int mdc_close(struct obd_export *, struct obdo *, struct obd_client_handle *, struct ptlrpc_request **); -int mdc_readpage(struct obd_export *exp, struct lustre_id *id, +int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, __u64, struct page *, struct ptlrpc_request **); int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data, const void *data, int datalen, int mode, __u32 uid, __u32 gid, @@ -256,23 +251,28 @@ int mdc_link(struct obd_export *exp, struct mdc_op_data *data, int mdc_rename(struct obd_export *exp, struct mdc_op_data *data, const char *old, int oldlen, const char *new, int newlen, struct ptlrpc_request **request); -int mdc_sync(struct obd_export *exp, struct lustre_id *id, +int mdc_sync(struct obd_export *exp, struct ll_fid *fid, struct ptlrpc_request **); int mdc_create_client(struct obd_uuid uuid, struct ptlrpc_client *cl); -/* store the generation of a newly-created inode in |req| for replay. */ -int mdc_store_inode_generation(struct obd_export *exp, - struct ptlrpc_request *req, +/* Store the generation of a newly-created inode in |req| for replay. */ +int mdc_store_inode_generation(struct obd_export *exp, struct ptlrpc_request *req, int reqoff, int repoff); - -int mdc_llog_process(struct obd_export *, char *, llog_cb_t, - void *); - -int mdc_done_writing(struct obd_export *, struct obdo *); +int mdc_llog_process(struct obd_export *, char *logname, llog_cb_t, void *data); +int mdc_done_writing(struct obd_export *exp, struct obdo *); +int mdc_reint(struct ptlrpc_request *request, struct mdc_rpc_lock *rpc_lock, + int level); +static inline void mdc_pack_fid(struct ll_fid *fid, obd_id ino, __u32 gen, + int type) +{ + fid->id = ino; + fid->generation = gen; + fid->f_type = type; +} /* ioctls for trying requests */ -#define IOC_REQUEST_TYPE 'f' -#define IOC_REQUEST_MIN_NR 30 +#define IOC_REQUEST_TYPE 'f' +#define IOC_REQUEST_MIN_NR 30 #define IOC_REQUEST_GETATTR _IOWR('f', 30, long) #define IOC_REQUEST_READPAGE _IOWR('f', 31, long) diff --git a/lustre/include/linux/lustre_net.h b/lustre/include/linux/lustre_net.h index aaec825..f3569c0 100644 --- a/lustre/include/linux/lustre_net.h +++ b/lustre/include/linux/lustre_net.h @@ -708,86 +708,15 @@ void *mdc_setattr_pack(struct lustre_msg *msg, int offset, struct mdc_op_data *data, struct iattr *iattr, void *ea, int ealen, void *ea2, int ea2len); void *mdc_create_pack(struct lustre_msg *msg, int offset, - struct mdc_op_data *op_data, __u32 mode, - __u64 rdev, const void *data, int datalen); + struct mdc_op_data *op_data, __u32 mode, __u64 rdev, + const void *data, int datalen); void *mdc_unlink_pack(struct lustre_msg *msg, int offset, struct mdc_op_data *data); void *mdc_link_pack(struct lustre_msg *msg, int offset, struct mdc_op_data *data); void *mdc_rename_pack(struct lustre_msg *msg, int offset, struct mdc_op_data *data, - const char *old, int oldlen, - const char *new, int newlen); - -/* lustre id helper functions and macros. */ -static inline -void mdc_pack_id(struct lustre_id *id, obd_id ino, - __u32 gen, int type, __u64 mds, - __u64 fid) -{ - LASSERT(id != NULL); - - id->li_fid.lf_id = fid; - id->li_fid.lf_group = mds; - - id->li_stc.u.e3s.l3s_ino = ino; - id->li_stc.u.e3s.l3s_gen = gen; - id->li_stc.u.e3s.l3s_type = type; -} - -#define id_ino(id) \ - (id)->li_stc.u.e3s.l3s_ino - -#define id_gen(id) \ - (id)->li_stc.u.e3s.l3s_gen - -#define id_type(id) \ - (id)->li_stc.u.e3s.l3s_type - -#define id_fid(id) \ - (id)->li_fid.lf_id - -#define id_group(id) \ - (id)->li_fid.lf_group - -#define id_assign_fid(id1, id2) \ - ((id1)->li_fid = (id2)->li_fid) - -#define id_assign_stc(id1, id2) \ - ((id1)->li_stc = (id2)->li_stc) - -#define id_equal(id1, id2) \ - (id_ino(id1) == id_ino(id2) && \ - id_gen(id1) == id_gen(id2) && \ - id_fid(id1) == id_fid(id2) && \ - id_group(id1) == id_group(id2)) - -#ifdef __KERNEL__ -static inline void -mdc_inode2id(struct lustre_id *id, struct inode *inode) -{ - mdc_pack_id(id, inode->i_ino, inode->i_generation, - (inode->i_mode & S_IFMT), 0, 0); -} - -static inline void -mdc_prepare_mdc_data(struct mdc_op_data *data, struct inode *i1, - struct inode *i2, const char *name, int namelen, - int mode) -{ - LASSERT(i1); - - mdc_inode2id(&data->id1, i1); - if (i2) - mdc_inode2id(&data->id2, i2); - - data->valid = 0; - data->name = name; - data->namelen = namelen; - data->create_mode = mode; - data->mod_time = CURRENT_TIME; -} -#endif + const char *old, int oldlen, const char *new, int newlen); /* ldlm/ldlm_lib.c */ int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf); diff --git a/lustre/include/linux/lustre_smfs.h b/lustre/include/linux/lustre_smfs.h index b6fd845..62efd3c 100644 --- a/lustre/include/linux/lustre_smfs.h +++ b/lustre/include/linux/lustre_smfs.h @@ -33,10 +33,6 @@ struct snap_inode_info { ino_t sn_root_ino; /*the root ino of this snap*/ }; struct smfs_inode_info { - /* this first part of struct should be the same as in mds_info_info */ - struct lustre_id smi_id; - - /* smfs part. */ struct inode *smi_inode; __u32 smi_flags; struct snap_inode_info sm_sninfo; @@ -128,14 +124,11 @@ struct fs_extent{ }; #define I2SMI(inode) ((struct smfs_inode_info *) ((inode->u.generic_ip))) -#define I2FSI(inode) (((inode->u.generic_ip))) #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#define S2FSI(sb) (((sb->u.generic_sbp))) #define S2SMI(sb) ((struct smfs_super_info *) ((sb->u.generic_sbp))) #define S2CSB(sb) (((struct smfs_super_info *)((sb->u.generic_sbp)))->smsi_sb) #else -#define S2FSI(sb) ((sb->s_fs_info)) #define S2SMI(sb) ((struct smfs_super_info *) (sb->s_fs_info)) #define S2CSB(sb) (((struct smfs_super_info *) (sb->s_fs_info))->smsi_sb) #endif @@ -320,10 +313,9 @@ static inline void post_smfs_inode(struct inode *inode, { if (inode && cache_inode) { duplicate_inode(inode, cache_inode); - - /* - * here we must release the cache_inode, otherwise we will have - * no chance to do it later. + /*Here we must release the cache_inode, + *Otherwise we will have no chance to + *do it */ cache_inode->i_state &=~I_LOCK; inode->i_blocks = cache_inode->i_blocks; @@ -441,11 +433,6 @@ static inline void post_smfs_dentry(struct dentry *cache_dentry) { if (!cache_dentry) return; - - /* - * this is needed because d_unalloc() calls dput(), which in turn calls - * iput() on dentry inode. - */ if (cache_dentry->d_inode) igrab(cache_dentry->d_inode); d_unalloc(cache_dentry); diff --git a/lustre/include/linux/lvfs.h b/lustre/include/linux/lvfs.h index fcccab4..3585660 100644 --- a/lustre/include/linux/lvfs.h +++ b/lustre/include/linux/lvfs.h @@ -3,7 +3,7 @@ #include -#define LL_ID_NAMELEN (16 + 1 + 8 + 1) +#define LL_FID_NAMELEN (16 + 1 + 8 + 1) #if defined __KERNEL__ #include @@ -28,8 +28,7 @@ struct lvfs_ucred { }; struct lvfs_callback_ops { - struct dentry *(*l_id2dentry)(__u64 ino, __u32 gen, - __u64 gr, void *data); + struct dentry *(*l_fid2dentry)(__u64 id_ino, __u32 gen, __u64 gr, void *data); }; #define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA @@ -59,8 +58,7 @@ struct lvfs_run_ctxt { #endif /* lvfs_common.c */ -struct dentry *lvfs_id2dentry(struct lvfs_run_ctxt *, __u64, - __u32, __u64 ,void *data); +struct dentry *lvfs_fid2dentry(struct lvfs_run_ctxt *, __u64, __u32, __u64 ,void *data); void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx, struct lvfs_ucred *cred); @@ -91,25 +89,27 @@ void *lock_dir(struct inode *dir, struct qstr *name); void unlock_dir(struct inode *dir, void *lock); #endif -/* We need to hold the inode semaphore over the dcache lookup itself, or we run - * the risk of entering the filesystem lookup path concurrently on SMP systems, - * and instantiating two inodes for the same entry. We still protect against - * concurrent addition/removal races with the DLM locking. */ -static inline struct dentry * -ll_lookup_one_len(const char *name, struct dentry *dparent, int namelen) +/* We need to hold the inode semaphore over the dcache lookup itself, or we + * run the risk of entering the filesystem lookup path concurrently on SMP + * systems, and instantiating two inodes for the same entry. We still + * protect against concurrent addition/removal races with the DLM locking. + */ +static inline struct dentry *ll_lookup_one_len(const char *fid_name, + struct dentry *dparent, + int fid_namelen) { struct dentry *dchild; #ifdef S_PDIROPS struct qstr qstr; void *lock; - qstr.name = name; - qstr.len = namelen; + qstr.name = fid_name; + qstr.len = fid_namelen; lock = lock_dir(dparent->d_inode, &qstr); #else down(&dparent->d_inode->i_sem); #endif - dchild = lookup_one_len(name, dparent, namelen); + dchild = lookup_one_len(fid_name, dparent, fid_namelen); #ifdef S_PDIROPS unlock_dir(dparent->d_inode, lock); @@ -127,10 +127,9 @@ static inline void ll_sleep(int t) } #endif -static inline int ll_id2str(char *str, __u64 id, __u32 generation) +static inline int ll_fid2str(char *str, __u64 id, __u32 generation) { - return sprintf(str, "%llx:%08x", (unsigned long long)id, - generation); + return sprintf(str, "%llx:%08x", (unsigned long long)id, generation); } #endif diff --git a/lustre/include/linux/lvfs_linux.h b/lustre/include/linux/lvfs_linux.h index 5d84673..ae27f81 100644 --- a/lustre/include/linux/lvfs_linux.h +++ b/lustre/include/linux/lvfs_linux.h @@ -26,7 +26,7 @@ struct l_linux_dirent { struct list_head lld_list; ino_t lld_ino; unsigned long lld_off; - char lld_name[LL_ID_NAMELEN]; + char lld_name[LL_FID_NAMELEN]; }; struct l_readdir_callback { struct l_linux_dirent *lrc_dirent; diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index c9e122d..4cf2769 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -216,8 +216,8 @@ struct filter_obd { struct semaphore fo_init_lock; /* group initialization lock */ int fo_committed_group; - spinlock_t fo_objidlock; /* protect fo_lastobjid increment */ - spinlock_t fo_translock; /* protect fsd_last_rcvd increment */ + spinlock_t fo_objidlock; /* protect fo_lastobjid increment */ + spinlock_t fo_translock; /* protect fsd_last_rcvd increment */ struct file *fo_rcvd_filp; struct filter_server_data *fo_fsd; unsigned long *fo_last_rcvd_slots; @@ -332,28 +332,26 @@ struct mds_obd { struct ptlrpc_service *mds_readpage_service; struct super_block *mds_sb; struct vfsmount *mds_vfsmnt; - struct dentry *mds_id_de; + struct dentry *mds_fid_de; int mds_max_mdsize; int mds_max_cookiesize; struct file *mds_rcvd_filp; - struct file *mds_fid_filp; spinlock_t mds_transno_lock; __u64 mds_last_transno; __u64 mds_mount_count; __u64 mds_io_epoch; - spinlock_t mds_fid_lock; - __u64 mds_last_fid; struct semaphore mds_epoch_sem; - struct lustre_id mds_rootid; + struct ll_fid mds_rootfid; struct mds_server_data *mds_server_data; struct dentry *mds_pending_dir; struct dentry *mds_logs_dir; struct dentry *mds_objects_dir; struct llog_handle *mds_cfg_llh; - struct obd_device *mds_lov_obd; +// struct llog_handle *mds_catalog; + struct obd_device *mds_osc_obd; /* XXX lov_obd */ struct obd_uuid mds_lov_uuid; char *mds_profile; - struct obd_export *mds_lov_exp; + struct obd_export *mds_osc_exp; /* XXX lov_exp */ int mds_has_lov_desc; struct lov_desc mds_lov_desc; obd_id *mds_lov_objids; @@ -363,15 +361,15 @@ struct mds_obd { spinlock_t mds_lov_lock; unsigned long *mds_client_bitmap; struct semaphore mds_orphan_recovery_sem; - + /*add mds num here for real mds and cache mds create + FIXME later will be totally fixed by b_cmd*/ int mds_num; struct lprocfs_stats *mds_counters; int mds_config_version; char *mds_lmv_name; - struct obd_device *mds_lmv_obd; - struct obd_export *mds_lmv_exp; - + struct obd_device *mds_lmv_obd; /* XXX lmv_obd */ + struct obd_export *mds_lmv_exp; /* XXX lov_exp */ struct ptlrpc_service *mds_create_service; struct semaphore mds_lmv_sem; uid_t mds_squash_uid; @@ -379,8 +377,7 @@ struct mds_obd { ptl_nid_t mds_nosquash_nid; atomic_t mds_real_clients; struct obd_uuid mds_lmv_uuid; - struct dentry *mds_id_dir; - int mds_obd_type; + struct dentry *mds_fids_dir; int mds_lmv_connected; struct dentry *mds_unnamed_dir; /* for mdt_obd_create only */ }; @@ -429,55 +426,54 @@ struct ost_obd { }; struct echo_client_obd { - struct obd_export *ec_exp; /* the local connection to osc/lov */ - spinlock_t ec_lock; - struct list_head ec_objects; - int ec_nstripes; - __u64 ec_unique; + struct obd_export *ec_exp; /* the local connection to osc/lov */ + spinlock_t ec_lock; + struct list_head ec_objects; + int ec_nstripes; + __u64 ec_unique; }; struct cache_obd { - struct obd_export *master_exp; /* local connection to master obd */ - struct obd_export *cache_exp; /* local connection to cache obd */ - char *master_name; - char *cache_name; - int refcount; - int cache_on; + struct obd_export *cobd_real_exp;/* local connection to target obd */ + struct obd_export *cobd_cache_exp; /* local connection to cache obd */ + char *cobd_real_name; + char *cobd_cache_name; + int refcount; + int cache_on; }; struct lov_tgt_desc { - struct obd_uuid uuid; - __u32 ltd_gen; - struct obd_export *ltd_exp; - int active; /* is this target up for requests */ + struct obd_uuid uuid; + __u32 ltd_gen; + struct obd_export *ltd_exp; + int active; /* is this target up for requests */ }; struct lov_obd { - spinlock_t lov_lock; - struct lov_desc desc; - int bufsize; - int refcount; - int lo_catalog_loaded:1; - struct semaphore lov_llog_sem; - unsigned long lov_connect_flags; - struct lov_tgt_desc *tgts; + spinlock_t lov_lock; + struct lov_desc desc; + struct semaphore lov_llog_sem; + int bufsize; + int refcount; + int lo_catalog_loaded:1; + unsigned long lov_connect_flags; + struct lov_tgt_desc *tgts; }; struct lmv_tgt_desc { struct obd_uuid uuid; - struct obd_export *ltd_exp; - int active; /* is this target up for requests */ + struct obd_export *ltd_exp; + int active; /* is this target up for requests */ }; struct lmv_obd { - int refcount; spinlock_t lmv_lock; struct lmv_desc desc; + int bufsize; + int refcount; struct lmv_tgt_desc *tgts; struct obd_uuid cluuid; struct obd_export *exp; - - int tgts_size; int connected; int max_easize; int max_cookiesize; @@ -496,13 +492,13 @@ struct niobuf_local { int rc; }; -struct cm_obd { - struct obd_device *master_obd; /* master lov */ - struct obd_export *master_exp; - struct obd_device *cache_obd; /* cache obdfilter */ - struct obd_export *cache_exp; - int master_group; /* master group*/ - struct cmobd_write_service *write_srv; +struct cache_manager_obd { + struct obd_device *cm_master_obd; /* master lov */ + struct obd_export *cm_master_exp; + struct obd_device *cm_cache_obd; /* cache obdfilter */ + struct obd_export *cm_cache_exp; + int cm_master_group; /* master group*/ + struct cmobd_write_service *cm_write_srv; }; @@ -632,35 +628,34 @@ struct obd_device { union { - struct filter_obd filter; - struct mds_obd mds; - struct client_obd cli; - struct ost_obd ost; - struct echo_client_obd echo_client; - struct echo_obd echo; - struct recovd_obd recovd; - struct lov_obd lov; - struct cache_obd cobd; - struct ptlbd_obd ptlbd; - struct mgmtcli_obd mgmtcli; - struct lmv_obd lmv; - struct cm_obd cm; + struct filter_obd filter; + struct mds_obd mds; + struct client_obd cli; + struct ost_obd ost; + struct echo_client_obd echo_client; + struct echo_obd echo; + struct recovd_obd recovd; + struct lov_obd lov; + struct cache_obd cobd; + struct ptlbd_obd ptlbd; + struct mgmtcli_obd mgmtcli; + struct lmv_obd lmv; + struct cache_manager_obd cmobd; } u; - - /* fields used by LProcFS */ + /* Fields used by LProcFS */ unsigned int obd_cntr_base; struct lprocfs_stats *obd_stats; struct proc_dir_entry *obd_svc_procroot; struct lprocfs_stats *obd_svc_stats; }; -#define OBD_OPT_FORCE (1 << 0) -#define OBD_OPT_FAILOVER (1 << 1) -#define OBD_OPT_REAL_CLIENT (1 << 2) -#define OBD_OPT_MDS_CONNECTION (1 << 3) +#define OBD_OPT_FORCE 0x0001 +#define OBD_OPT_FAILOVER 0x0002 +#define OBD_OPT_REAL_CLIENT 0x0004 +#define OBD_OPT_MDS_CONNECTION 0x0008 -#define OBD_LLOG_FL_SENDNOW (1 << 0) -#define OBD_LLOG_FL_CREATE (1 << 1) +#define OBD_LLOG_FL_SENDNOW 0x0001 +#define OBD_LLOG_FL_CREATE 0x0002 struct mdc_op_data; @@ -810,11 +805,6 @@ struct obd_ops { int (*o_notify)(struct obd_device *obd, struct obd_device *watched, int active, void *data); - - /* this method is needed for cmobd to make say to LMV "get ready" when - * master obd is LMV. This is needed, because LMV is initialized in - * "defered" manner to let all MDSs to be set up first. */ - int (*o_getready)(struct obd_export *exp); int (*o_init_ea_size)(struct obd_export *, int, int); /* @@ -825,11 +815,11 @@ struct obd_ops { }; struct md_ops { - int (*m_getstatus)(struct obd_export *, struct lustre_id *); - int (*m_change_cbdata)(struct obd_export *, struct lustre_id *, + int (*m_getstatus)(struct obd_export *, struct ll_fid *); + int (*m_change_cbdata)(struct obd_export *, struct ll_fid *, ldlm_iterator_t, void *); - int (*m_change_cbdata_name)(struct obd_export *, struct lustre_id *, - char *, int, struct lustre_id *, + int (*m_change_cbdata_name)(struct obd_export *, struct ll_fid *, + char *, int, struct ll_fid *, ldlm_iterator_t, void *); int (*m_close)(struct obd_export *, struct obdo *, struct obd_client_handle *, @@ -842,15 +832,15 @@ struct md_ops { int, struct mdc_op_data *, struct lustre_handle *, void *, int, ldlm_completion_callback, ldlm_blocking_callback, void *); - int (*m_getattr)(struct obd_export *, struct lustre_id *, + int (*m_getattr)(struct obd_export *, struct ll_fid *, unsigned long, unsigned int, struct ptlrpc_request **); - int (*m_getattr_name)(struct obd_export *, struct lustre_id *, + int (*m_getattr_name)(struct obd_export *, struct ll_fid *, char *, int, unsigned long, unsigned int, struct ptlrpc_request **); int (*m_intent_lock)(struct obd_export *, - struct lustre_id *, const char *, int, - void *, int, struct lustre_id *, + struct ll_fid *, const char *, int, + void *, int, struct ll_fid *, struct lookup_intent *, int, struct ptlrpc_request **, ldlm_blocking_callback); @@ -862,14 +852,13 @@ struct md_ops { int (*m_setattr)(struct obd_export *, struct mdc_op_data *, struct iattr *, void *, int , void *, int, struct ptlrpc_request **); - int (*m_sync)(struct obd_export *, struct lustre_id *, + int (*m_sync)(struct obd_export *, struct ll_fid *, struct ptlrpc_request **); - int (*m_readpage)(struct obd_export *, struct lustre_id *, + int (*m_readpage)(struct obd_export *, struct ll_fid *, __u64, struct page *, struct ptlrpc_request **); int (*m_unlink)(struct obd_export *, struct mdc_op_data *, struct ptlrpc_request **); - int (*m_valid_attrs)(struct obd_export *, struct lustre_id *); - + int (*m_valid_attrs)(struct obd_export *, struct ll_fid *); struct obd_device * (*m_get_real_obd)(struct obd_export *, char *name, int len); @@ -886,26 +875,24 @@ struct md_ops { int repoff); int (*m_set_lock_data)(struct obd_export *exp, __u64 *l, void *data); - int (*m_delete_object)(struct obd_export *, struct lustre_id *); - - /* NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line to - * lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c. Also, add a - * wrapper function in include/linux/obd_class.h. + int (*m_delete_object)(struct obd_export *, struct ll_fid *); + /* + * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line + * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c. + * Also, add a wrapper function in include/linux/obd_class.h. */ }; -static inline void obd_transno_commit_cb(struct obd_device *obd, - __u64 transno, int error) +static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno, + int error) { if (error) { CERROR("%s: transno "LPD64" commit error: %d\n", obd->obd_name, transno, error); return; } - CDEBUG(D_HA, "%s: transno "LPD64" committed\n", obd->obd_name, transno); - if (transno > obd->obd_last_committed) { obd->obd_last_committed = transno; ptlrpc_commit_replies (obd); diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 0c30089..dd05896 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -99,9 +99,9 @@ int class_config_dump_llog(struct llog_ctxt *ctxt, char *name, struct lustre_profile { struct list_head lp_list; - char *lp_profile; - char *lp_lov; - char *lp_lmv; + char * lp_profile; + char * lp_osc; + char * lp_mdc; }; struct lustre_profile *class_get_profile(char * prof); @@ -141,7 +141,6 @@ do { \ LASSERT(atomic_read(&(exp)->exp_refcount) < 0x5a5a5a); \ __class_export_put(exp); \ } while (0) - void __class_export_put(struct obd_export *); struct obd_export *class_new_export(struct obd_device *obddev); void class_unlink_export(struct obd_export *exp); @@ -155,10 +154,9 @@ struct obd_type *class_get_type(char *name); void class_put_type(struct obd_type *type); int class_connect(struct lustre_handle *conn, struct obd_device *obd, struct obd_uuid *cluuid); -int class_disconnect(struct obd_export *exp, int flags); -void class_disconnect_exports(struct obd_device *obddev, int flags); -void class_disconnect_stale_exports(struct obd_device *obddev, int flags); - +int class_disconnect(struct obd_export *exp, int failover); +void class_disconnect_exports(struct obd_device *obddev, int failover); +void class_disconnect_stale_exports(struct obd_device *obddev, int failover); /* generic operations shared by various OBD types */ int class_multi_setup(struct obd_device *obddev, uint32_t len, void *data); int class_multi_cleanup(struct obd_device *obddev); @@ -700,17 +698,6 @@ static inline int obd_disconnect(struct obd_export *exp, int flags) RETURN(rc); } -static inline int obd_getready(struct obd_export *exp) -{ - int rc; - ENTRY; - - if (!OBP(exp->exp_obd, getready)) - RETURN(0); - rc = OBP(exp->exp_obd, getready)(exp); - RETURN(rc); -} - static inline int obd_init_export(struct obd_export *exp) { int rc = 0; @@ -732,13 +719,12 @@ static inline int obd_destroy_export(struct obd_export *exp) } static inline struct dentry * -obd_lvfs_id2dentry(struct obd_export *exp, __u64 ino, - __u32 gen, __u64 gr) +obd_lvfs_fid2dentry(struct obd_export *exp, __u64 id_ino, __u32 gen, __u64 gr) { LASSERT(exp->exp_obd); - return lvfs_id2dentry(&exp->exp_obd->obd_lvfs_ctxt, - ino, gen, gr, exp->exp_obd); + return lvfs_fid2dentry(&exp->exp_obd->obd_lvfs_ctxt, id_ino, gen, gr, + exp->exp_obd); } #ifndef time_before @@ -1202,21 +1188,20 @@ static inline int obd_init_ea_size(struct obd_export *exp, int size, int size2) rc = OBP(exp->exp_obd, init_ea_size)(exp, size, size2); RETURN(rc); } - -static inline int md_getstatus(struct obd_export *exp, struct lustre_id *id) +static inline int md_getstatus(struct obd_export *exp, struct ll_fid *fid) { int rc; EXP_CHECK_MD_OP(exp, getstatus); MD_COUNTER_INCREMENT(exp->exp_obd, getstatus); - rc = MDP(exp->exp_obd, getstatus)(exp, id); + rc = MDP(exp->exp_obd, getstatus)(exp, fid); RETURN(rc); } -/* this function notifies MDC, that inode described by @id gets removed from +/* this function notifies MDC, that inode described by @fid gets removed from * memory.*/ static inline int md_delete_object(struct obd_export *exp, - struct lustre_id *id) + struct ll_fid *fid) { int rc; ENTRY; @@ -1228,11 +1213,11 @@ static inline int md_delete_object(struct obd_export *exp, RETURN(0); MD_COUNTER_INCREMENT(exp->exp_obd, delete_object); - rc = MDP(exp->exp_obd, delete_object)(exp, id); + rc = MDP(exp->exp_obd, delete_object)(exp, fid); RETURN(rc); } -static inline int md_getattr(struct obd_export *exp, struct lustre_id *id, +static inline int md_getattr(struct obd_export *exp, struct ll_fid *fid, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request) { @@ -1240,24 +1225,24 @@ static inline int md_getattr(struct obd_export *exp, struct lustre_id *id, ENTRY; EXP_CHECK_MD_OP(exp, getattr); MD_COUNTER_INCREMENT(exp->exp_obd, getattr); - rc = MDP(exp->exp_obd, getattr)(exp, id, valid, ea_size, request); + rc = MDP(exp->exp_obd, getattr)(exp, fid, valid, ea_size, request); RETURN(rc); } -static inline int md_change_cbdata(struct obd_export *exp, struct lustre_id *id, +static inline int md_change_cbdata(struct obd_export *exp, struct ll_fid *fid, ldlm_iterator_t it, void *data) { int rc; ENTRY; EXP_CHECK_MD_OP(exp, change_cbdata); MD_COUNTER_INCREMENT(exp->exp_obd, change_cbdata); - rc = MDP(exp->exp_obd, change_cbdata)(exp, id, it, data); + rc = MDP(exp->exp_obd, change_cbdata)(exp, fid, it, data); RETURN(rc); } static inline int md_change_cbdata_name(struct obd_export *exp, - struct lustre_id *id, char *name, - int namelen, struct lustre_id *id2, + struct ll_fid *fid, char *name, + int namelen, struct ll_fid *fid2, ldlm_iterator_t it, void *data) { int rc; @@ -1269,8 +1254,8 @@ static inline int md_change_cbdata_name(struct obd_export *exp, ENTRY; MD_COUNTER_INCREMENT(exp->exp_obd, change_cbdata_name); - rc = MDP(exp->exp_obd, change_cbdata_name)(exp, id, name, namelen, - id2, it, data); + rc = MDP(exp->exp_obd, change_cbdata_name)(exp, fid, name, namelen, + fid2, it, data); RETURN(rc); } @@ -1330,7 +1315,7 @@ static inline int md_enqueue(struct obd_export *exp, int lock_type, RETURN(rc); } -static inline int md_getattr_name(struct obd_export *exp, struct lustre_id *id, +static inline int md_getattr_name(struct obd_export *exp, struct ll_fid *fid, char *filename, int namelen, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request) @@ -1339,15 +1324,15 @@ static inline int md_getattr_name(struct obd_export *exp, struct lustre_id *id, ENTRY; EXP_CHECK_MD_OP(exp, getattr_name); MD_COUNTER_INCREMENT(exp->exp_obd, getattr_name); - rc = MDP(exp->exp_obd, getattr_name)(exp, id, filename, namelen, + rc = MDP(exp->exp_obd, getattr_name)(exp, fid, filename, namelen, valid, ea_size, request); RETURN(rc); } static inline int md_intent_lock(struct obd_export *exp, - struct lustre_id *pid, const char *name, + struct ll_fid *pfid, const char *name, int len, void *lmm, int lmmsize, - struct lustre_id *cid, struct lookup_intent *it, + struct ll_fid *cfid, struct lookup_intent *it, int flags, struct ptlrpc_request **reqp, ldlm_blocking_callback cb_blocking) { @@ -1355,8 +1340,8 @@ static inline int md_intent_lock(struct obd_export *exp, ENTRY; EXP_CHECK_MD_OP(exp, intent_lock); MD_COUNTER_INCREMENT(exp->exp_obd, intent_lock); - rc = MDP(exp->exp_obd, intent_lock)(exp, pid, name, len, - lmm, lmmsize, cid, it, flags, + rc = MDP(exp->exp_obd, intent_lock)(exp, pfid, name, len, + lmm, lmmsize, cfid, it, flags, reqp, cb_blocking); RETURN(rc); } @@ -1400,18 +1385,18 @@ static inline int md_setattr(struct obd_export *exp, struct mdc_op_data *data, RETURN(rc); } -static inline int md_sync(struct obd_export *exp, struct lustre_id *id, +static inline int md_sync(struct obd_export *exp, struct ll_fid *fid, struct ptlrpc_request **request) { int rc; ENTRY; EXP_CHECK_MD_OP(exp, sync); MD_COUNTER_INCREMENT(exp->exp_obd, sync); - rc = MDP(exp->exp_obd, sync)(exp, id, request); + rc = MDP(exp->exp_obd, sync)(exp, fid, request); RETURN(rc); } -static inline int md_readpage(struct obd_export *exp, struct lustre_id *id, +static inline int md_readpage(struct obd_export *exp, struct ll_fid *fid, __u64 offset, struct page *page, struct ptlrpc_request **request) { @@ -1419,7 +1404,7 @@ static inline int md_readpage(struct obd_export *exp, struct lustre_id *id, ENTRY; EXP_CHECK_MD_OP(exp, readpage); MD_COUNTER_INCREMENT(exp->exp_obd, readpage); - rc = MDP(exp->exp_obd, readpage)(exp, id, offset, page, request); + rc = MDP(exp->exp_obd, readpage)(exp, fid, offset, page, request); RETURN(rc); } @@ -1444,13 +1429,12 @@ static inline struct obd_device *md_get_real_obd(struct obd_export *exp, return MDP(exp->exp_obd, get_real_obd)(exp, name, len); } -static inline int md_valid_attrs(struct obd_export *exp, - struct lustre_id *id) +static inline int md_valid_attrs(struct obd_export *exp, struct ll_fid *fid) { ENTRY; EXP_CHECK_MD_OP(exp, valid_attrs); MD_COUNTER_INCREMENT(exp->exp_obd, valid_attrs); - return MDP(exp->exp_obd, valid_attrs)(exp, id); + return MDP(exp->exp_obd, valid_attrs)(exp, fid); } static inline int md_req2lustre_md(struct obd_export *exp, @@ -1495,8 +1479,7 @@ static inline int md_store_inode_generation(struct obd_export *exp, reqoff, repoff); } -static inline int md_set_lock_data(struct obd_export *exp, __u64 *l, - void *data) +static inline int md_set_lock_data(struct obd_export *exp, __u64 *l, void *data) { ENTRY; EXP_CHECK_MD_OP(exp, set_lock_data); diff --git a/lustre/include/linux/obd_lmv.h b/lustre/include/linux/obd_lmv.h index ad5d653..a3dc652 100644 --- a/lustre/include/linux/obd_lmv.h +++ b/lustre/include/linux/obd_lmv.h @@ -7,4 +7,5 @@ #define OBD_LMV_DEVICENAME "lmv" + #endif diff --git a/lustre/kernel_patches/patches/ext3-dentry-fid.patch b/lustre/kernel_patches/patches/ext3-dentry-fid.patch deleted file mode 100644 index 0aa7916..0000000 --- a/lustre/kernel_patches/patches/ext3-dentry-fid.patch +++ /dev/null @@ -1,52 +0,0 @@ -diff -rupN linux-2.4.24.orig/fs/ext3/namei.c linux-2.4.24/fs/ext3/namei.c ---- linux-2.4.24.orig/fs/ext3/namei.c Tue Oct 5 10:34:28 2004 -+++ linux-2.4.24/fs/ext3/namei.c Tue Oct 5 10:43:12 2004 -@@ -1112,6 +1112,7 @@ static struct dentry *ext3_lookup(struct - dentry->d_flags |= DCACHE_CROSS_REF; - dentry->d_generation = mds[1]; - dentry->d_mdsnum = mds[0]; -+ dentry->d_fid = mds[2]; - dentry->d_inum = ino; - d_add(dentry, NULL); - return NULL; -@@ -1334,7 +1335,8 @@ static int add_dirent_to_buf(handle_t *h - if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_MDSNUM) - && (dentry->d_flags & DCACHE_CROSS_REF) - && (dentry->d_mdsnum != EXT3_SB(sb)->s_mdsnum)) -- reclen += 8; /* we need space to store mds num */ -+ reclen += 12; /* we need space to store mds num, -+ * inode num and fid num. */ - if (!de) { - de = (struct ext3_dir_entry_2 *)bh->b_data; - top = bh->b_data + dir->i_sb->s_blocksize - reclen; -@@ -1387,6 +1389,7 @@ static int add_dirent_to_buf(handle_t *h - mds = (__u32 *)((char *)de + EXT3_DIR_REC_LEN(namelen)); - mds[0] = cpu_to_le32(dentry->d_mdsnum); - mds[1] = cpu_to_le32(dentry->d_generation); -+ mds[2] = cpu_to_le32(dentry->d_fid); - de->inode = cpu_to_le32(dentry->d_inum); - de->file_type = 128; - } else { -diff -rupN linux-2.4.24.orig/include/linux/dcache.h linux-2.4.24/include/linux/dcache.h ---- linux-2.4.24.orig/include/linux/dcache.h Tue Oct 5 10:34:28 2004 -+++ linux-2.4.24/include/linux/dcache.h Tue Oct 5 10:43:45 2004 -@@ -123,6 +123,7 @@ struct dentry { - unsigned d_inum; /* for cross-fs references (Lustre) */ - unsigned d_mdsnum; /* for cross-fs references (Lustre) */ - unsigned d_generation; /* for cross-fs references (Lustre) */ -+ unsigned d_fid; /* for cross-fs references (Lustre) */ - struct dentry * d_parent; /* parent directory */ - struct list_head d_hash; /* lookup hash list */ - struct list_head d_lru; /* d_count = 0 LRU list */ -diff -rupN linux-2.4.24.orig/include/linux/ext3_fs.h linux-2.4.24/include/linux/ext3_fs.h ---- linux-2.4.24.orig/include/linux/ext3_fs.h Tue Oct 5 10:34:28 2004 -+++ linux-2.4.24/include/linux/ext3_fs.h Tue Oct 5 10:44:29 2004 -@@ -589,7 +589,7 @@ struct ext3_dir_entry_2 { - #define EXT3_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT3_DIR_ROUND) & \ - ~EXT3_DIR_ROUND) - #define EXT3_DIR_REC_LEN_DE(de) (EXT3_DIR_REC_LEN((de)->name_len) + \ -- (((de)->file_type & 128) ? 8 : 0)) -+ (((de)->file_type & 128) ? 12 : 0)) - - /* - * Hash Tree Directory indexing diff --git a/lustre/kernel_patches/patches/kksymoops-2.4.24.vanilla.patch b/lustre/kernel_patches/patches/kksymoops-2.4.24.vanilla.patch index 75d4767..c47d1ac 100644 --- a/lustre/kernel_patches/patches/kksymoops-2.4.24.vanilla.patch +++ b/lustre/kernel_patches/patches/kksymoops-2.4.24.vanilla.patch @@ -170,7 +170,7 @@ Index: linux-2.4.24-b1_4/include/linux/kallsyms.h + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + -+#ident "$Id: kksymoops-2.4.24.vanilla.patch,v 1.8 2004/10/24 16:10:34 yury Exp $" ++#ident "$Id: kksymoops-2.4.24.vanilla.patch,v 1.9 2004/10/24 17:00:18 yury Exp $" + +#ifndef MODUTILS_KALLSYMS_H +#define MODUTILS_KALLSYMS_H 1 diff --git a/lustre/kernel_patches/series/vanilla-2.4.24 b/lustre/kernel_patches/series/vanilla-2.4.24 index ff01c9c..fd99cca 100644 --- a/lustre/kernel_patches/series/vanilla-2.4.24 +++ b/lustre/kernel_patches/series/vanilla-2.4.24 @@ -50,4 +50,3 @@ ext3-inode-reuse-2.4.24.patch export-zap-page-range-2.4.24.patch export_num_siblings-2.4.24.patch ext3-nlinks-2.4.24.patch -ext3-dentry-fid.patch diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 73e3ece..d0e2466 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -417,7 +417,7 @@ out_sem: return rc; } -int client_disconnect_export(struct obd_export *exp, int flags) +int client_disconnect_export(struct obd_export *exp, int failover) { struct obd_device *obd = class_exp2obd(exp); struct client_obd *cli = &obd->u.cli; @@ -810,7 +810,6 @@ static void target_release_saved_req(struct ptlrpc_request *req) OBD_FREE(req, sizeof *req); } -#ifdef __KERNEL__ static void target_finish_recovery(struct obd_device *obd) { struct list_head *tmp, *n; @@ -866,8 +865,6 @@ static void abort_recovery_queue(struct obd_device *obd) target_release_saved_req(req); } } -#endif - /* Called from a cleanup function if the device is being cleaned up forcefully. The exports should all have been disconnected already, the only thing left to do is @@ -907,7 +904,6 @@ void target_cleanup_recovery(struct obd_device *obd) } } -#ifdef __KERNEL__ static void target_abort_recovery(void *data) { struct obd_device *obd = data; @@ -923,7 +919,6 @@ static void target_abort_recovery(void *data) target_finish_recovery(obd); ptlrpc_run_recovery_over_upcall(obd); } -#endif static void target_recovery_expired(unsigned long castmeharder) { @@ -945,7 +940,6 @@ void target_cancel_recovery_timer(struct obd_device *obd) del_timer(&obd->obd_recovery_timer); } -#ifdef __KERNEL__ static void reset_recovery_timer(struct obd_device *obd) { spin_lock_bh(&obd->obd_processing_task_lock); @@ -958,7 +952,7 @@ static void reset_recovery_timer(struct obd_device *obd) mod_timer(&obd->obd_recovery_timer, jiffies + OBD_RECOVERY_TIMEOUT); spin_unlock_bh(&obd->obd_processing_task_lock); } -#endif + /* Only start it the first time called */ void target_start_recovery_timer(struct obd_device *obd) @@ -976,7 +970,6 @@ void target_start_recovery_timer(struct obd_device *obd) spin_unlock_bh(&obd->obd_processing_task_lock); } -#ifdef __KERNEL__ static int check_for_next_transno(struct obd_device *obd) { struct ptlrpc_request *req = NULL; @@ -1050,6 +1043,7 @@ target_next_replay_req(struct obd_device *obd) return req; } +#ifdef __KERNEL__ static int target_recovery_thread(void *arg) { struct obd_device *obd = arg; @@ -1144,7 +1138,6 @@ void target_stop_recovery_thread(struct obd_device *obd) } } #endif - int target_queue_recovery_request(struct ptlrpc_request *req, struct obd_device *obd) { diff --git a/lustre/liblustre/dir.c b/lustre/liblustre/dir.c index b50e458..3b9b0f6 100644 --- a/lustre/liblustre/dir.c +++ b/lustre/liblustre/dir.c @@ -51,7 +51,7 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page) { struct llu_inode_info *lli = llu_i2info(inode); struct llu_sb_info *sbi = llu_i2sbi(inode); - struct lustre_id id; + struct ll_fid mdc_fid; __u64 offset; int rc = 0; struct ptlrpc_request *request; @@ -59,18 +59,18 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page) struct mds_body *body; struct lookup_intent it = { .it_op = IT_READDIR }; struct mdc_op_data data; - struct obd_device *obddev = class_exp2obd(sbi->ll_lmv_exp); + struct obd_device *obddev = class_exp2obd(sbi->ll_mdc_exp); struct ldlm_res_id res_id = - { .name = {id_fid(&lli->lli_id), id_group(&lli->lli_id)} }; + { .name = {lli->lli_st_ino, (__u64)lli->lli_st_generation} }; ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_UPDATE } }; ENTRY; rc = ldlm_lock_match(obddev->obd_namespace, LDLM_FL_BLOCK_GRANTED, &res_id, LDLM_IBITS, &policy, LCK_PR, &lockh); if (!rc) { - llu_prepare_mdc_data(&data, inode, NULL, NULL, 0, 0); + llu_prepare_mdc_op_data(&data, inode, NULL, NULL, 0, 0); - rc = mdc_enqueue(sbi->ll_lmv_exp, LDLM_IBITS, &it, LCK_PR, + rc = mdc_enqueue(sbi->ll_mdc_exp, LDLM_IBITS, &it, LCK_PR, &data, &lockh, NULL, 0, ldlm_completion_ast, llu_mdc_blocking_ast, inode); @@ -84,12 +84,11 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page) } ldlm_lock_dump_handle(D_OTHER, &lockh); - /* FIXME-UMKA: should be here some mds num and mds id? */ - mdc_pack_id(&id, lli->lli_st_ino, lli->lli_st_generation, - S_IFDIR, 0, 0); + mdc_pack_fid(&mdc_fid, lli->lli_st_ino, lli->lli_st_generation, S_IFDIR); offset = page->index << PAGE_SHIFT; - rc = mdc_readpage(sbi->ll_lmv_exp, &id, offset, page, &request); + rc = mdc_readpage(sbi->ll_mdc_exp, &mdc_fid, + offset, page, &request); if (!rc) { body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body)); LASSERT (body != NULL); /* checked by mdc_readpage() */ diff --git a/lustre/liblustre/file.c b/lustre/liblustre/file.c index 78b9202..0ceefdb 100644 --- a/lustre/liblustre/file.c +++ b/lustre/liblustre/file.c @@ -42,17 +42,22 @@ #include "llite_lib.h" -void llu_prepare_mdc_data(struct mdc_op_data *data, struct inode *i1, - struct inode *i2, const char *name, - int namelen, int mode) +void llu_prepare_mdc_op_data(struct mdc_op_data *data, + struct inode *i1, + struct inode *i2, + const char *name, + int namelen, + int mode) { LASSERT(i1); - ll_inode2id(&data->id1, i1); - if (i2) - ll_inode2id(&data->id2, i2); + ll_i2uctxt(&data->ctxt, i1, i2); + ll_inode2fid(&data->fid1, i1); + + if (i2) { + ll_inode2fid(&data->fid2, i2); + } - data->valid = 0; data->name = name; data->namelen = namelen; data->create_mode = mode; @@ -340,7 +345,7 @@ int llu_file_release(struct inode *inode) if (!fd) /* no process opened the file after an mcreate */ RETURN(0); - rc2 = llu_mdc_close(sbi->ll_lmv_exp, inode); + rc2 = llu_mdc_close(sbi->ll_mdc_exp, inode); if (rc2 && !rc) rc = rc2; diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c index bf006fa..88c92d1 100644 --- a/lustre/liblustre/llite_lib.c +++ b/lustre/liblustre/llite_lib.c @@ -99,7 +99,7 @@ int liblustre_process_log(struct config_llog_instance *cfg, int allow_recov) CERROR("Can't parse NAL %s\n", LIBLUSTRE_NAL_NAME); RETURN(-EINVAL); } - LCFG_INIT(lcfg, LCFG_ADD_UUID, name); + LCFG_INIT(lcfg, LCFG_ADD_UUID, NULL); lcfg.lcfg_nid = nid; lcfg.lcfg_inllen1 = strlen(peer) + 1; lcfg.lcfg_inlbuf1 = peer; @@ -146,8 +146,9 @@ int liblustre_process_log(struct config_llog_instance *cfg, int allow_recov) ctxt = exp->exp_obd->obd_llog_ctxt[LLOG_CONFIG_REPL_CTXT]; rc = class_config_process_llog(ctxt, g_zconf_profile, cfg); - if (rc) - CERROR("class_config_process_llog failed: rc = %d\n", rc); + if (rc) { + CERROR("class_config_parse_llog failed: rc = %d\n", rc); + } err = obd_disconnect(exp, 0); diff --git a/lustre/liblustre/llite_lib.h b/lustre/liblustre/llite_lib.h index 34f1fea..6c0c61d 100644 --- a/lustre/liblustre/llite_lib.h +++ b/lustre/liblustre/llite_lib.h @@ -45,8 +45,8 @@ struct ll_file_data { struct llu_sb_info { struct obd_uuid ll_sb_uuid; - struct obd_export *ll_lmv_exp; - struct obd_export *ll_lov_exp; + struct obd_export *ll_mdc_exp; + struct obd_export *ll_osc_exp; obd_id ll_rootino; int ll_flags; struct list_head ll_conn_chain; @@ -65,7 +65,7 @@ struct llu_sb_info struct llu_inode_info { struct llu_sb_info *lli_sbi; - struct lustre_id lli_id; + struct ll_fid lli_fid; struct lov_stripe_md *lli_smd; char *lli_symlink_name; @@ -81,9 +81,10 @@ struct llu_inode_info { /* XXX workaround for libsysio readdir */ loff_t lli_dir_pos; - /* in libsysio we have no chance to store data in file, so place it - * here. since it's possible that an file was opened several times - * without close, we track an open_count here */ + /* in libsysio we have no chance to store data in file, + * so place it here. since it's possible that an file + * was opened several times without close, we track an + * open_count here */ struct ll_file_data *lli_file_data; int lli_open_flags; int lli_open_count; @@ -125,17 +126,17 @@ static inline struct llu_sb_info *llu_i2sbi(struct inode *inode) static inline struct obd_export *llu_i2obdexp(struct inode *inode) { - return llu_i2info(inode)->lli_sbi->ll_lov_exp; + return llu_i2info(inode)->lli_sbi->ll_osc_exp; } static inline struct obd_export *llu_i2mdcexp(struct inode *inode) { - return llu_i2info(inode)->lli_sbi->ll_lmv_exp; + return llu_i2info(inode)->lli_sbi->ll_mdc_exp; } static inline int llu_is_root_inode(struct inode *inode) { - return (llu_i2info(inode)->lli_id.li_stc.u.e3s.l3s_ino == + return (llu_i2info(inode)->lli_fid.id == llu_i2info(inode)->lli_sbi->ll_rootino); } @@ -165,18 +166,17 @@ do { \ #define LL_LOOKUP_POSITIVE 1 #define LL_LOOKUP_NEGATIVE 2 +static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode) +{ + *fid = llu_i2info(inode)->lli_fid; +} + struct it_cb_data { struct inode *icbd_parent; struct pnode *icbd_child; obd_id hash; }; -static inline void ll_inode2id(struct lustre_id *id, - struct inode *inode) -{ - *id = llu_i2info(inode)->lli_id; -} - typedef int (*intent_finish_cb)(struct ptlrpc_request *, struct inode *parent, struct pnode *pnode, struct lookup_intent *, int offset, obd_id ino); @@ -221,10 +221,12 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr); extern struct fssw_ops llu_fssw_ops; /* file.c */ -void llu_prepare_mdc_data(struct mdc_op_data *data, struct inode *i1, - struct inode *i2, const char *name, int namelen, - int mode); - +void llu_prepare_mdc_op_data(struct mdc_op_data *data, + struct inode *i1, + struct inode *i2, + const char *name, + int namelen, + int mode); int llu_create(struct inode *dir, struct pnode_base *pnode, int mode); int llu_iop_open(struct pnode *pnode, int flags, mode_t mode); int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode); diff --git a/lustre/liblustre/namei.c b/lustre/liblustre/namei.c index 04606fd..2a7c5e0 100644 --- a/lustre/liblustre/namei.c +++ b/lustre/liblustre/namei.c @@ -148,15 +148,15 @@ int llu_mdc_blocking_ast(struct ldlm_lock *lock, if (inode == NULL) break; - lli = llu_i2info(inode); + lli = llu_i2info(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] != id_fid(&lli->lli_id) || - lock->l_resource->lr_name.name[1] != id_group(&lli->lli_id)) { - LDLM_ERROR(lock, "data mismatch with object "DLID4, - OLID4(&lli->lli_id)); + if (lock->l_resource->lr_name.name[0] != lli->lli_st_ino || + lock->l_resource->lr_name.name[1] != lli->lli_st_generation) { + LDLM_ERROR(lock, "data mismatch with ino %lu/%lu", + lli->lli_st_ino, lli->lli_st_generation); } if (S_ISDIR(lli->lli_st_mode) && (bits & MDS_INODELOCK_UPDATE)) { @@ -166,6 +166,11 @@ int llu_mdc_blocking_ast(struct ldlm_lock *lock, 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; } @@ -194,8 +199,8 @@ static int pnode_revalidate_finish(struct ptlrpc_request *req, if (it_disposition(it, DISP_LOOKUP_NEG)) RETURN(-ENOENT); - rc = mdc_req2lustre_md(llu_i2sbi(inode)->ll_lmv_exp, req, offset, - llu_i2sbi(inode)->ll_lov_exp, &md); + rc = mdc_req2lustre_md(llu_i2sbi(inode)->ll_mdc_exp, req, offset, + llu_i2sbi(inode)->ll_osc_exp, &md); if (rc) RETURN(rc); @@ -207,8 +212,9 @@ static int pnode_revalidate_finish(struct ptlrpc_request *req, int llu_pb_revalidate(struct pnode *pnode, int flags, struct lookup_intent *it) { struct pnode_base *pb = pnode->p_base; - struct lustre_id pid, cid; + struct ll_fid pfid, cfid; struct it_cb_data icbd; + struct ll_uctxt ctxt; struct ptlrpc_request *req = NULL; struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; struct obd_export *exp; @@ -243,8 +249,8 @@ int llu_pb_revalidate(struct pnode *pnode, int flags, struct lookup_intent *it) } exp = llu_i2mdcexp(pb->pb_ino); - ll_inode2id(&pid, pnode->p_parent->p_base->pb_ino); - ll_inode2id(&cid, pb->pb_ino); + ll_inode2fid(&pfid, pnode->p_parent->p_base->pb_ino); + ll_inode2fid(&cfid, pb->pb_ino); icbd.icbd_parent = pnode->p_parent->p_base->pb_ino; icbd.icbd_child = pnode; @@ -253,8 +259,12 @@ int llu_pb_revalidate(struct pnode *pnode, int flags, struct lookup_intent *it) it->it_op_release = ll_intent_release; } - rc = mdc_intent_lock(exp, &pid, pb->pb_name.name, pb->pb_name.len, - NULL, 0, &cid, it, flags, &req, llu_mdc_blocking_ast); + ll_i2uctxt(&ctxt, pnode->p_parent->p_base->pb_ino, pb->pb_ino); + + rc = mdc_intent_lock(exp, &ctxt, &pfid, + pb->pb_name.name, pb->pb_name.len, + NULL, 0, &cfid, it, flags, &req, + llu_mdc_blocking_ast); /* 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) @@ -330,8 +340,8 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, struct llu_inode_info *lli; ENTRY; - rc = mdc_req2lustre_md(sbi->ll_lmv_exp, request, offset, - sbi->ll_lov_exp, &md); + rc = mdc_req2lustre_md(sbi->ll_mdc_exp, request, offset, + sbi->ll_osc_exp, &md); if (rc) RETURN(rc); @@ -339,11 +349,11 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, if (!inode || IS_ERR(inode)) { /* free the lsm if we allocated one above */ if (md.lsm != NULL) - obd_free_memmd(sbi->ll_lov_exp, &md.lsm); + obd_free_memmd(sbi->ll_osc_exp, &md.lsm); RETURN(inode ? PTR_ERR(inode) : -ENOMEM); } else if (md.lsm != NULL && llu_i2info(inode)->lli_smd != md.lsm) { - obd_free_memmd(sbi->ll_lov_exp, &md.lsm); + obd_free_memmd(sbi->ll_osc_exp, &md.lsm); } lli = llu_i2info(inode); @@ -396,7 +406,8 @@ struct inode *llu_inode_from_lock(struct ldlm_lock *lock) static int llu_lookup_it(struct inode *parent, struct pnode *pnode, struct lookup_intent *it, int flags) { - struct lustre_id pid; + struct ll_fid pfid; + struct ll_uctxt ctxt; struct it_cb_data icbd; struct ptlrpc_request *req = NULL; struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; @@ -414,9 +425,10 @@ static int llu_lookup_it(struct inode *parent, struct pnode *pnode, icbd.icbd_child = pnode; icbd.icbd_parent = parent; icbd.icbd_child = pnode; - ll_inode2id(&pid, parent); + ll_inode2fid(&pfid, parent); + ll_i2uctxt(&ctxt, parent, NULL); - rc = mdc_intent_lock(llu_i2mdcexp(parent), &pid, + rc = mdc_intent_lock(llu_i2mdcexp(parent), &ctxt, &pfid, pnode->p_base->pb_name.name, pnode->p_base->pb_name.len, NULL, 0, NULL, it, flags, &req, diff --git a/lustre/liblustre/rw.c b/lustre/liblustre/rw.c index 15be024..8c4c686 100644 --- a/lustre/liblustre/rw.c +++ b/lustre/liblustre/rw.c @@ -32,8 +32,9 @@ #include #include -#include +#include #include +#include #include #include #include @@ -223,7 +224,7 @@ int llu_glimpse_size(struct inode *inode) CDEBUG(D_DLMTRACE, "Glimpsing inode %lu\n", lli->lli_st_ino); - rc = obd_enqueue(sbi->ll_lov_exp, lli->lli_smd, LDLM_EXTENT, &policy, + rc = obd_enqueue(sbi->ll_osc_exp, lli->lli_smd, LDLM_EXTENT, &policy, LCK_PR, &flags, llu_extent_lock_callback, ldlm_completion_ast, llu_glimpse_callback, inode, sizeof(struct ost_lvb), lustre_swab_ost_lvb, &lockh); @@ -239,7 +240,7 @@ int llu_glimpse_size(struct inode *inode) CDEBUG(D_DLMTRACE, "glimpse: size: %llu, blocks: %lu\n", lli->lli_st_size, lli->lli_st_blocks); - obd_cancel(sbi->ll_lov_exp, lli->lli_smd, LCK_PR, &lockh); + obd_cancel(sbi->ll_osc_exp, lli->lli_smd, LCK_PR, &lockh); RETURN(rc); } @@ -264,7 +265,7 @@ int llu_extent_lock(struct ll_file_data *fd, struct inode *inode, CDEBUG(D_DLMTRACE, "Locking inode %lu, start "LPU64" end "LPU64"\n", lli->lli_st_ino, policy->l_extent.start, policy->l_extent.end); - rc = obd_enqueue(sbi->ll_lov_exp, lsm, LDLM_EXTENT, policy, mode, + rc = obd_enqueue(sbi->ll_osc_exp, lsm, LDLM_EXTENT, policy, mode, &ast_flags, llu_extent_lock_callback, ldlm_completion_ast, llu_glimpse_callback, inode, sizeof(struct ost_lvb), lustre_swab_ost_lvb, lockh); @@ -293,7 +294,7 @@ int llu_extent_unlock(struct ll_file_data *fd, struct inode *inode, (sbi->ll_flags & LL_SBI_NOLCK)) RETURN(0); - rc = obd_cancel(sbi->ll_lov_exp, lsm, mode, lockh); + rc = obd_cancel(sbi->ll_osc_exp, lsm, mode, lockh); RETURN(rc); } diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 7b5fc95..028c2c8 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -31,26 +31,26 @@ #include #include #include - #ifndef __CYGWIN__ # include #else # include #endif -#include #include +#include #include #include #include #undef LIST_HEAD + #include "llite_lib.h" #ifndef MAY_EXEC -# define MAY_EXEC 1 -# define MAY_WRITE 2 -# define MAY_READ 4 +#define MAY_EXEC 1 +#define MAY_WRITE 2 +#define MAY_READ 4 #endif #define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) @@ -85,14 +85,14 @@ static int ll_permission(struct inode *inode, int mask) static void llu_fsop_gone(struct filesys *fs) { struct llu_sb_info *sbi = (struct llu_sb_info *) fs->fs_private; - struct obd_device *obd = class_exp2obd(sbi->ll_lmv_exp); + struct obd_device *obd = class_exp2obd(sbi->ll_mdc_exp); struct lustre_cfg lcfg; int next = 0; ENTRY; list_del(&sbi->ll_conn_chain); - obd_disconnect(sbi->ll_lov_exp, 0); - obd_disconnect(sbi->ll_lmv_exp, 0); + obd_disconnect(sbi->ll_osc_exp, 0); + obd_disconnect(sbi->ll_mdc_exp, 0); while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL) { @@ -111,12 +111,12 @@ static void llu_fsop_gone(struct filesys *fs) } } - obd_disconnect(sbi->ll_lmv_exp, 0); OBD_FREE(sbi, sizeof(*sbi)); + EXIT; } -struct inode_ops llu_inode_ops; +static struct inode_ops llu_inode_ops; void llu_update_inode(struct inode *inode, struct mds_body *body, struct lov_stripe_md *lsm) @@ -139,19 +139,8 @@ void llu_update_inode(struct inode *inode, struct mds_body *body, } } - /* - * updating inode lustre id. We try optimize things a little bit here, - * thus do not do it all the time. - */ - if (body->valid & OBD_MD_FID) - id_assign_fid(&lli->lli_id, &body->id1); - if ((body->valid & OBD_MD_FLID) || (body->valid & OBD_MD_FLGENER)) - id_assign_stc(&lli->lli_id, &body->id1); if (body->valid & OBD_MD_FLID) - lli->lli_st_ino = id_ino(&body->id1); - if (body->valid & OBD_MD_FLGENER) - lli->lli_st_generation = id_gen(&body->id1); - + lli->lli_st_ino = body->ino; if (body->valid & OBD_MD_FLATIME) LTIME_S(lli->lli_st_atime) = body->atime; if (body->valid & OBD_MD_FLMTIME) @@ -170,12 +159,22 @@ void llu_update_inode(struct inode *inode, struct mds_body *body, lli->lli_st_flags = body->flags; if (body->valid & OBD_MD_FLNLINK) lli->lli_st_nlink = body->nlink; + if (body->valid & OBD_MD_FLGENER) + lli->lli_st_generation = body->generation; if (body->valid & OBD_MD_FLRDEV) lli->lli_st_rdev = body->rdev; if (body->valid & OBD_MD_FLSIZE) lli->lli_st_size = body->size; if (body->valid & OBD_MD_FLBLOCKS) lli->lli_st_blocks = body->blocks; + + /* fillin fid */ + if (body->valid & OBD_MD_FLID) + lli->lli_fid.id = body->ino; + if (body->valid & OBD_MD_FLGENER) + lli->lli_fid.generation = body->generation; + if (body->valid & OBD_MD_FLTYPE) + lli->lli_fid.f_type = body->mode & S_IFMT; } void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid) @@ -343,7 +342,7 @@ int llu_inode_getattr(struct inode *inode, struct lov_stripe_md *lsm) } static struct inode* llu_new_inode(struct filesys *fs, - struct lustre_id *id) + struct ll_fid *fid) { struct inode *inode; struct llu_inode_info *lli; @@ -360,17 +359,17 @@ static struct inode* llu_new_inode(struct filesys *fs, lli->lli_maxbytes = (__u64)(~0UL); lli->lli_file_data = NULL; - lli->lli_sysio_fid.fid_data = &lli->lli_id; - lli->lli_sysio_fid.fid_len = sizeof(lli->lli_id); + lli->lli_sysio_fid.fid_data = &lli->lli_fid; + lli->lli_sysio_fid.fid_len = sizeof(lli->lli_fid); - memcpy(&lli->lli_id, id, sizeof(*id)); + memcpy(&lli->lli_fid, fid, sizeof(*fid)); /* file identifier is needed by functions like _sysio_i_find() */ inode = _sysio_i_new(fs, &lli->lli_sysio_fid, #ifndef AUTOMOUNT_FILE_NAME - id->li_stc.u.e3s.l3s_type & S_IFMT, + fid->f_type & S_IFMT, #else - id->li_stc.u.e3s.l3s_type, /* all of the bits! */ + fid->f_type, /* all of the bits! */ #endif 0, 0, &llu_inode_ops, lli); @@ -394,9 +393,9 @@ static int llu_have_md_lock(struct inode *inode, __u64 lockpart) LASSERT(inode); - obddev = sbi->ll_lmv_exp->exp_obd; - res_id.name[0] = id_fid(&lli->lli_id); - res_id.name[1] = id_group(&lli->lli_id); + obddev = sbi->ll_mdc_exp->exp_obd; + res_id.name[0] = lli->lli_st_ino; + res_id.name[1] = lli->lli_st_generation; CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id.name[0]); @@ -431,24 +430,24 @@ static int llu_inode_revalidate(struct inode *inode) struct lustre_md md; struct ptlrpc_request *req = NULL; struct llu_sb_info *sbi = llu_i2sbi(inode); - struct lustre_id id; + struct ll_fid fid; unsigned long valid = 0; int rc, ealen = 0; - /* Why don't we update all valid MDS fields here, if we're doing - * an RPC anyways? -phil */ + /* Why don't we update all valid MDS fields here, if we're + * doing an RPC anyways? -phil */ if (S_ISREG(lli->lli_st_mode)) { - ealen = obd_size_diskmd(sbi->ll_lov_exp, NULL); + ealen = obd_size_diskmd(sbi->ll_osc_exp, NULL); valid |= OBD_MD_FLEASIZE; } - ll_inode2id(&id, inode); - rc = mdc_getattr(sbi->ll_lmv_exp, &id, valid, ealen, &req); + ll_inode2fid(&fid, inode); + rc = mdc_getattr(sbi->ll_mdc_exp, &fid, valid, ealen, &req); if (rc) { CERROR("failure %d inode %lu\n", rc, lli->lli_st_ino); RETURN(-abs(rc)); } - rc = mdc_req2lustre_md(sbi->ll_lmv_exp, req, 0, - sbi->ll_lov_exp, &md); + rc = mdc_req2lustre_md(sbi->ll_mdc_exp, req, 0, sbi->ll_osc_exp, + &md); /* XXX Too paranoid? */ if (((md.body->valid ^ valid) & OBD_MD_FLEASIZE) && @@ -467,7 +466,7 @@ static int llu_inode_revalidate(struct inode *inode) llu_update_inode(inode, md.body, md.lsm); if (md.lsm != NULL && llu_i2info(inode)->lli_smd != md.lsm) - obd_free_memmd(sbi->ll_lov_exp, &md.lsm); + obd_free_memmd(sbi->ll_osc_exp, &md.lsm); if (md.body->valid & OBD_MD_FLSIZE) set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, @@ -546,7 +545,7 @@ static int null_if_equal(struct ldlm_lock *lock, void *data) void llu_clear_inode(struct inode *inode) { - struct lustre_id id; + struct ll_fid fid; struct llu_inode_info *lli = llu_i2info(inode); struct llu_sb_info *sbi = llu_i2sbi(inode); ENTRY; @@ -554,16 +553,16 @@ void llu_clear_inode(struct inode *inode) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%lu(%p)\n", lli->lli_st_ino, lli->lli_st_generation, inode); - ll_inode2id(&id, inode); + ll_inode2fid(&fid, inode); clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(lli->lli_flags)); - mdc_change_cbdata(sbi->ll_lmv_exp, &id, null_if_equal, inode); + mdc_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode); if (lli->lli_smd) - obd_change_cbdata(sbi->ll_lov_exp, lli->lli_smd, + obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd, null_if_equal, inode); if (lli->lli_smd) { - obd_free_memmd(sbi->ll_lov_exp, &lli->lli_smd); + obd_free_memmd(sbi->ll_osc_exp, &lli->lli_smd); lli->lli_smd = NULL; } @@ -682,11 +681,11 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr) * inode ourselves so we can call obdo_from_inode() always. */ if (ia_valid & (lsm ? ~(ATTR_SIZE | ATTR_FROM_OPEN | ATTR_RAW) : ~0)) { struct lustre_md md; - llu_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0); + llu_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0); + + rc = mdc_setattr(sbi->ll_mdc_exp, &op_data, + attr, NULL, 0, NULL, 0, &request); - rc = mdc_setattr(sbi->ll_lmv_exp, &op_data, - attr, NULL, 0, NULL, 0, &request); - if (rc) { ptlrpc_req_finished(request); if (rc != -EPERM && rc != -EACCES) @@ -694,8 +693,8 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr) RETURN(rc); } - rc = mdc_req2lustre_md(sbi->ll_lmv_exp, request, 0, - sbi->ll_lov_exp, &md); + rc = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0, + sbi->ll_osc_exp, &md); if (rc) { ptlrpc_req_finished(request); RETURN(rc); @@ -772,7 +771,7 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr) oa.o_valid = OBD_MD_FLID; obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME); - rc = obd_setattr(sbi->ll_lov_exp, &oa, lsm, NULL); + rc = obd_setattr(sbi->ll_osc_exp, &oa, lsm, NULL); if (rc) CERROR("obd_setattr fails: rc=%d\n", rc); } @@ -844,8 +843,8 @@ static int llu_iop_symlink_raw(struct pnode *pno, const char *tgt) if (llu_i2info(dir)->lli_st_nlink >= EXT2_LINK_MAX) RETURN(err); - llu_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); - err = mdc_create(sbi->ll_lmv_exp, &op_data, + llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); + err = mdc_create(sbi->ll_mdc_exp, &op_data, tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO, current->fsuid, current->fsgid, 0, &request); ptlrpc_req_finished(request); @@ -858,7 +857,7 @@ static int llu_readlink_internal(struct inode *inode, { struct llu_inode_info *lli = llu_i2info(inode); struct llu_sb_info *sbi = llu_i2sbi(inode); - struct lustre_id id; + struct ll_fid fid; struct mds_body *body; int rc, symlen = lli->lli_st_size + 1; ENTRY; @@ -871,8 +870,8 @@ static int llu_readlink_internal(struct inode *inode, RETURN(0); } - ll_inode2id(&id, inode); - rc = mdc_getattr(sbi->ll_lmv_exp, &id, + ll_inode2fid(&fid, inode); + rc = mdc_getattr(sbi->ll_mdc_exp, &fid, OBD_MD_LINKNAME, symlen, request); if (rc) { CERROR("inode %lu: rc = %d\n", lli->lli_st_ino, rc); @@ -963,11 +962,11 @@ static int llu_iop_mknod_raw(struct pnode *pno, case S_IFBLK: case S_IFIFO: case S_IFSOCK: - llu_prepare_mdc_data(&op_data, dir, NULL, - pno->p_base->pb_name.name, - pno->p_base->pb_name.len, - 0); - err = mdc_create(sbi->ll_lmv_exp, &op_data, NULL, 0, mode, + llu_prepare_mdc_op_data(&op_data, dir, NULL, + pno->p_base->pb_name.name, + pno->p_base->pb_name.len, + 0); + err = mdc_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode, current->fsuid, current->fsgid, dev, &request); ptlrpc_req_finished(request); break; @@ -995,8 +994,8 @@ static int llu_iop_link_raw(struct pnode *old, struct pnode *new) LASSERT(dir); liblustre_wait_event(0); - llu_prepare_mdc_data(&op_data, src, dir, name, namelen, 0); - rc = mdc_link(llu_i2sbi(src)->ll_lmv_exp, &op_data, &request); + llu_prepare_mdc_op_data(&op_data, src, dir, name, namelen, 0); + rc = mdc_link(llu_i2sbi(src)->ll_mdc_exp, &op_data, &request); ptlrpc_req_finished(request); liblustre_wait_event(0); @@ -1021,12 +1020,13 @@ static int llu_iop_unlink_raw(struct pnode *pno) LASSERT(target); liblustre_wait_event(0); - llu_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); - rc = mdc_unlink(llu_i2sbi(dir)->ll_lmv_exp, &op_data, &request); + llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); + rc = mdc_unlink(llu_i2sbi(dir)->ll_mdc_exp, &op_data, &request); if (!rc) rc = llu_objects_destroy(request, dir); ptlrpc_req_finished(request); liblustre_wait_event(0); + RETURN(rc); } @@ -1046,8 +1046,8 @@ static int llu_iop_rename_raw(struct pnode *old, struct pnode *new) LASSERT(src); LASSERT(tgt); - llu_prepare_mdc_data(&op_data, src, tgt, NULL, 0, 0); - rc = mdc_rename(llu_i2sbi(src)->ll_lmv_exp, &op_data, + llu_prepare_mdc_op_data(&op_data, src, tgt, NULL, 0, 0); + rc = mdc_rename(llu_i2sbi(src)->ll_mdc_exp, &op_data, oldname, oldnamelen, newname, newnamelen, &request); if (!rc) { @@ -1068,7 +1068,7 @@ static int llu_statfs_internal(struct llu_sb_info *sbi, int rc; ENTRY; - rc = obd_statfs(class_exp2obd(sbi->ll_lmv_exp), osfs, max_age); + rc = obd_statfs(class_exp2obd(sbi->ll_mdc_exp), osfs, max_age); if (rc) { CERROR("mdc_statfs fails: rc = %d\n", rc); RETURN(rc); @@ -1077,7 +1077,7 @@ static int llu_statfs_internal(struct llu_sb_info *sbi, CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n", osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files); - rc = obd_statfs(class_exp2obd(sbi->ll_lov_exp), &obd_osfs, max_age); + rc = obd_statfs(class_exp2obd(sbi->ll_osc_exp), &obd_osfs, max_age); if (rc) { CERROR("obd_statfs fails: rc = %d\n", rc); RETURN(rc); @@ -1162,7 +1162,7 @@ static int llu_iop_statvfs(struct pnode *pno, buf->f_files = fs.f_files; /* Total number serial numbers */ buf->f_ffree = fs.f_ffree; /* Number free serial numbers */ buf->f_favail = fs.f_ffree; /* Number free ser num for non-privileged*/ - buf->f_fsid = fs.f_fstc.__val[1]; + buf->f_fsid = fs.f_fsid.__val[1]; buf->f_flag = 0; /* No equiv in statfs; maybe use type? */ buf->f_namemax = fs.f_namelen; #endif @@ -1189,8 +1189,8 @@ static int llu_iop_mkdir_raw(struct pnode *pno, mode_t mode) RETURN(err); mode = (mode & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR; - llu_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); - err = mdc_create(llu_i2sbi(dir)->ll_lmv_exp, &op_data, NULL, 0, mode, + llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); + err = mdc_create(llu_i2sbi(dir)->ll_mdc_exp, &op_data, NULL, 0, mode, current->fsuid, current->fsgid, 0, &request); ptlrpc_req_finished(request); RETURN(err); @@ -1210,8 +1210,8 @@ static int llu_iop_rmdir_raw(struct pnode *pno) CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%lu(%p)\n", name, lli->lli_st_ino, lli->lli_st_generation, dir); - llu_prepare_mdc_data(&op_data, dir, NULL, name, len, S_IFDIR); - rc = mdc_unlink(llu_i2sbi(dir)->ll_lmv_exp, &op_data, &request); + llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, S_IFDIR); + rc = mdc_unlink(llu_i2sbi(dir)->ll_mdc_exp, &op_data, &request); ptlrpc_req_finished(request); RETURN(rc); @@ -1237,7 +1237,7 @@ static int llu_iop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn) flags = va_arg(ap, long); flags &= FCNTL_FLMASK; if (flags & FCNTL_FLMASK_INVALID) { - CERROR("liblustre does not support O_NONBLOCK, O_ASYNC, " + CERROR("liblustre don't support O_NONBLOCK, O_ASYNC, " "and O_DIRECT on file descriptor\n"); *rtn = -1; return EINVAL; @@ -1353,8 +1353,8 @@ struct filesys_ops llu_filesys_ops = struct inode *llu_iget(struct filesys *fs, struct lustre_md *md) { struct inode *inode; - struct lustre_id id; - struct file_identifier fileid = {&id, sizeof(id)}; + struct ll_fid fid; + struct file_identifier fileid = {&fid, sizeof(fid)}; if ((md->body->valid & (OBD_MD_FLGENER | OBD_MD_FLID | OBD_MD_FLTYPE)) != @@ -1364,15 +1364,17 @@ struct inode *llu_iget(struct filesys *fs, struct lustre_md *md) return ERR_PTR(-EPERM); } - id = md->body->id1; - /* try to find existing inode */ + fid.id = md->body->ino; + fid.generation = md->body->generation; + fid.f_type = md->body->mode & S_IFMT; + inode = _sysio_i_find(fs, &fileid); if (inode) { struct llu_inode_info *lli = llu_i2info(inode); if (inode->i_zombie || - lli->lli_st_generation != id_gen(&md->body->id1)) { + lli->lli_st_generation != md->body->generation) { I_RELE(inode); } else { @@ -1381,13 +1383,15 @@ struct inode *llu_iget(struct filesys *fs, struct lustre_md *md) } } - inode = llu_new_inode(fs, &id); + inode = llu_new_inode(fs, &fid); if (inode) llu_update_inode(inode, md->body, md->lsm); return inode; } +extern struct list_head lustre_profile_list; + static int llu_fsswop_mount(const char *source, unsigned flags, @@ -1399,18 +1403,18 @@ llu_fsswop_mount(const char *source, struct inode *root; struct pnode_base *rootpb; struct obd_device *obd; - struct lustre_id rootid; + struct ll_fid rootfid; struct llu_sb_info *sbi; struct obd_statfs osfs; static struct qstr noname = { NULL, 0, 0 }; struct ptlrpc_request *request = NULL; - struct lustre_handle lmv_conn = {0, }; - struct lustre_handle lov_conn = {0, }; + struct lustre_handle mdc_conn = {0, }; + struct lustre_handle osc_conn = {0, }; struct lustre_md md; class_uuid_t uuid; struct config_llog_instance cfg; struct lustre_profile *lprof; - char *lov = NULL, *lmv = NULL; + char *osc = NULL, *mdc = NULL; int async = 1, err = -EINVAL; ENTRY; @@ -1445,23 +1449,23 @@ llu_fsswop_mount(const char *source, CERROR("No profile found: %s\n", g_zconf_profile); GOTO(out_free, err = -EINVAL); } - if (lov) - OBD_FREE(lov, strlen(lov) + 1); - OBD_ALLOC(lov, strlen(lprof->lp_lov) + + if (osc) + OBD_FREE(osc, strlen(osc) + 1); + OBD_ALLOC(osc, strlen(lprof->lp_osc) + strlen(sbi->ll_instance) + 2); - sprintf(lov, "%s-%s", lprof->lp_lov, sbi->ll_instance); + sprintf(osc, "%s-%s", lprof->lp_osc, sbi->ll_instance); - if (lmv) - OBD_FREE(lmv, strlen(lmv) + 1); - OBD_ALLOC(lmv, strlen(lprof->lp_lmv) + + if (mdc) + OBD_FREE(mdc, strlen(mdc) + 1); + OBD_ALLOC(mdc, strlen(lprof->lp_mdc) + strlen(sbi->ll_instance) + 2); - sprintf(lmv, "%s-%s", lprof->lp_lmv, sbi->ll_instance); + sprintf(mdc, "%s-%s", lprof->lp_mdc, sbi->ll_instance); - if (!lov) { + if (!osc) { CERROR("no osc\n"); GOTO(out_free, err = -EINVAL); } - if (!lmv) { + if (!mdc) { CERROR("no mdc\n"); GOTO(out_free, err = -EINVAL); } @@ -1472,68 +1476,68 @@ llu_fsswop_mount(const char *source, goto out_free; } - obd = class_name2obd(lmv); + obd = class_name2obd(mdc); if (!obd) { - CERROR("MDC %s: not setup or attached\n", lmv); + CERROR("MDC %s: not setup or attached\n", mdc); GOTO(out_free, err = -EINVAL); } obd_set_info(obd->obd_self_export, strlen("async"), "async", sizeof(async), &async); #warning "FIXME ASAP!" #if 0 - if (mdc_init_ea_size(obd, lov)) + if (mdc_init_ea_size(obd, osc)) GOTO(out_free, err = -EINVAL); #endif /* setup mdc */ - err = obd_connect(&lmv_conn, obd, &sbi->ll_sb_uuid, 0); + err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, 0); if (err) { - CERROR("cannot connect to %s: rc = %d\n", lmv, err); + CERROR("cannot connect to %s: rc = %d\n", mdc, err); GOTO(out_free, err); } - sbi->ll_lmv_exp = class_conn2export(&lmv_conn); + sbi->ll_mdc_exp = class_conn2export(&mdc_conn); err = obd_statfs(obd, &osfs, 100000000); if (err) - GOTO(out_lmv, err); + GOTO(out_mdc, err); /* * FIXME fill fs stat data into sbi here!!! FIXME */ - /* setup lov */ - obd = class_name2obd(lov); + /* setup osc */ + obd = class_name2obd(osc); if (!obd) { - CERROR("OSC %s: not setup or attached\n", lov); - GOTO(out_lmv, err = -EINVAL); + CERROR("OSC %s: not setup or attached\n", osc); + GOTO(out_mdc, err = -EINVAL); } obd_set_info(obd->obd_self_export, strlen("async"), "async", sizeof(async), &async); - err = obd_connect(&lov_conn, obd, &sbi->ll_sb_uuid, 0); + err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, 0); if (err) { - CERROR("cannot connect to %s: rc = %d\n", lov, err); - GOTO(out_lmv, err); + CERROR("cannot connect to %s: rc = %d\n", osc, err); + GOTO(out_mdc, err); } - sbi->ll_lov_exp = class_conn2export(&lov_conn); + sbi->ll_osc_exp = class_conn2export(&osc_conn); - err = mdc_getstatus(sbi->ll_lmv_exp, &rootid); + err = mdc_getstatus(sbi->ll_mdc_exp, &rootfid); if (err) { CERROR("cannot mds_connect: rc = %d\n", err); - GOTO(out_lov, err); + GOTO(out_osc, err); } - CDEBUG(D_SUPER, "rootid "LPU64"\n", rootid.li_stc.u.e3s.l3s_ino); - sbi->ll_rootino = rootid.li_stc.u.e3s.l3s_ino; + CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id); + sbi->ll_rootino = rootfid.id; /* fetch attr of root inode */ - err = mdc_getattr(sbi->ll_lmv_exp, &rootid, + err = mdc_getattr(sbi->ll_mdc_exp, &rootfid, OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, 0, &request); if (err) { CERROR("mdc_getattr failed for root: rc = %d\n", err); - GOTO(out_lov, err); + GOTO(out_osc, err); } - err = mdc_req2lustre_md(sbi->ll_lmv_exp, request, 0, - sbi->ll_lov_exp, &md); + err = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0, sbi->ll_osc_exp, + &md); if (err) { CERROR("failed to understand root inode md: rc = %d\n",err); GOTO(out_request, err); @@ -1572,10 +1576,10 @@ out_inode: _sysio_i_gone(root); out_request: ptlrpc_req_finished(request); -out_lov: - obd_disconnect(sbi->ll_lov_exp, 0); -out_lmv: - obd_disconnect(sbi->ll_lmv_exp, 0); +out_osc: + obd_disconnect(sbi->ll_osc_exp, 0); +out_mdc: + obd_disconnect(sbi->ll_mdc_exp, 0); out_free: OBD_FREE(sbi, sizeof(*sbi)); return err; @@ -1585,30 +1589,31 @@ struct fssw_ops llu_fssw_ops = { llu_fsswop_mount }; -struct inode_ops llu_inode_ops = { - .inop_lookup = llu_iop_lookup, - .inop_getattr = llu_iop_getattr, - .inop_setattr = llu_iop_setattr, - .inop_getdirentries = llu_iop_getdirentries, - .inop_mkdir = llu_iop_mkdir_raw, - .inop_rmdir = llu_iop_rmdir_raw, - .inop_symlink = llu_iop_symlink_raw, - .inop_readlink = llu_iop_readlink, - .inop_open = llu_iop_open, - .inop_close = llu_iop_close, - .inop_link = llu_iop_link_raw, - .inop_unlink = llu_iop_unlink_raw, - .inop_rename = llu_iop_rename_raw, - .inop_iodone = llu_iop_iodone, - .inop_fcntl = llu_iop_fcntl, - .inop_sync = llu_iop_sync, - .inop_read = llu_iop_read, - .inop_write = llu_iop_write, - .inop_datasync = llu_iop_datasync, - .inop_ioctl = llu_iop_ioctl, - .inop_mknod = llu_iop_mknod_raw, +static struct inode_ops llu_inode_ops = { + inop_lookup: llu_iop_lookup, + inop_getattr: llu_iop_getattr, + inop_setattr: llu_iop_setattr, + inop_getdirentries: llu_iop_getdirentries, + inop_mkdir: llu_iop_mkdir_raw, + inop_rmdir: llu_iop_rmdir_raw, + inop_symlink: llu_iop_symlink_raw, + inop_readlink: llu_iop_readlink, + inop_open: llu_iop_open, + inop_close: llu_iop_close, + inop_link: llu_iop_link_raw, + inop_unlink: llu_iop_unlink_raw, + inop_rename: llu_iop_rename_raw, + inop_pos: llu_iop_pos, + inop_read: llu_iop_read, + inop_write: llu_iop_write, + inop_iodone: llu_iop_iodone, + inop_fcntl: llu_iop_fcntl, + inop_sync: llu_iop_sync, + inop_datasync: llu_iop_datasync, + inop_ioctl: llu_iop_ioctl, + inop_mknod: llu_iop_mknod_raw, #ifdef _HAVE_STATVFS - .inop_statvfs = llu_iop_statvfs, + inop_statvfs: llu_iop_statvfs, #endif - .inop_gone = llu_iop_gone, + inop_gone: llu_iop_gone, }; diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 7743136..1984bc0 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -169,7 +169,7 @@ int revalidate_it_finish(struct ptlrpc_request *request, int offset, RETURN(-ENOENT); sbi = ll_i2sbi(de->d_inode); - rc = ll_prep_inode(sbi->ll_lov_exp, sbi->ll_lmv_exp, + rc = ll_prep_inode(sbi->ll_osc_exp, sbi->ll_mdc_exp, &de->d_inode, request, offset, NULL); RETURN(rc); @@ -203,7 +203,6 @@ void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry) void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft) { struct lookup_intent *it = *itp; - #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) if (it) { LASSERTF(it->it_magic == INTENT_MAGIC, "bad intent magic: %x\n", @@ -221,8 +220,7 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd, struct lookup_intent *it) { int rc; - struct lustre_id pid; - struct lustre_id cid; + struct ll_fid pfid, cfid; struct it_cb_data icbd; struct ptlrpc_request *req = NULL; struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; @@ -237,20 +235,18 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd, RETURN(0); CDEBUG(D_INODE, "revalidate 0x%p: %*s -> %lu/%lu\n", - de, de->d_name.len, de->d_name.name, - (unsigned long) de->d_inode->i_ino, - (unsigned long) de->d_inode->i_generation); + de, de->d_name.len, de->d_name.name, + (unsigned long) de->d_inode->i_ino, + (unsigned long) de->d_inode->i_generation); - exp = ll_i2lmvexp(de->d_inode); - ll_inode2id(&pid, de->d_parent->d_inode); - ll_inode2id(&cid, de->d_inode); + exp = ll_i2mdcexp(de->d_inode); + ll_inode2fid(&pfid, de->d_parent->d_inode); + ll_inode2fid(&cfid, de->d_inode); icbd.icbd_parent = de->d_parent->d_inode; icbd.icbd_childp = &de; - /* - * never execute intents for mount points. Attributes will be fixed up - * in ll_inode_revalidate_it(). - */ + /* Never execute intents for mount points. + * Attributes will be fixed up in ll_inode_revalidate_it */ if (d_mountpoint(de)) RETURN(1); @@ -262,8 +258,8 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd, if (it->it_op == IT_GETATTR) { /* We need to check for LOOKUP lock as well */ - rc = md_intent_lock(exp, &pid, de->d_name.name, - de->d_name.len, NULL, 0, &cid, &lookup_it, + rc = md_intent_lock(exp, &pfid, de->d_name.name, + de->d_name.len, NULL, 0, &cfid, &lookup_it, flags, &req, ll_mdc_blocking_ast); /* If there was no lookup lock, no point in even checking for UPDATE lock */ @@ -283,13 +279,9 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd, ll_lookup_finish_locks(&lookup_it, de); } - /* at this point fid should be valid. */ - LASSERT(id_fid(&cid) != 0); - - rc = md_intent_lock(exp, &pid, de->d_name.name, de->d_name.len, - NULL, 0, &cid, it, flags, &req, + rc = md_intent_lock(exp, &pfid, de->d_name.name, de->d_name.len, + NULL, 0, &cfid, it, flags, &req, ll_mdc_blocking_ast); - /* 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) @@ -370,7 +362,7 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd, unlock_kernel(); handle = (flag) ? &ldd->lld_mnt_och : &ldd->lld_cwd_och; - rc = obd_pin(sbi->ll_lmv_exp, inode->i_ino, inode->i_generation, + rc = obd_pin(sbi->ll_mdc_exp, inode->i_ino, inode->i_generation, inode->i_mode & S_IFMT, handle, flag); if (rc) { @@ -420,7 +412,7 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd, return; } - rc = obd_unpin(sbi->ll_lmv_exp, &handle, flag); + rc = obd_unpin(sbi->ll_mdc_exp, &handle, flag); EXIT; return; } @@ -444,12 +436,12 @@ static int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd) static void ll_dentry_iput(struct dentry *dentry, struct inode *inode) { struct ll_sb_info *sbi = ll_i2sbi(inode); - struct lustre_id parent, child; + struct ll_fid parent, child; LASSERT(dentry->d_parent && dentry->d_parent->d_inode); - ll_inode2id(&parent, dentry->d_parent->d_inode); - ll_inode2id(&child, inode); - md_change_cbdata_name(sbi->ll_lmv_exp, &parent, + ll_inode2fid(&parent, dentry->d_parent->d_inode); + ll_inode2fid(&child, inode); + md_change_cbdata_name(sbi->ll_mdc_exp, &parent, (char *)dentry->d_name.name, dentry->d_name.len, &child, null_if_equal, inode); diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 50d402d..6ac70be 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -61,26 +61,24 @@ typedef struct ext2_dir_entry_2 ext2_dirent; static int ll_dir_readpage(struct file *file, struct page *page) { struct inode *inode = page->mapping->host; + struct ll_fid mdc_fid; + __u64 offset; struct ptlrpc_request *request; struct mds_body *body; - struct lustre_id id; - __u64 offset; int rc = 0; ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); - mdc_pack_id(&id, inode->i_ino, inode->i_generation, - S_IFDIR, id_group(&ll_i2info(inode)->lli_id), - id_fid(&ll_i2info(inode)->lli_id)); - + mdc_pack_fid(&mdc_fid, inode->i_ino, inode->i_generation, S_IFDIR); + mdc_fid.mds = ll_i2info(inode)->lli_mds; offset = page->index << PAGE_SHIFT; - rc = md_readpage(ll_i2sbi(inode)->ll_lmv_exp, &id, offset, - page, &request); + rc = md_readpage(ll_i2sbi(inode)->ll_mdc_exp, &mdc_fid, + offset, page, &request); if (!rc) { - body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body)); - LASSERT (body != NULL); /* checked by md_readpage() */ + body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body)); + LASSERT (body != NULL); /* checked by md_readpage() */ LASSERT_REPSWABBED (request, 0); /* swabbed by md_readpage() */ #warning "FIXME ASAP!" @@ -90,7 +88,8 @@ static int ll_dir_readpage(struct file *file, struct page *page) ptlrpc_req_finished(request); unlock_page(page); - RETURN(rc); + EXIT; + return rc; } struct address_space_operations ll_dir_aops = { @@ -117,6 +116,7 @@ static inline unsigned long dir_pages(struct inode *inode) return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT; } + static void ext2_check_page(struct page *page) { struct inode *dir = page->mapping->host; @@ -208,17 +208,16 @@ fail: static struct page *ll_get_dir_page(struct inode *dir, unsigned long n) { - struct ll_inode_info *li = ll_i2info(dir); struct ldlm_res_id res_id = - { .name = { id_fid(&li->lli_id), id_group(&li->lli_id)} }; + { .name = { dir->i_ino, (__u64)dir->i_generation} }; struct lustre_handle lockh; - struct obd_device *obddev = class_exp2obd(ll_i2sbi(dir)->ll_lmv_exp); + struct obd_device *obddev = class_exp2obd(ll_i2sbi(dir)->ll_mdc_exp); struct address_space *mapping = dir->i_mapping; struct page *page; ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_UPDATE } }; int rc; - obddev = md_get_real_obd(ll_i2sbi(dir)->ll_lmv_exp, NULL, 0); + obddev = md_get_real_obd(ll_i2sbi(dir)->ll_mdc_exp, NULL, 0); rc = ldlm_lock_match(obddev->obd_namespace, LDLM_FL_BLOCK_GRANTED, &res_id, LDLM_IBITS, &policy, LCK_PR, &lockh); if (!rc) { @@ -226,9 +225,9 @@ static struct page *ll_get_dir_page(struct inode *dir, unsigned long n) struct ptlrpc_request *request; struct mdc_op_data data; - ll_prepare_mdc_data(&data, dir, NULL, NULL, 0, 0); + ll_prepare_mdc_op_data(&data, dir, NULL, NULL, 0, 0); - rc = md_enqueue(ll_i2sbi(dir)->ll_lmv_exp, LDLM_IBITS, &it, + rc = md_enqueue(ll_i2sbi(dir)->ll_mdc_exp, LDLM_IBITS, &it, LCK_PR, &data, &lockh, NULL, 0, ldlm_completion_ast, ll_mdc_blocking_ast, dir); @@ -401,8 +400,8 @@ static int ll_mkdir_stripe(struct inode *inode, unsigned long arg) mode = lums.lums_mode; mode = (mode & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR; - ll_prepare_mdc_data(&op_data, inode, NULL, name,lums.lums_namelen,0); - err = md_create(sbi->ll_lmv_exp, &op_data, &nstripes, sizeof(nstripes), + ll_prepare_mdc_op_data(&op_data, inode, NULL, name,lums.lums_namelen,0); + err = md_create(sbi->ll_mdc_exp, &op_data, &nstripes, sizeof(nstripes), mode, current->fsuid, current->fsgid, 0, &request); ptlrpc_req_finished(request); @@ -431,7 +430,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, RETURN(ll_iocontrol(inode, file, cmd, arg)); case IOC_MDC_LOOKUP: { struct ptlrpc_request *request = NULL; - struct lustre_id id; + struct ll_fid fid; char *buf = NULL; char *filename; int namelen, rc, len = 0; @@ -451,8 +450,8 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, } valid = OBD_MD_FLID; - ll_inode2id(&id, inode); - rc = md_getattr_name(sbi->ll_lmv_exp, &id, + ll_inode2fid(&fid, inode); + rc = md_getattr_name(sbi->ll_mdc_exp, &fid, filename, namelen, valid, 0, &request); if (rc < 0) { CDEBUG(D_INFO, "md_getattr_name: %d\n", rc); @@ -477,7 +476,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, struct lov_user_md lum, *lump = (struct lov_user_md *)arg; int rc = 0; - ll_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0); + ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0); LASSERT(sizeof(lum) == sizeof(*lump)); LASSERT(sizeof(lum.lmm_objects[0]) == @@ -489,7 +488,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, if (lum.lmm_magic != LOV_USER_MAGIC) RETURN(-EINVAL); - rc = md_setattr(sbi->ll_lmv_exp, &op_data, + rc = md_setattr(sbi->ll_mdc_exp, &op_data, &attr, &lum, sizeof(lum), NULL, 0, &request); if (rc) { ptlrpc_req_finished(request); @@ -505,16 +504,16 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, struct ptlrpc_request *request = NULL; struct lov_user_md *lump = (struct lov_user_md *)arg; struct lov_mds_md *lmm; - struct lustre_id id; + struct ll_fid fid; struct mds_body *body; unsigned long valid = 0; int rc, lmmsize; valid |= OBD_MD_FLDIREA; - ll_inode2id(&id, inode); - rc = md_getattr(sbi->ll_lmv_exp, &id, valid, - obd_size_diskmd(sbi->ll_lov_exp, NULL), + ll_inode2fid(&fid, inode); + rc = md_getattr(sbi->ll_mdc_exp, &fid, valid, + obd_size_diskmd(sbi->ll_osc_exp, NULL), &request); if (rc < 0) { CDEBUG(D_INFO, "md_getattr failed: rc = %d\n", rc); @@ -543,7 +542,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, } case IOC_MDC_GETSTRIPE: { struct ptlrpc_request *request = NULL; - struct lustre_id id; + struct ll_fid fid; struct mds_body *body; struct lov_user_md *lump = (struct lov_user_md *)arg; struct lov_mds_md *lmm; @@ -554,10 +553,10 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, if (IS_ERR(filename)) RETURN(PTR_ERR(filename)); - ll_inode2id(&id, inode); - rc = md_getattr_name(sbi->ll_lmv_exp, &id, filename, + ll_inode2fid(&fid, inode); + rc = md_getattr_name(sbi->ll_mdc_exp, &fid, filename, strlen(filename) + 1, OBD_MD_FLEASIZE, - obd_size_diskmd(sbi->ll_lov_exp, NULL), + obd_size_diskmd(sbi->ll_osc_exp, NULL), &request); if (rc < 0) { CDEBUG(D_INFO, "md_getattr_name failed on %s: rc %d\n", @@ -660,7 +659,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, bufs[1] = NULL; } size = data->ioc_plen1; - req = ptlrpc_prep_req(sbi2lmv(sbi)->cl_import, + req = ptlrpc_prep_req(sbi2mdc(sbi)->cl_import, LUSTRE_LOG_VERSION, LLOG_CATINFO, 2, lens, bufs); if (!req) @@ -679,8 +678,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, RETURN(rc); } default: - return obd_iocontrol(cmd, sbi->ll_lov_exp, 0, - NULL, (void *)arg); + return obd_iocontrol(cmd, sbi->ll_osc_exp,0,NULL,(void *)arg); } } diff --git a/lustre/llite/file.c b/lustre/llite/file.c index e30f5ba..117a08c 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -33,7 +33,7 @@ #include "llite_internal.h" #include -int ll_mdc_close(struct obd_export *lmv_exp, struct inode *inode, +int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode, struct file *file) { struct ll_file_data *fd = file->private_data; @@ -53,16 +53,16 @@ int ll_mdc_close(struct obd_export *lmv_exp, struct inode *inode, obdo.o_id = inode->i_ino; obdo.o_valid = OBD_MD_FLID; - obdo_from_inode(&obdo, inode, (OBD_MD_FLTYPE | OBD_MD_FLMODE | - OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | - OBD_MD_FLATIME | OBD_MD_FLMTIME | - OBD_MD_FLCTIME)); + obdo_from_inode(&obdo, inode, OBD_MD_FLTYPE | OBD_MD_FLMODE | + OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | + OBD_MD_FLATIME | OBD_MD_FLMTIME | + OBD_MD_FLCTIME); if (0 /* ll_is_inode_dirty(inode) */) { obdo.o_flags = MDS_BFLAG_UNCOMMITTED_WRITES; obdo.o_valid |= OBD_MD_FLFLAGS; } - obdo.o_mds = id_group(&ll_i2info(inode)->lli_id); - rc = md_close(lmv_exp, &obdo, och, &req); + obdo.o_mds = ll_i2info(inode)->lli_mds; + rc = md_close(mdc_exp, &obdo, och, &req); if (rc == EAGAIN) { /* We are the last writer, so the MDS has instructed us to get @@ -80,7 +80,7 @@ int ll_mdc_close(struct obd_export *lmv_exp, struct inode *inode, inode->i_ino, rc); } - mdc_clear_open_replay_data(lmv_exp, och); + mdc_clear_open_replay_data(mdc_exp, och); ptlrpc_req_finished(req); och->och_fh.cookie = DEAD_HANDLE_MAGIC; file->private_data = NULL; @@ -101,8 +101,9 @@ int ll_file_release(struct inode *inode, struct file *file) int rc; ENTRY; - CDEBUG(D_VFSTRACE, "VFS Op:inode="DLID4"(%p)\n", - OLID4(&ll_i2info(inode)->lli_id), inode); + CDEBUG(D_VFSTRACE, "VFS Op:inode=%u/%lu/%u(%p)\n", + ll_i2info(inode)->lli_mds, inode->i_ino, + inode->i_generation, inode); /* don't do anything for / */ if (inode->i_sb->s_root == file->f_dentry) @@ -112,7 +113,7 @@ int ll_file_release(struct inode *inode, struct file *file) fd = (struct ll_file_data *)file->private_data; LASSERT(fd != NULL); - rc = ll_mdc_close(sbi->ll_lmv_exp, inode, file); + rc = ll_mdc_close(sbi->ll_mdc_exp, inode, file); RETURN(rc); } @@ -130,9 +131,9 @@ static int ll_intent_file_open(struct file *file, void *lmm, if (!parent) RETURN(-ENOENT); - ll_prepare_mdc_data(&data, parent->d_inode, NULL, name, len, O_RDWR); + ll_prepare_mdc_op_data(&data, parent->d_inode, NULL, name, len, O_RDWR); - rc = md_enqueue(sbi->ll_lmv_exp, LDLM_IBITS, itp, LCK_PR, &data, + rc = md_enqueue(sbi->ll_mdc_exp, LDLM_IBITS, itp, LCK_PR, &data, &lockh, lmm, lmmsize, ldlm_completion_ast, ll_mdc_blocking_ast, NULL); if (rc == 0) { @@ -150,7 +151,7 @@ int ll_local_open(struct file *file, struct lookup_intent *it) { struct ptlrpc_request *req = it->d.lustre.it_data; struct ll_inode_info *lli = ll_i2info(file->f_dentry->d_inode); - struct obd_export *lmv_exp = ll_i2lmvexp(file->f_dentry->d_inode); + struct obd_export *mdc_exp = ll_i2mdcexp(file->f_dentry->d_inode); struct ll_file_data *fd; struct mds_body *body; ENTRY; @@ -169,7 +170,6 @@ int ll_local_open(struct file *file, struct lookup_intent *it) OBD_SLAB_ALLOC(fd, ll_file_data_slab, SLAB_KERNEL, sizeof *fd); - /* We can't handle this well without reorganizing ll_file_open and * ll_mdc_close, so don't even try right now. */ LASSERT(fd != NULL); @@ -181,7 +181,7 @@ int ll_local_open(struct file *file, struct lookup_intent *it) lli->lli_io_epoch = body->io_epoch; - mdc_set_open_replay_data(lmv_exp, &fd->fd_mds_och, it->d.lustre.it_data); + mdc_set_open_replay_data(mdc_exp, &fd->fd_mds_och, it->d.lustre.it_data); RETURN(0); } @@ -678,7 +678,7 @@ int ll_glimpse_size(struct inode *inode) CDEBUG(D_DLMTRACE, "Glimpsing inode %lu\n", inode->i_ino); - rc = obd_enqueue(sbi->ll_lov_exp, lli->lli_smd, LDLM_EXTENT, &policy, + rc = obd_enqueue(sbi->ll_osc_exp, lli->lli_smd, LDLM_EXTENT, &policy, LCK_PR, &flags, ll_extent_lock_callback, ldlm_completion_ast, ll_glimpse_callback, inode, sizeof(struct ost_lvb), lustre_swab_ost_lvb, &lockh); @@ -694,9 +694,10 @@ int ll_glimpse_size(struct inode *inode) inode->i_blocks = lov_merge_blocks(lli->lli_smd); //inode->i_mtime = lov_merge_mtime(lli->lli_smd, inode->i_mtime); - CDEBUG(D_DLMTRACE, "glimpse: size: "LPU64", blocks: "LPU64"\n", - (__u64)inode->i_size, (__u64)inode->i_blocks); - obd_cancel(sbi->ll_lov_exp, lli->lli_smd, LCK_PR, &lockh); + CDEBUG(D_DLMTRACE, "glimpse: size: %llu, blocks: %lu\n", + inode->i_size, inode->i_blocks); + obd_cancel(sbi->ll_osc_exp, lli->lli_smd, LCK_PR, &lockh); + RETURN(rc); } @@ -732,7 +733,8 @@ int ll_extent_lock(struct ll_file_data *fd, struct inode *inode, inode->i_ino, policy->l_extent.start, policy->l_extent.end); do_gettimeofday(&start); - rc = obd_enqueue(sbi->ll_lov_exp, lsm, LDLM_EXTENT, policy, mode, + + rc = obd_enqueue(sbi->ll_osc_exp, lsm, LDLM_EXTENT, policy, mode, &ast_flags, ll_extent_lock_callback, ldlm_completion_ast, ll_glimpse_callback, inode, sizeof(struct ost_lvb), lustre_swab_ost_lvb, lockh); @@ -773,7 +775,7 @@ int ll_extent_unlock(struct ll_file_data *fd, struct inode *inode, (sbi->ll_flags & LL_SBI_NOLCK)) RETURN(0); - rc = obd_cancel(sbi->ll_lov_exp, lsm, mode, lockh); + rc = obd_cancel(sbi->ll_osc_exp, lsm, mode, lockh); RETURN(rc); } @@ -811,6 +813,7 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count, rc = ll_tree_lock(&tree, node, inode, buf, count, file->f_flags & O_NONBLOCK ? LDLM_FL_BLOCK_NOWAIT :0); + if (rc != 0) RETURN(rc); @@ -841,11 +844,8 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count, RETURN(retval); } -/* - * Write to a file (through the page cache). - */ -static ssize_t ll_file_write(struct file *file, const char *buf, - size_t count, loff_t *ppos) +static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, + loff_t *ppos) { struct inode *inode = file->f_dentry->d_inode; loff_t maxbytes = ll_file_maxbytes(inode); @@ -958,7 +958,7 @@ static int ll_lov_recreate_obj(struct inode *inode, struct file *file, oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLFLAGS; oa->o_flags |= OBD_FL_RECREATE_OBJS; obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME | - OBD_MD_FLMTIME | OBD_MD_FLCTIME); + OBD_MD_FLMTIME | OBD_MD_FLCTIME); oti.oti_objid = NULL; memcpy(lsm2, lsm, lsm_size); @@ -1013,7 +1013,7 @@ static int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, if (rc < 0) GOTO(out, rc); - rc = mdc_req2lustre_md(ll_i2lmvexp(inode), req, 1, exp, &md); + rc = mdc_req2lustre_md(ll_i2mdcexp(inode), req, 1, exp, &md); if (rc) GOTO(out, rc); ll_update_inode(f->f_dentry->d_inode, &md); @@ -1276,7 +1276,7 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data) { struct inode *inode = dentry->d_inode; struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd; - struct lustre_id id; + struct ll_fid fid; struct ptlrpc_request *req; int rc, err; ENTRY; @@ -1289,8 +1289,8 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data) * that IO to finish before calling the osc and mdc sync methods */ rc = filemap_fdatawait(inode->i_mapping); - ll_inode2id(&id, inode); - err = md_sync(ll_i2sbi(inode)->ll_lmv_exp, &id, &req); + ll_inode2fid(&fid, inode); + err = md_sync(ll_i2sbi(inode)->ll_mdc_exp, &fid, &req); if (!rc) rc = err; if (!err) @@ -1305,11 +1305,11 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data) oa->o_id = lsm->lsm_object_id; oa->o_gr = lsm->lsm_object_gr; oa->o_valid = OBD_MD_FLID; - obdo_from_inode(oa, inode, (OBD_MD_FLTYPE | OBD_MD_FLATIME | - OBD_MD_FLMTIME | OBD_MD_FLCTIME | - OBD_MD_FLGROUP)); + obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME | + OBD_MD_FLMTIME | OBD_MD_FLCTIME | + OBD_MD_FLGROUP); - err = obd_sync(ll_i2sbi(inode)->ll_lov_exp, oa, lsm, + err = obd_sync(ll_i2sbi(inode)->ll_osc_exp, oa, lsm, 0, OBD_OBJECT_EOF); if (!rc) rc = err; @@ -1322,11 +1322,10 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data) int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) { struct inode *inode = file->f_dentry->d_inode; - struct ll_inode_info *li = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); struct obd_device *obddev; struct ldlm_res_id res_id = - { .name = {id_fid(&li->lli_id), id_group(&li->lli_id), LDLM_FLOCK} }; + { .name = {inode->i_ino, inode->i_generation, LDLM_FLOCK} }; struct lustre_handle lockh = {0}; ldlm_policy_data_t flock; ldlm_mode_t mode = 0; @@ -1395,7 +1394,7 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) "start="LPU64", end="LPU64"\n", inode->i_ino, flock.l_flock.pid, flags, mode, flock.l_flock.start, flock.l_flock.end); - obddev = md_get_real_obd(sbi->ll_lmv_exp, NULL, 0); + obddev = md_get_real_obd(sbi->ll_mdc_exp, NULL, 0); rc = ldlm_cli_enqueue(obddev->obd_self_export, NULL, obddev->obd_namespace, res_id, LDLM_FLOCK, &flock, mode, &flags, @@ -1409,10 +1408,10 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it) struct inode *inode = dentry->d_inode; struct ll_inode_info *lli; struct lov_stripe_md *lsm; - struct lustre_id id; struct ptlrpc_request *req = NULL; struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode); struct lookup_intent oit = { .it_op = IT_GETATTR }; + struct ll_fid cfid; int rc; ENTRY; @@ -1421,21 +1420,17 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it) CERROR("REPORT THIS LINE TO PETER\n"); RETURN(0); } - - ll_inode2id(&id, inode); lli = ll_i2info(inode); - LASSERT(id_fid(&id) != 0); - CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),name=%s,intent=%s\n", inode->i_ino, inode->i_generation, inode, dentry->d_name.name, LL_IT2STR(it)); - #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)) lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_REVALIDATE); #endif - rc = md_intent_lock(sbi->ll_lmv_exp, &id, - NULL, 0, NULL, 0, &id, &oit, 0, &req, + ll_inode2fid(&cfid, dentry->d_inode); + rc = md_intent_lock(sbi->ll_mdc_exp, &cfid, + NULL, 0, NULL, 0, &cfid, &oit, 0, &req, ll_mdc_blocking_ast); if (rc < 0) GOTO(out, rc); diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 5e0c95b..ce92461 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -35,17 +35,14 @@ struct ll_ra_info { }; struct ll_sb_info { - /* this protects pglist and max_r_a_pages. It isn't safe to grab from - * interrupt contexts. */ + /* this protects pglist and ra_info. It isn't safe to + * grab from interrupt contexts */ spinlock_t ll_lock; - struct obd_uuid ll_sb_uuid; - struct obd_export *ll_lmv_exp; - struct lmv_desc ll_lmv_desc; - struct obd_export *ll_lov_exp; - struct lov_desc ll_lov_desc; - struct proc_dir_entry *ll_proc_root; - struct lustre_id ll_rootid; /* root lustre id */ + struct obd_export *ll_mdc_exp; + struct obd_export *ll_osc_exp; + struct proc_dir_entry* ll_proc_root; + obd_id ll_rootino; /* number of root inode */ struct lustre_mount_data *ll_lmd; char *ll_instance; @@ -56,7 +53,7 @@ struct ll_sb_info { struct hlist_head ll_orphan_dentry_list; /*please don't ask -p*/ struct ll_close_queue *ll_lcq; - struct lprocfs_stats *ll_stats; /* lprocfs stats counter */ + struct lprocfs_stats *ll_stats; /* lprocfs stats counter */ unsigned long ll_pglist_gen; struct list_head ll_pglist; @@ -156,8 +153,7 @@ struct ll_async_page { /* llite/lproc_llite.c */ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, - struct super_block *sb, char *lov, - char *lmv); + struct super_block *sb, char *osc, char *mdc); void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi); /* llite/dir.c */ @@ -206,7 +202,7 @@ int ll_file_release(struct inode *inode, struct file *file); int ll_lsm_getattr(struct obd_export *, struct lov_stripe_md *, struct obdo *); int ll_glimpse_size(struct inode *inode); int ll_local_open(struct file *file, struct lookup_intent *it); -int ll_mdc_close(struct obd_export *lmv_exp, struct inode *inode, +int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode, struct file *file); #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) int ll_getattr(struct vfsmount *mnt, struct dentry *de, @@ -355,18 +351,18 @@ static inline __u64 ll_ts2u64(time_t *time) /* don't need an addref as the sb_info should be holding one */ static inline struct obd_export *ll_s2obdexp(struct super_block *sb) { - return ll_s2sbi(sb)->ll_lov_exp; + return ll_s2sbi(sb)->ll_osc_exp; } /* don't need an addref as the sb_info should be holding one */ -static inline struct obd_export *ll_s2lmvexp(struct super_block *sb) +static inline struct obd_export *ll_s2mdcexp(struct super_block *sb) { - return ll_s2sbi(sb)->ll_lmv_exp; + return ll_s2sbi(sb)->ll_mdc_exp; } -static inline struct client_obd *sbi2lmv(struct ll_sb_info *sbi) +static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi) { - struct obd_device *obd = sbi->ll_lmv_exp->exp_obd; + struct obd_device *obd = sbi->ll_mdc_exp->exp_obd; if (obd == NULL) LBUG(); return &obd->u.cli; @@ -383,14 +379,14 @@ static inline struct obd_export *ll_i2obdexp(struct inode *inode) return ll_s2obdexp(inode->i_sb); } -static inline struct obd_export *ll_i2lmvexp(struct inode *inode) +static inline struct obd_export *ll_i2mdcexp(struct inode *inode) { - return ll_s2lmvexp(inode->i_sb); + return ll_s2mdcexp(inode->i_sb); } static inline int ll_mds_max_easize(struct super_block *sb) { - return sbi2lmv(ll_s2sbi(sb))->cl_max_mds_easize; + return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize; } static inline __u64 ll_file_maxbytes(struct inode *inode) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index bd2774c..4ab2c4a 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -92,148 +92,130 @@ void lustre_free_sbi(struct super_block *sb) EXIT; } -int lustre_init_lov_desc(struct ll_sb_info *sbi) +int lustre_init_ea_size(struct ll_sb_info *sbi) { - int valsize, rc; - ENTRY; + struct lov_desc desc; + int rc, valsize; - valsize = sizeof(sbi->ll_lov_desc); - memset(&sbi->ll_lov_desc, 0, sizeof(sbi->ll_lov_desc)); - rc = obd_get_info(sbi->ll_lov_exp, strlen("lovdesc") + 1, - "lovdesc", &valsize, &sbi->ll_lov_desc); - RETURN(rc); -} + /* OSC may have larger ea size */ + valsize = sizeof(desc); + rc = obd_get_info(sbi->ll_osc_exp, strlen("lovdesc") + 1, "lovdesc", + &valsize, &desc); + if (rc) + RETURN(rc); + obd_init_ea_size(sbi->ll_mdc_exp, obd_size_diskmd(sbi->ll_osc_exp, NULL), + desc.ld_tgt_count*sizeof(struct llog_cookie)); -int lustre_init_lmv_desc(struct ll_sb_info *sbi) -{ - int valsize, rc; - ENTRY; - - valsize = sizeof(sbi->ll_lmv_desc); - memset(&sbi->ll_lmv_desc, 0, sizeof(sbi->ll_lmv_desc)); - rc = obd_get_info(sbi->ll_lmv_exp, strlen("lmvdesc") + 1, - "lmvdesc", &valsize, &sbi->ll_lmv_desc); RETURN(rc); } -int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov) +int lustre_common_fill_super(struct super_block *sb, char *mdc, char *osc) { + struct inode *root = 0; struct ll_sb_info *sbi = ll_s2sbi(sb); - struct ptlrpc_request *request = NULL; - struct lustre_handle lov_conn = {0, }; - struct lustre_handle lmv_conn = {0, }; - struct inode *root = NULL; struct obd_device *obd; + struct ll_fid rootfid; struct obd_statfs osfs; + struct ptlrpc_request *request = NULL; + struct lustre_handle osc_conn = {0, }; + struct lustre_handle mdc_conn = {0, }; struct lustre_md md; kdev_t devno; int err; - obd = class_name2obd(lmv); + obd = class_name2obd(mdc); if (!obd) { - CERROR("MDC %s: not setup or attached\n", lmv); + CERROR("MDC %s: not setup or attached\n", mdc); RETURN(-EINVAL); } if (proc_lustre_fs_root) { err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb, - lov, lmv); + osc, mdc); if (err < 0) CERROR("could not register mount in /proc/lustre"); } - err = obd_connect(&lmv_conn, obd, &sbi->ll_sb_uuid, 0); + err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, 0); if (err == -EBUSY) { CERROR("An MDS (mdc %s) is performing recovery, of which this" " client is not a part. Please wait for recovery to " - "complete, abort, or time out.\n", lmv); + "complete, abort, or time out.\n", mdc); GOTO(out, err); } else if (err) { - CERROR("cannot connect to %s: rc = %d\n", lmv, err); + CERROR("cannot connect to %s: rc = %d\n", mdc, err); GOTO(out, err); } - sbi->ll_lmv_exp = class_conn2export(&lmv_conn); + sbi->ll_mdc_exp = class_conn2export(&mdc_conn); - lustre_init_lmv_desc(sbi); - err = obd_statfs(obd, &osfs, jiffies - HZ); if (err) - GOTO(out_lmv, err); + GOTO(out_mdc, err); - if (!osfs.os_bsize) { - CERROR("Invalid block size is detected."); - GOTO(out_lmv, err); - } - - sb->s_magic = LL_SUPER_MAGIC; + LASSERT(osfs.os_bsize); sb->s_blocksize = osfs.os_bsize; sb->s_blocksize_bits = log2(osfs.os_bsize); + sb->s_magic = LL_SUPER_MAGIC; sb->s_maxbytes = PAGE_CACHE_MAXBYTES; - devno = get_uuid2int(sbi->ll_lmv_exp->exp_obd->obd_uuid.uuid, - strlen(sbi->ll_lmv_exp->exp_obd->obd_uuid.uuid)); + devno = get_uuid2int(sbi->ll_mdc_exp->exp_obd->obd_uuid.uuid, + strlen(sbi->ll_mdc_exp->exp_obd->obd_uuid.uuid)); sb->s_dev = devno; - obd = class_name2obd(lov); + obd = class_name2obd(osc); if (!obd) { - CERROR("OSC %s: not setup or attached\n", lov); - GOTO(out_lmv, err); + CERROR("OSC %s: not setup or attached\n", osc); + GOTO(out_mdc, err); } - err = obd_connect(&lov_conn, obd, &sbi->ll_sb_uuid, 0); + err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, 0); if (err == -EBUSY) { CERROR("An OST (osc %s) is performing recovery, of which this" " client is not a part. Please wait for recovery to " - "complete, abort, or time out.\n", lov); + "complete, abort, or time out.\n", osc); GOTO(out, err); } else if (err) { - CERROR("cannot connect to %s: rc = %d\n", lov, err); - GOTO(out_lmv, err); - } - sbi->ll_lov_exp = class_conn2export(&lov_conn); - - err = lustre_init_lov_desc(sbi); - if (err == 0) { - int mdsize = obd_size_diskmd(sbi->ll_lov_exp, NULL); - obd_init_ea_size(sbi->ll_lmv_exp, mdsize, - sbi->ll_lov_desc.ld_tgt_count * - sizeof(struct llog_cookie)); + CERROR("cannot connect to %s: rc = %d\n", osc, err); + GOTO(out_mdc, err); } - - err = md_getstatus(sbi->ll_lmv_exp, &sbi->ll_rootid); + sbi->ll_osc_exp = class_conn2export(&osc_conn); + + lustre_init_ea_size(sbi); + err = md_getstatus(sbi->ll_mdc_exp, &rootfid); if (err) { CERROR("cannot mds_connect: rc = %d\n", err); - GOTO(out_lov, err); + GOTO(out_osc, err); } - CDEBUG(D_SUPER, "rootid "DLID4"\n", OLID4(&sbi->ll_rootid)); + CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id); + sbi->ll_rootino = rootfid.id; sb->s_op = &lustre_super_operations; /* make root inode * XXX: move this to after cbd setup? */ - err = md_getattr(sbi->ll_lmv_exp, &sbi->ll_rootid, - OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS | OBD_MD_FID, - 0, &request); + err = md_getattr(sbi->ll_mdc_exp, &rootfid, + OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS, 0, &request); if (err) { CERROR("md_getattr failed for root: rc = %d\n", err); - GOTO(out_lov, err); + GOTO(out_osc, err); } - err = mdc_req2lustre_md(sbi->ll_lmv_exp, request, 0, - sbi->ll_lov_exp, &md); + err = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0, + sbi->ll_osc_exp, &md); if (err) { - CERROR("failed to understand root inode md: rc = %d\n", err); - ptlrpc_req_finished(request); - GOTO(out_lov, err); + CERROR("failed to understand root inode md: rc = %d\n",err); + ptlrpc_req_finished (request); + GOTO(out_osc, err); } - LASSERT(sbi->ll_rootid.li_stc.u.e3s.l3s_ino != 0); - root = ll_iget(sb, sbi->ll_rootid.li_stc.u.e3s.l3s_ino, &md); + LASSERT(sbi->ll_rootino != 0); + root = ll_iget(sb, sbi->ll_rootino, &md); ptlrpc_req_finished(request); if (root == NULL || is_bad_inode(root)) { + /* XXX might need iput() for bad inode */ CERROR("lustre_lite: bad iget4 for root\n"); GOTO(out_root, err = -EBADF); } @@ -246,9 +228,9 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov) ll_gns_add_timer(sbi); - /* making vm readahead 0 for 2.4.x. In the case of 2.6.x, backing dev - info assigned to inode mapping is used for determining maximal - readahead. */ + /* making vm readahead 0 for 2.4.x. In the case of 2.6.x, + backing dev info assigned to inode mapping is used for + determining maximal readahead. */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) /* bug 2805 - set VM readahead to zero */ vm_max_readahead = vm_min_readahead = 0; @@ -266,10 +248,10 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov) out_root: if (root) iput(root); -out_lov: - obd_disconnect(sbi->ll_lov_exp, 0); -out_lmv: - obd_disconnect(sbi->ll_lmv_exp, 0); +out_osc: + obd_disconnect(sbi->ll_osc_exp, 0); +out_mdc: + obd_disconnect(sbi->ll_mdc_exp, 0); out: lprocfs_unregister_mountpoint(sbi); RETURN(err); @@ -282,10 +264,11 @@ void lustre_common_put_super(struct super_block *sb) ENTRY; ll_gns_del_timer(sbi); + ll_close_thread_shutdown(sbi->ll_lcq); list_del(&sbi->ll_conn_chain); - obd_disconnect(sbi->ll_lov_exp, 0); + obd_disconnect(sbi->ll_osc_exp, 0); lprocfs_unregister_mountpoint(sbi); if (sbi->ll_proc_root) { @@ -293,7 +276,7 @@ void lustre_common_put_super(struct super_block *sb) sbi->ll_proc_root = NULL; } - obd_disconnect(sbi->ll_lmv_exp, 0); + obd_disconnect(sbi->ll_mdc_exp, 0); // We do this to get rid of orphaned dentries. That is not really trw. spin_lock(&dcache_lock); @@ -307,6 +290,7 @@ void lustre_common_put_super(struct super_block *sb) EXIT; } + char *ll_read_opt(const char *opt, char *data) { char *value; @@ -342,7 +326,7 @@ int ll_set_opt(const char *opt, char *data, int fl) RETURN(fl); } -void ll_options(char *options, char **lov, char **lmv, int *flags) +void ll_options(char *options, char **ost, char **mdc, int *flags) { char *this_char; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) @@ -363,9 +347,9 @@ void ll_options(char *options, char **lov, char **lmv, int *flags) while ((this_char = strsep (&opt_ptr, ",")) != NULL) { #endif CDEBUG(D_SUPER, "this_char %s\n", this_char); - if (!*lov && (*lov = ll_read_opt("osc", this_char))) + if (!*ost && (*ost = ll_read_opt("osc", this_char))) continue; - if (!*lmv && (*lmv = ll_read_opt("mdc", this_char))) + if (!*mdc && (*mdc = ll_read_opt("mdc", this_char))) continue; if (!(*flags & LL_SBI_NOLCK) && ((*flags) = (*flags) | @@ -385,14 +369,13 @@ void ll_lli_init(struct ll_inode_info *lli) spin_lock_init(&lli->lli_lock); INIT_LIST_HEAD(&lli->lli_pending_write_llaps); lli->lli_inode_magic = LLI_INODE_MAGIC; - memset(&lli->lli_id, 0, sizeof(lli->lli_id)); } int ll_fill_super(struct super_block *sb, void *data, int silent) { struct ll_sb_info *sbi; - char *lov = NULL; - char *lmv = NULL; + char *osc = NULL; + char *mdc = NULL; int err; ENTRY; @@ -403,27 +386,28 @@ int ll_fill_super(struct super_block *sb, void *data, int silent) RETURN(-ENOMEM); sbi->ll_flags |= LL_SBI_READAHEAD; - ll_options(data, &lov, &lmv, &sbi->ll_flags); + ll_options(data, &osc, &mdc, &sbi->ll_flags); - if (!lov) { + if (!osc) { CERROR("no osc\n"); GOTO(out, err = -EINVAL); } - if (!lmv) { + if (!mdc) { CERROR("no mdc\n"); GOTO(out, err = -EINVAL); } - err = lustre_common_fill_super(sb, lmv, lov); + err = lustre_common_fill_super(sb, mdc, osc); out: if (err) lustre_free_sbi(sb); - if (lmv) - OBD_FREE(lmv, strlen(lmv) + 1); - if (lov) - OBD_FREE(lov, strlen(lov) + 1); + if (mdc) + OBD_FREE(mdc, strlen(mdc) + 1); + if (osc) + OBD_FREE(osc, strlen(osc) + 1); + RETURN(err); } /* ll_read_super */ @@ -432,13 +416,13 @@ static int lustre_process_log(struct lustre_mount_data *lmd, char *profile, { struct lustre_cfg lcfg; struct portals_cfg pcfg; - char *peer = "MDS_PEER_UUID"; + char * peer = "MDS_PEER_UUID"; struct obd_device *obd; - struct lustre_handle lmv_conn = {0, }; + struct lustre_handle mdc_conn = {0, }; struct obd_export *exp; - char *name = "mdc_dev"; + char * name = "mdc_dev"; class_uuid_t uuid; - struct obd_uuid lmv_uuid; + struct obd_uuid mdc_uuid; struct llog_ctxt *ctxt; int rc = 0; int err; @@ -448,7 +432,7 @@ static int lustre_process_log(struct lustre_mount_data *lmd, char *profile, RETURN(-EINVAL); generate_random_uuid(uuid); - class_uuid_unparse(uuid, &lmv_uuid); + class_uuid_unparse(uuid, &mdc_uuid); if (lmd->lmd_local_nid) { PCFG_INIT(pcfg, NAL_CMD_REGISTER_MYNID); @@ -485,7 +469,7 @@ static int lustre_process_log(struct lustre_mount_data *lmd, char *profile, LCFG_INIT(lcfg, LCFG_ATTACH, name); lcfg.lcfg_inlbuf1 = "mdc"; lcfg.lcfg_inllen1 = strlen(lcfg.lcfg_inlbuf1) + 1; - lcfg.lcfg_inlbuf2 = lmv_uuid.uuid; + lcfg.lcfg_inlbuf2 = mdc_uuid.uuid; lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1; err = class_process_config(&lcfg); if (err < 0) @@ -511,13 +495,13 @@ static int lustre_process_log(struct lustre_mount_data *lmd, char *profile, if (err) GOTO(out_cleanup, err); - err = obd_connect(&lmv_conn, obd, &lmv_uuid, 0); + err = obd_connect(&mdc_conn, obd, &mdc_uuid, 0); if (err) { CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err); GOTO(out_cleanup, err); } - exp = class_conn2export(&lmv_conn); + exp = class_conn2export(&mdc_conn); ctxt = llog_get_context(&exp->exp_obd->obd_llogs,LLOG_CONFIG_REPL_CTXT); rc = class_config_process_llog(ctxt, profile, cfg); @@ -565,8 +549,9 @@ out: int lustre_fill_super(struct super_block *sb, void *data, int silent) { struct lustre_mount_data * lmd = data; - char *lov = NULL, *lmv = NULL; struct ll_sb_info *sbi; + char *osc = NULL; + char *mdc = NULL; int err; ENTRY; @@ -617,39 +602,39 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) CERROR("No profile found: %s\n", lmd->lmd_profile); GOTO(out_free, err = -EINVAL); } - if (lov) - OBD_FREE(lov, strlen(lov) + 1); - OBD_ALLOC(lov, strlen(lprof->lp_lov) + + if (osc) + OBD_FREE(osc, strlen(osc) + 1); + OBD_ALLOC(osc, strlen(lprof->lp_osc) + strlen(sbi->ll_instance) + 2); - sprintf(lov, "%s-%s", lprof->lp_lov, sbi->ll_instance); + sprintf(osc, "%s-%s", lprof->lp_osc, sbi->ll_instance); - if (lmv) - OBD_FREE(lmv, strlen(lmv) + 1); - OBD_ALLOC(lmv, strlen(lprof->lp_lmv) + + if (mdc) + OBD_FREE(mdc, strlen(mdc) + 1); + OBD_ALLOC(mdc, strlen(lprof->lp_mdc) + strlen(sbi->ll_instance) + 2); - sprintf(lmv, "%s-%s", lprof->lp_lmv, sbi->ll_instance); + sprintf(mdc, "%s-%s", lprof->lp_mdc, sbi->ll_instance); } - if (!lov) { + if (!osc) { CERROR("no osc\n"); GOTO(out_free, err = -EINVAL); } - if (!lmv) { + if (!mdc) { CERROR("no mdc\n"); GOTO(out_free, err = -EINVAL); } - err = lustre_common_fill_super(sb, lmv, lov); + err = lustre_common_fill_super(sb, mdc, osc); if (err) GOTO(out_free, err); out_dev: - if (lmv) - OBD_FREE(lmv, strlen(lmv) + 1); - if (lov) - OBD_FREE(lov, strlen(lov) + 1); + if (mdc) + OBD_FREE(mdc, strlen(mdc) + 1); + if (osc) + OBD_FREE(osc, strlen(osc) + 1); RETURN(err); @@ -719,7 +704,7 @@ void lustre_put_super(struct super_block *sb) ENTRY; CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb); - obd = class_exp2obd(sbi->ll_lmv_exp); + obd = class_exp2obd(sbi->ll_mdc_exp); if (obd) force_umount = obd->obd_no_recov; obd = NULL; @@ -763,7 +748,7 @@ void lustre_put_super(struct super_block *sb) int ll_process_config_update(struct ll_sb_info *sbi, int clean) { - struct obd_export *lmv_exp = sbi->ll_lmv_exp; + struct obd_export *mdc_exp = sbi->ll_mdc_exp; struct lustre_mount_data *lmd = sbi->ll_lmd; struct llog_ctxt *ctxt; struct config_llog_instance cfg; @@ -779,12 +764,12 @@ int ll_process_config_update(struct ll_sb_info *sbi, int clean) RETURN(0); } - rc = ldlm_cli_cancel_unused(lmv_exp->exp_obd->obd_namespace, NULL, + rc = ldlm_cli_cancel_unused(mdc_exp->exp_obd->obd_namespace, NULL, LDLM_FL_CONFIG_CHANGE, NULL); if (rc != 0) CWARN("ldlm_cli_cancel_unused(mdc): %d\n", rc); - rc = obd_cancel_unused(sbi->ll_lov_exp, NULL, LDLM_FL_CONFIG_CHANGE, + rc = obd_cancel_unused(sbi->ll_osc_exp, NULL, LDLM_FL_CONFIG_CHANGE, NULL); if (rc != 0) CWARN("obd_cancel_unused(lov): %d\n", rc); @@ -808,7 +793,7 @@ int ll_process_config_update(struct ll_sb_info *sbi, int clean) CWARN("Applying configuration log %s\n", name); - ctxt = llog_get_context(&lmv_exp->exp_obd->obd_llogs, + ctxt = llog_get_context(&mdc_exp->exp_obd->obd_llogs, LLOG_CONFIG_REPL_CTXT); rc = class_config_process_llog(ctxt, name, &cfg); if (rc == 0) @@ -819,11 +804,11 @@ int ll_process_config_update(struct ll_sb_info *sbi, int clean) struct lov_desc desc; int rc, valsize; valsize = sizeof(desc); - rc = obd_get_info(sbi->ll_lov_exp, strlen("lovdesc") + 1, + rc = obd_get_info(sbi->ll_osc_exp, strlen("lovdesc") + 1, "lovdesc", &valsize, &desc); - rc = obd_init_ea_size(lmv_exp, - obd_size_diskmd(sbi->ll_lov_exp, NULL), + rc = obd_init_ea_size(mdc_exp, + obd_size_diskmd(sbi->ll_osc_exp, NULL), (desc.ld_tgt_count * sizeof(struct llog_cookie))); } @@ -862,7 +847,7 @@ int null_if_equal(struct ldlm_lock *lock, void *data) void ll_clear_inode(struct inode *inode) { - struct lustre_id id; + struct ll_fid fid; struct ll_inode_info *lli = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); ENTRY; @@ -871,22 +856,22 @@ void ll_clear_inode(struct inode *inode) inode->i_generation, inode); lli->lli_inode_magic = LLI_INODE_DEAD; - ll_inode2id(&id, inode); - + ll_inode2fid(&fid, inode); clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags)); - md_change_cbdata(sbi->ll_lmv_exp, &id, null_if_equal, inode); + md_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode); if (lli->lli_smd) - obd_change_cbdata(sbi->ll_lov_exp, lli->lli_smd, + obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd, null_if_equal, inode); if (lli->lli_smd) { - obd_free_memmd(sbi->ll_lov_exp, &lli->lli_smd); + obd_free_memmd(sbi->ll_osc_exp, &lli->lli_smd); lli->lli_smd = NULL; } if (lli->lli_mea) { - obd_free_memmd(sbi->ll_lmv_exp, + /* FIXME: change cbdata for mea here */ + obd_free_memmd(sbi->ll_mdc_exp, (struct lov_stripe_md **) &lli->lli_mea); lli->lli_mea = NULL; } @@ -968,9 +953,9 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) * inode ourselves so we can call obdo_from_inode() always. */ if (ia_valid & (lsm ? ~(ATTR_SIZE | ATTR_FROM_OPEN | ATTR_RAW) : ~0)) { struct lustre_md md; - ll_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0); + ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0); - rc = md_setattr(sbi->ll_lmv_exp, &op_data, + rc = md_setattr(sbi->ll_mdc_exp, &op_data, attr, NULL, 0, NULL, 0, &request); if (rc) { ptlrpc_req_finished(request); @@ -979,8 +964,8 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) RETURN(rc); } - rc = mdc_req2lustre_md(sbi->ll_lmv_exp, request, 0, - sbi->ll_lov_exp, &md); + rc = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0, + sbi->ll_osc_exp, &md); if (rc) { ptlrpc_req_finished(request); RETURN(rc); @@ -1069,7 +1054,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP; obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME); - rc = obd_setattr(sbi->ll_lov_exp, &oa, lsm, NULL); + rc = obd_setattr(sbi->ll_osc_exp, &oa, lsm, NULL); if (rc) CERROR("obd_setattr fails: rc=%d\n", rc); } @@ -1090,7 +1075,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, int rc; ENTRY; - rc = obd_statfs(class_exp2obd(sbi->ll_lmv_exp), osfs, max_age); + rc = obd_statfs(class_exp2obd(sbi->ll_mdc_exp), osfs, max_age); if (rc) { CERROR("mdc_statfs fails: rc = %d\n", rc); RETURN(rc); @@ -1101,7 +1086,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n", osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files); - rc = obd_statfs(class_exp2obd(sbi->ll_lov_exp), &obd_osfs, max_age); + rc = obd_statfs(class_exp2obd(sbi->ll_osc_exp), &obd_osfs, max_age); if (rc) { CERROR("obd_statfs fails: rc = %d\n", rc); RETURN(rc); @@ -1164,10 +1149,9 @@ int ll_statfs(struct super_block *sb, struct kstatfs *sfs) void ll_update_inode(struct inode *inode, struct lustre_md *md) { - struct ll_sb_info *sbi = ll_s2sbi(inode->i_sb); struct ll_inode_info *lli = ll_i2info(inode); - struct lov_stripe_md *lsm = md->lsm; struct mds_body *body = md->body; + struct lov_stripe_md *lsm = md->lsm; struct mea *mea = md->mea; ENTRY; @@ -1222,26 +1206,13 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) } } if (lli->lli_mea != mea) - obd_free_memmd(ll_i2lmvexp(inode), - (struct lov_stripe_md **) &mea); + obd_free_memmd(ll_i2mdcexp(inode), + (struct lov_stripe_md **) &mea); + } - /* - * updating inode lustre id. We try optimize things a little bit here, - * thus do not do it all the time. - */ - if (body->valid & OBD_MD_FID) { - LASSERT(id_fid(&body->id1) != 0); - id_assign_fid(&lli->lli_id, &body->id1); - } - - if ((body->valid & OBD_MD_FLID) || (body->valid & OBD_MD_FLGENER)) - id_assign_stc(&lli->lli_id, &body->id1); - if (body->valid & OBD_MD_FLID) - inode->i_ino = id_ino(&body->id1); - if (body->valid & OBD_MD_FLGENER) - inode->i_generation = id_gen(&body->id1); + inode->i_ino = body->ino; if (body->valid & OBD_MD_FLATIME) LTIME_S(inode->i_atime) = body->atime; if (body->valid & OBD_MD_FLMTIME && @@ -1253,14 +1224,10 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) if (body->valid & OBD_MD_FLCTIME && body->ctime > LTIME_S(inode->i_ctime)) LTIME_S(inode->i_ctime) = body->ctime; - if (body->valid & OBD_MD_FLMODE) { - inode->i_mode = (inode->i_mode & S_IFMT) | - (body->mode & ~S_IFMT); - } - if (body->valid & OBD_MD_FLTYPE) { - inode->i_mode = (inode->i_mode & ~S_IFMT) | - (body->mode & S_IFMT); - } + if (body->valid & OBD_MD_FLMODE) + inode->i_mode = (inode->i_mode & S_IFMT)|(body->mode & ~S_IFMT); + if (body->valid & OBD_MD_FLTYPE) + inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT); if (body->valid & OBD_MD_FLUID) inode->i_uid = body->uid; if (body->valid & OBD_MD_FLGID) @@ -1269,6 +1236,8 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) inode->i_flags = body->flags; if (body->valid & OBD_MD_FLNLINK) inode->i_nlink = body->nlink; + if (body->valid & OBD_MD_FLGENER) + inode->i_generation = body->generation; if (body->valid & OBD_MD_FLRDEV) #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) inode->i_rdev = body->rdev; @@ -1282,12 +1251,12 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) if (body->valid & OBD_MD_FLSIZE) set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags); - + + lli->lli_mds = body->mds; #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - inode->i_dev = (kdev_t)id_group(&lli->lli_id); + inode->i_dev = (kdev_t) body->mds; #endif - LASSERT(!sbi->ll_lmv_desc.ld_tgt_count || - id_group(&lli->lli_id) < sbi->ll_lmv_desc.ld_tgt_count); + LASSERT(body->mds < 1000); } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) @@ -1373,13 +1342,13 @@ void ll_read_inode2(struct inode *inode, void *opaque) void ll_delete_inode(struct inode *inode) { int rc; - struct lustre_id id; + struct ll_fid fid; struct ll_sb_info *sbi = ll_i2sbi(inode); ENTRY; - ll_inode2id(&id, inode); + ll_inode2fid(&fid, inode); - rc = md_delete_object(sbi->ll_lmv_exp, &id); + rc = md_delete_object(sbi->ll_mdc_exp, &fid); if (rc) { CERROR("md_delete_object() failed, error %d.\n", rc); @@ -1399,12 +1368,12 @@ int ll_iocontrol(struct inode *inode, struct file *file, switch(cmd) { case EXT3_IOC_GETFLAGS: { - struct lustre_id id; + struct ll_fid fid; unsigned long valid = OBD_MD_FLFLAGS; struct mds_body *body; - ll_inode2id(&id, inode); - rc = md_getattr(sbi->ll_lmv_exp, &id, valid, 0, &req); + ll_inode2fid(&fid, inode); + rc = md_getattr(sbi->ll_mdc_exp, &fid, valid, 0, &req); if (rc) { CERROR("failure %d inode %lu\n", rc, inode->i_ino); RETURN(-abs(rc)); @@ -1436,13 +1405,13 @@ int ll_iocontrol(struct inode *inode, struct file *file, if (!oa) RETURN(-ENOMEM); - ll_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0); + ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0); memset(&attr, 0x0, sizeof(attr)); attr.ia_attr_flags = flags; attr.ia_valid |= ATTR_ATTR_FLAG; - rc = md_setattr(sbi->ll_lmv_exp, &op_data, + rc = md_setattr(sbi->ll_mdc_exp, &op_data, &attr, NULL, 0, NULL, 0, &req); if (rc) { ptlrpc_req_finished(req); @@ -1458,7 +1427,7 @@ int ll_iocontrol(struct inode *inode, struct file *file, oa->o_flags = flags; oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP; - rc = obd_setattr(sbi->ll_lov_exp, oa, lsm, NULL); + rc = obd_setattr(sbi->ll_osc_exp, oa, lsm, NULL); obdo_free(oa); if (rc) { if (rc != -EPERM && rc != -EACCES) @@ -1488,7 +1457,6 @@ int ll_iocontrol(struct inode *inode, struct file *file, RETURN(0); } -/* this is only called in the case of forced umount. */ void ll_umount_begin(struct super_block *sb) { struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -1499,31 +1467,30 @@ void ll_umount_begin(struct super_block *sb) CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb, sb->s_count, atomic_read(&sb->s_active)); - obd = class_exp2obd(sbi->ll_lmv_exp); + obd = class_exp2obd(sbi->ll_mdc_exp); if (obd == NULL) { CERROR("Invalid MDC connection handle "LPX64"\n", - sbi->ll_lmv_exp->exp_handle.h_cookie); + sbi->ll_mdc_exp->exp_handle.h_cookie); EXIT; return; } obd->obd_no_recov = 1; - obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_lmv_exp, - sizeof(ioc_data), &ioc_data, NULL); + obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_mdc_exp, sizeof ioc_data, + &ioc_data, NULL); - obd = class_exp2obd(sbi->ll_lov_exp); + obd = class_exp2obd(sbi->ll_osc_exp); if (obd == NULL) { CERROR("Invalid LOV connection handle "LPX64"\n", - sbi->ll_lov_exp->exp_handle.h_cookie); + sbi->ll_osc_exp->exp_handle.h_cookie); EXIT; return; } obd->obd_no_recov = 1; - obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_lov_exp, - sizeof(ioc_data), &ioc_data, NULL); + obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_osc_exp, sizeof ioc_data, + &ioc_data, NULL); - /* - * really, we'd like to wait until there are no requests outstanding, + /* Really, we'd like to wait until there are no requests outstanding, * and then continue. For now, we just invalidate the requests, * schedule, and hope. */ @@ -1532,14 +1499,14 @@ void ll_umount_begin(struct super_block *sb) EXIT; } -int ll_prep_inode(struct obd_export *lov_exp, struct obd_export *lmv_exp, +int ll_prep_inode(struct obd_export *osc_exp, struct obd_export *mdc_exp, struct inode **inode, struct ptlrpc_request *req, int offset, struct super_block *sb) { struct lustre_md md; int rc = 0; - rc = mdc_req2lustre_md(lmv_exp, req, offset, lov_exp, &md); + rc = mdc_req2lustre_md(mdc_exp, req, offset, osc_exp, &md); if (rc) RETURN(rc); @@ -1547,13 +1514,13 @@ int ll_prep_inode(struct obd_export *lov_exp, struct obd_export *lmv_exp, ll_update_inode(*inode, &md); } else { LASSERT(sb); - *inode = ll_iget(sb, id_ino(&md.body->id1), &md); + *inode = ll_iget(sb, md.body->ino, &md); if (*inode == NULL || is_bad_inode(*inode)) { /* free the lsm if we allocated one above */ if (md.lsm != NULL) - obd_free_memmd(lov_exp, &md.lsm); + obd_free_memmd(osc_exp, &md.lsm); if (md.mea != NULL) - obd_free_memmd(lmv_exp, + obd_free_memmd(mdc_exp, (struct lov_stripe_md**)&md.mea); rc = -ENOMEM; CERROR("new_inode -fatal: rc %d\n", rc); diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c index d052b2d..7615751 100644 --- a/lustre/llite/llite_nfs.c +++ b/lustre/llite/llite_nfs.c @@ -44,7 +44,7 @@ static struct inode * search_inode_for_lustre(struct super_block *sb, { struct ptlrpc_request *req = NULL; struct ll_sb_info *sbi = ll_s2sbi(sb); - struct lustre_id id; + struct ll_fid fid; unsigned long valid = 0; int eadatalen = 0, rc; struct inode *inode = NULL; @@ -54,20 +54,20 @@ static struct inode * search_inode_for_lustre(struct super_block *sb, if (inode) return inode; if (S_ISREG(mode)) { - eadatalen = obd_size_diskmd(sbi->ll_lov_exp, NULL); + eadatalen = obd_size_diskmd(sbi->ll_osc_exp, NULL); valid |= OBD_MD_FLEASIZE; } - id.li_stc.u.e3s.l3s_type = mode; - id.li_stc.u.e3s.l3s_ino = (__u64)ino; - id.li_stc.u.e3s.l3s_gen = generation; + fid.id = (__u64)ino; + fid.generation = generation; + fid.f_type = mode; - rc = md_getattr(sbi->ll_lmv_exp, &id, valid, eadatalen, &req); + rc = md_getattr(sbi->ll_mdc_exp, &fid, valid, eadatalen, &req); if (rc) { CERROR("failure %d inode %lu\n", rc, ino); return ERR_PTR(rc); } - rc = ll_prep_inode(sbi->ll_lov_exp, sbi->ll_lmv_exp, + rc = ll_prep_inode(sbi->ll_osc_exp, sbi->ll_mdc_exp, &inode, req, 0, sb); if (rc) { ptlrpc_req_finished(req); diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 2c26a80..6dd69d1 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -60,8 +60,7 @@ static int ll_test_inode(struct inode *inode, void *opaque) return 0; } - if (last_ino == id_ino(&md->body->id1) && - last_gen == id_gen(&md->body->id1) && + if (last_ino == md->body->ino && last_gen == md->body->generation && last_count < 500) { last_count++; } else { @@ -69,25 +68,26 @@ static int ll_test_inode(struct inode *inode, void *opaque) CDEBUG(D_VFSTRACE, "compared %u/%u %u times\n", last_ino, last_gen, last_count); last_count = 0; - last_ino = id_ino(&md->body->id1); - last_gen = id_gen(&md->body->id1); + last_ino = md->body->ino; + last_gen = md->body->generation; CDEBUG(D_VFSTRACE, - "comparing inode %p ino "DLID4" to body "DLID4"\n", - inode, OLID4(&ll_i2info(inode)->lli_id), - OLID4(&md->body->id1)); + "comparing inode %p ino %lu/%u/%u to body %u/%u/%u\n", + inode, inode->i_ino, inode->i_generation, + ll_i2info(inode)->lli_mds, + md->body->ino, md->body->generation, + md->body->mds); } #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) - if (inode->i_ino != id_ino(&md->body->id1)) + if (inode->i_ino != md->body->ino) return 0; #endif - if (inode->i_generation != id_gen(&md->body->id1)) + if (inode->i_generation != md->body->generation) return 0; - if (id_group(&ll_i2info(inode)->lli_id) != id_group(&md->body->id1)) + if (ll_i2info(inode)->lli_mds != md->body->mds) return 0; - - /* apply the attributes in 'opaque' to this inode. */ + /* Apply the attributes in 'opaque' to this inode */ ll_update_inode(inode, md); return 1; } @@ -103,9 +103,8 @@ int ll_unlock(__u32 mode, struct lustre_handle *lockh) RETURN(0); } -/* - * get an inode by inode number (already instantiated by the intent lookup). - * Returns inode or NULL. +/* Get an inode by inode number (already instantiated by the intent lookup). + * Returns inode or NULL */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) int ll_set_inode(struct inode *inode, void *opaque) @@ -163,7 +162,6 @@ int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, break; case LDLM_CB_CANCELING: { struct inode *inode = ll_inode_from_lock(lock); - struct ll_inode_info *li = ll_i2info(inode); __u64 bits = lock->l_policy_data.l_inodebits.bits; /* For lookup locks: Invalidate all dentries associated with @@ -176,11 +174,10 @@ int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, &(ll_i2info(inode)->lli_flags)); - if (lock->l_resource->lr_name.name[0] != id_fid(&li->lli_id) || - lock->l_resource->lr_name.name[1] != id_group(&li->lli_id)) { - LDLM_ERROR(lock, "data mismatch with object %lu/%lu", - (unsigned long)id_fid(&li->lli_id), - (unsigned long)id_group(&li->lli_id)); + if (lock->l_resource->lr_name.name[0] != inode->i_ino || + lock->l_resource->lr_name.name[1] != inode->i_generation) { + LDLM_ERROR(lock, "data mismatch with ino %lu/%u(%p)", + inode->i_ino, inode->i_generation, inode); } /* If lookup lock is cancelled, we just drop the dentry and @@ -214,9 +211,8 @@ int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, int ll_mdc_cancel_unused(struct lustre_handle *conn, struct inode *inode, int flags, void *opaque) { - struct ll_inode_info *li = ll_i2info(inode); struct ldlm_res_id res_id = - { .name = {id_fid(&li->lli_id), id_group(&li->lli_id)} }; + { .name = {inode->i_ino, inode->i_generation} }; struct obd_device *obddev = class_conn2obd(conn); ENTRY; @@ -286,7 +282,7 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, if (!it_disposition(it, DISP_LOOKUP_NEG)) { ENTRY; - rc = ll_prep_inode(sbi->ll_lov_exp, sbi->ll_lmv_exp, + rc = ll_prep_inode(sbi->ll_osc_exp, sbi->ll_mdc_exp, &inode, request, offset, dentry->d_sb); if (rc) RETURN(rc); @@ -294,7 +290,7 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n", inode, inode->i_ino, inode->i_generation); mdc_set_lock_data(NULL, &it->d.lustre.it_lock_handle, inode); - + /* If this is a stat, get the authoritative file size */ if (it->it_op == IT_GETATTR && S_ISREG(inode->i_mode) && ll_i2info(inode)->lli_smd != NULL) { @@ -321,18 +317,20 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, dentry->d_op = &ll_d_ops; ll_set_dd(dentry); - if (dentry == saved) + if (dentry == saved) { d_add(dentry, inode); + } RETURN(0); } + static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, - struct nameidata *nd, struct lookup_intent *it, - int flags) + struct nameidata *nd, + struct lookup_intent *it, int flags) { struct dentry *save = dentry, *retval; - struct lustre_id pid; + struct ll_fid pfid; struct it_cb_data icbd; struct ptlrpc_request *req = NULL; struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; @@ -356,9 +354,9 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, icbd.icbd_childp = &dentry; icbd.icbd_parent = parent; - ll_inode2id(&pid, parent); + ll_inode2fid(&pfid, parent); - rc = md_intent_lock(ll_i2lmvexp(parent), &pid, + rc = md_intent_lock(ll_i2mdcexp(parent), &pfid, dentry->d_name.name, dentry->d_name.len, NULL, 0, NULL, it, flags, &req, ll_mdc_blocking_ast); if (rc < 0) @@ -387,18 +385,18 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, ptlrpc_req_finished(req); if (dentry->d_inode) CDEBUG(D_INODE, "lookup 0x%p in %lu/%lu: %*s -> %lu/%lu\n", - dentry, - (unsigned long) parent->i_ino, - (unsigned long) parent->i_generation, - dentry->d_name.len, dentry->d_name.name, - (unsigned long) dentry->d_inode->i_ino, - (unsigned long) dentry->d_inode->i_generation); + dentry, + (unsigned long) parent->i_ino, + (unsigned long) parent->i_generation, + dentry->d_name.len, dentry->d_name.name, + (unsigned long) dentry->d_inode->i_ino, + (unsigned long) dentry->d_inode->i_generation); else CDEBUG(D_INODE, "lookup 0x%p in %lu/%lu: %*s -> ??\n", - dentry, - (unsigned long) parent->i_ino, - (unsigned long) parent->i_generation, - dentry->d_name.len, dentry->d_name.name); + dentry, + (unsigned long) parent->i_ino, + (unsigned long) parent->i_generation, + dentry->d_name.len, dentry->d_name.name); return retval; } @@ -433,7 +431,7 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, LASSERT(it && it->d.lustre.it_disposition); request = it->d.lustre.it_data; - rc = ll_prep_inode(sbi->ll_lov_exp, sbi->ll_lmv_exp, + rc = ll_prep_inode(sbi->ll_osc_exp, sbi->ll_mdc_exp, &inode, request, 1, dir->i_sb); if (rc) GOTO(out, inode = ERR_PTR(rc)); @@ -471,7 +469,7 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode, { struct inode *inode; struct ptlrpc_request *request = it->d.lustre.it_data; - struct obd_export *lmv_exp = ll_i2lmvexp(dir); + struct obd_export *mdc_exp = ll_i2mdcexp(dir); int rc = 0; ENTRY; @@ -483,11 +481,12 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode, if (rc) RETURN(rc); - mdc_store_inode_generation(lmv_exp, request, MDS_REQ_INTENT_REC_OFF, 1); + mdc_store_inode_generation(mdc_exp, request, MDS_REQ_INTENT_REC_OFF, 1); inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len, NULL, 0, mode, 0, it); - if (IS_ERR(inode)) + if (IS_ERR(inode)) { RETURN(PTR_ERR(inode)); + } d_instantiate(dentry, inode); RETURN(0); @@ -545,8 +544,8 @@ static int ll_mknod_raw(struct nameidata *nd, int mode, dev_t rdev) case S_IFBLK: case S_IFIFO: case S_IFSOCK: - ll_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); - err = md_create(sbi->ll_lmv_exp, &op_data, NULL, 0, mode, + ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); + err = md_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode, current->fsuid, current->fsgid, rdev, &request); if (err == 0) ll_update_times(request, 0, dir); @@ -589,15 +588,15 @@ static int ll_mknod(struct inode *dir, struct dentry *child, int mode, case S_IFBLK: case S_IFIFO: case S_IFSOCK: - ll_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); - err = md_create(sbi->ll_lmv_exp, &op_data, NULL, 0, mode, + ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); + err = md_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode, current->fsuid, current->fsgid, rdev, &request); if (err) GOTO(out_err, err); ll_update_times(request, 0, dir); - err = ll_prep_inode(sbi->ll_lov_exp, sbi->ll_lmv_exp, + err = ll_prep_inode(sbi->ll_osc_exp, sbi->ll_mdc_exp, &inode, request, 0, child->d_sb); if (err) GOTO(out_err, err); @@ -632,8 +631,8 @@ static int ll_symlink_raw(struct nameidata *nd, const char *tgt) if (dir->i_nlink >= EXT3_LINK_MAX) RETURN(err); - ll_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); - err = md_create(sbi->ll_lmv_exp, &op_data, + ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); + err = md_create(sbi->ll_mdc_exp, &op_data, tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO, current->fsuid, current->fsgid, 0, &request); if (err == 0) @@ -659,8 +658,8 @@ static int ll_link_raw(struct nameidata *srcnd, struct nameidata *tgtnd) src->i_ino, src->i_generation, src, dir->i_ino, dir->i_generation, dir, name); - ll_prepare_mdc_data(&op_data, src, dir, name, len, 0); - err = md_link(sbi->ll_lmv_exp, &op_data, &request); + ll_prepare_mdc_op_data(&op_data, src, dir, name, len, 0); + err = md_link(sbi->ll_mdc_exp, &op_data, &request); if (err == 0) ll_update_times(request, 0, dir); ptlrpc_req_finished(request); @@ -682,8 +681,8 @@ static int ll_mkdir_raw(struct nameidata *nd, int mode) name, dir->i_ino, dir->i_generation, dir); mode = (mode & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR; - ll_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); - err = md_create(sbi->ll_lmv_exp, &op_data, NULL, 0, mode, + ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); + err = md_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode, current->fsuid, current->fsgid, 0, &request); if (err == 0) ll_update_times(request, 0, dir); @@ -703,8 +702,8 @@ static int ll_rmdir_raw(struct nameidata *nd) CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%u(%p)\n", name, dir->i_ino, dir->i_generation, dir); - ll_prepare_mdc_data(&op_data, dir, NULL, name, len, S_IFDIR); - rc = md_unlink(ll_i2sbi(dir)->ll_lmv_exp, &op_data, &request); + ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, S_IFDIR); + rc = md_unlink(ll_i2sbi(dir)->ll_mdc_exp, &op_data, &request); if (rc == 0) ll_update_times(request, 0, dir); ptlrpc_req_finished(request); @@ -803,8 +802,8 @@ static int ll_unlink_raw(struct nameidata *nd) CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%u(%p)\n", name, dir->i_ino, dir->i_generation, dir); - ll_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); - rc = md_unlink(ll_i2sbi(dir)->ll_lmv_exp, &op_data, &request); + ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); + rc = md_unlink(ll_i2sbi(dir)->ll_mdc_exp, &op_data, &request); if (rc) GOTO(out, rc); ll_update_times(request, 0, dir); @@ -832,8 +831,8 @@ static int ll_rename_raw(struct nameidata *oldnd, struct nameidata *newnd) "tgt_dir=%lu/%u(%p)\n", oldname, src->i_ino, src->i_generation, src, newname, tgt->i_ino, tgt->i_generation, tgt); - ll_prepare_mdc_data(&op_data, src, tgt, NULL, 0, 0); - err = md_rename(sbi->ll_lmv_exp, &op_data, + ll_prepare_mdc_op_data(&op_data, src, tgt, NULL, 0, 0); + err = md_rename(sbi->ll_mdc_exp, &op_data, oldname, oldlen, newname, newlen, &request); if (!err) { ll_update_times(request, 0, src); diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 9a90d50..abda07f 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -314,11 +314,10 @@ void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa) valid_flags = OBD_MD_FLTYPE | OBD_MD_FLATIME; if (cmd == OBD_BRW_WRITE) { oa->o_valid |= OBD_MD_FLIFID | OBD_MD_FLEPOCH; - mdc_pack_id(obdo_id(oa), inode->i_ino, 0, inode->i_mode, - id_group(&ll_i2info(inode)->lli_id), - id_fid(&ll_i2info(inode)->lli_id)); - + mdc_pack_fid(obdo_fid(oa), inode->i_ino, 0, inode->i_mode); + obdo_fid(oa)->mds = ll_i2info(inode)->lli_mds; oa->o_easize = ll_i2info(inode)->lli_io_epoch; + valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME; } @@ -701,7 +700,7 @@ static int ll_page_matches(struct page *page, int fd_flags) page_extent.l_extent.end = page_extent.l_extent.start + PAGE_CACHE_SIZE - 1; flags = LDLM_FL_CBPENDING | LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK; - matches = obd_match(ll_i2sbi(inode)->ll_lov_exp, + matches = obd_match(ll_i2sbi(inode)->ll_osc_exp, ll_i2info(inode)->lli_smd, LDLM_EXTENT, &page_extent, LCK_PR | LCK_PW, &flags, inode, &match_lockh); diff --git a/lustre/llite/special.c b/lustre/llite/special.c index cd3a552..c932752 100644 --- a/lustre/llite/special.c +++ b/lustre/llite/special.c @@ -271,7 +271,7 @@ static int ll_special_release_internal(struct inode *inode, struct file *filp, } lprocfs_counter_incr(sbi->ll_stats, LPROC_LL_RELEASE); - err = ll_mdc_close(sbi->ll_lmv_exp, inode, filp); + err = ll_mdc_close(sbi->ll_mdc_exp, inode, filp); if (err && rc == 0) rc = err; @@ -310,7 +310,7 @@ static int ll_special_open(struct inode *inode, struct file *filp) err = ll_local_open(filp, it); if (rc != 0) { CERROR("error opening special file: rc %d\n", rc); - ll_mdc_close(ll_i2sbi(inode)->ll_lmv_exp, inode, filp); + ll_mdc_close(ll_i2sbi(inode)->ll_mdc_exp, inode, filp); } else if (err) { if (pfop && *pfop) { if ((*pfop)->release) diff --git a/lustre/llite/symlink.c b/lustre/llite/symlink.c index 9364ec8..5f4a74c 100644 --- a/lustre/llite/symlink.c +++ b/lustre/llite/symlink.c @@ -30,12 +30,11 @@ #include "llite_internal.h" static int ll_readlink_internal(struct inode *inode, - struct ptlrpc_request **request, - char **symname) + struct ptlrpc_request **request, char **symname) { struct ll_inode_info *lli = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); - struct lustre_id id; + struct ll_fid fid; struct mds_body *body; int rc, symlen = inode->i_size + 1; ENTRY; @@ -48,8 +47,8 @@ static int ll_readlink_internal(struct inode *inode, RETURN(0); } - ll_inode2id(&id, inode); - rc = md_getattr(sbi->ll_lmv_exp, &id, OBD_MD_LINKNAME, symlen, + ll_inode2fid(&fid, inode); + rc = md_getattr(sbi->ll_mdc_exp, &fid, OBD_MD_LINKNAME, symlen, request); if (rc) { if (rc != -ENOENT) diff --git a/lustre/lmv/lmv_intent.c b/lustre/lmv/lmv_intent.c index c1cb22a..baea244 100644 --- a/lustre/lmv/lmv_intent.c +++ b/lustre/lmv/lmv_intent.c @@ -56,9 +56,10 @@ static inline void lmv_drop_intent_lock(struct lookup_intent *it) it->d.lustre.it_lock_mode); } -int lmv_handle_remote_inode(struct obd_export *exp, void *lmm, - int lmmsize, struct lookup_intent *it, - int flags, struct ptlrpc_request **reqp, +int lmv_handle_remote_inode(struct obd_export *exp, + void *lmm, int lmmsize, + struct lookup_intent *it, int flags, + struct ptlrpc_request **reqp, ldlm_blocking_callback cb_blocking) { struct obd_device *obd = exp->exp_obd; @@ -71,20 +72,16 @@ int lmv_handle_remote_inode(struct obd_export *exp, void *lmm, LASSERT(body != NULL); if (body->valid & OBD_MD_MDS) { - /* - * oh, MDS reports that this is remote inode case i.e. we have - * to ask for real attrs on another MDS. - */ + /* oh, MDS reports that this is remote inode case + * i.e. we have to ask for real attrs on another MDS */ struct ptlrpc_request *req = NULL; + struct ll_fid nfid; struct lustre_handle plock; - struct lustre_id nid; int pmode; if (it->it_op == IT_LOOKUP) { - /* - * unfortunately, we have to lie to MDC/MDS to retrieve - * attributes llite needs. - */ + /* unfortunately, we have to lie to MDC/MDS to + * retrieve attributes llite needs */ it->it_op = IT_GETATTR; } @@ -92,25 +89,23 @@ int lmv_handle_remote_inode(struct obd_export *exp, void *lmm, pmode = it->d.lustre.it_lock_mode; if (pmode) { memcpy(&plock, &it->d.lustre.it_lock_handle, - sizeof(plock)); + sizeof(plock)); it->d.lustre.it_lock_mode = 0; } - nid = body->id1; + nfid = body->fid1; it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE; - rc = md_intent_lock(lmv->tgts[id_group(&nid)].ltd_exp, &nid, + rc = md_intent_lock(lmv->tgts[nfid.mds].ltd_exp, &nfid, NULL, 0, lmm, lmmsize, NULL, it, flags, &req, cb_blocking); - /* - * llite needs LOOKUP lock to track dentry revocation in order - * to maintain dcache consistency. Thus drop UPDATE lock here - * and put LOOKUP in request. - */ + /* llite needs LOOKUP lock to track dentry revocation in + * order to maintain dcache consistency. thus drop UPDATE + * lock here and put LOOKUP in request */ if (rc == 0) { lmv_drop_intent_lock(it); memcpy(&it->d.lustre.it_lock_handle, &plock, - sizeof(plock)); + sizeof(plock)); it->d.lustre.it_lock_mode = pmode; } else if (pmode) @@ -122,48 +117,48 @@ int lmv_handle_remote_inode(struct obd_export *exp, void *lmm, RETURN(rc); } -int lmv_intent_open(struct obd_export *exp, struct lustre_id *pid, - const char *name, int len, void *lmm, int lmmsize, - struct lustre_id *cid, struct lookup_intent *it, - int flags, struct ptlrpc_request **reqp, +int lmv_intent_open(struct obd_export *exp, + struct ll_fid *pfid, const char *name, int len, + void *lmm, int lmmsize, struct ll_fid *cfid, + struct lookup_intent *it, int flags, + struct ptlrpc_request **reqp, ldlm_blocking_callback cb_blocking) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct mds_body *body = NULL; - struct lustre_id rpid = *pid; + struct ll_fid rpfid = *pfid; struct lmv_obj *obj; struct mea *mea; int rc, mds, loop = 0; ENTRY; /* IT_OPEN is intended to open (and create, possible) an object. Parent - * (pid) may be splitted dir */ + * (pfid) may be splitted dir */ repeat: LASSERT(++loop <= 2); - mds = id_group(&rpid); - obj = lmv_grab_obj(obd, &rpid); + mds = rpfid.mds; + obj = lmv_grab_obj(obd, &rpfid); if (obj) { /* directory is already splitted, so we have to forward * request to the right MDS */ - mds = raw_name2idx(obj->hashtype, obj->objcount, - (char *)name, len); - - CDEBUG(D_OTHER, "forward to MDS #%u ("DLID4")\n", - mds, OLID4(&rpid)); - rpid = obj->objs[mds].id; + mds = raw_name2idx(obj->hashtype, obj->objcount, (char *)name, len); + CDEBUG(D_OTHER, "forward to MDS #%u (%lu/%lu/%lu)\n", mds, + (unsigned long) rpfid.mds, (unsigned long) rpfid.id, + (unsigned long) rpfid.generation); + rpfid = obj->objs[mds].fid; lmv_put_obj(obj); } - rc = md_intent_lock(lmv->tgts[id_group(&rpid)].ltd_exp, &rpid, name, - len, lmm, lmmsize, cid, it, flags, reqp, + rc = md_intent_lock(lmv->tgts[rpfid.mds].ltd_exp, &rpfid, name, + len, lmm, lmmsize, cfid, it, flags, reqp, cb_blocking); if (rc == -ERESTART) { - /* directory got splitted. time to update local object and - * repeat the request with proper MDS */ - LASSERT(lmv_id_equal(pid, &rpid)); - rc = lmv_get_mea_and_update_object(exp, &rpid); + /* directory got splitted. time to update local object + * and repeat the request with proper MDS */ + LASSERT(fid_equal(pfid, &rpfid)); + rc = lmv_get_mea_and_update_object(exp, &rpfid); if (rc == 0) { ptlrpc_req_finished(*reqp); goto repeat; @@ -178,8 +173,14 @@ repeat: flags, reqp, cb_blocking); if (rc != 0) { LASSERT(rc < 0); - CERROR("can't handle remote %s: dir "DLID4"("DLID4"):" - "%*s: %d\n", LL_IT2STR(it), OLID4(pid), OLID4(&rpid), + CERROR("can't handle remote %s: dir %lu/%lu/%lu(%lu/%lu/%lu):" + "%*s: %d\n", LL_IT2STR(it), + (unsigned long) pfid->mds, + (unsigned long) pfid->id, + (unsigned long) pfid->generation, + (unsigned long) rpfid.mds, + (unsigned long) rpfid.id, + (unsigned long) rpfid.generation, len, name, rc); RETURN(rc); } @@ -189,25 +190,27 @@ repeat: body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body)); LASSERT(body != NULL); - cid = &body->id1; - obj = lmv_grab_obj(obd, cid); - if (!obj && (mea = lmv_splitted_dir_body(*reqp, 1))) { + cfid = &body->fid1; + obj = lmv_grab_obj(obd, cfid); + if (!obj && (mea = body_of_splitted_dir(*reqp, 1))) { /* wow! this is splitted dir, we'd like to handle it */ - obj = lmv_create_obj(exp, &body->id1, mea); + obj = lmv_create_obj(exp, &body->fid1, mea); if (IS_ERR(obj)) RETURN(PTR_ERR(obj)); } if (obj) { /* this is splitted dir and we'd want to get attrs */ - CDEBUG(D_OTHER, "attrs from slaves for "DLID4"\n", - OLID4(cid)); - - rc = lmv_revalidate_slaves(exp, reqp, cid, it, 1, - cb_blocking); + CDEBUG(D_OTHER, "attrs from slaves for %lu/%lu/%lu\n", + (unsigned long)cfid->mds, (unsigned long)cfid->id, + (unsigned long)cfid->generation); + rc = lmv_revalidate_slaves(exp, reqp, cfid, + it, 1, cb_blocking); } else if (S_ISDIR(body->mode)) { - CDEBUG(D_OTHER, "object "DLID4" has not lmv obj?\n", - OLID4(cid)); + /*CWARN("hmmm, %lu/%lu/%lu has not lmv obj?!\n", + (unsigned long) cfid->mds, + (unsigned long) cfid->id, + (unsigned long) cfid->generation);*/ } if (obj) @@ -216,55 +219,59 @@ repeat: RETURN(rc); } -int lmv_intent_getattr(struct obd_export *exp, struct lustre_id *pid, - const char *name, int len, void *lmm, int lmmsize, - struct lustre_id *cid, struct lookup_intent *it, - int flags, struct ptlrpc_request **reqp, +int lmv_intent_getattr(struct obd_export *exp, + struct ll_fid *pfid, const char *name, int len, + void *lmm, int lmmsize, struct ll_fid *cfid, + struct lookup_intent *it, int flags, + struct ptlrpc_request **reqp, ldlm_blocking_callback cb_blocking) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct mds_body *body = NULL; - struct lustre_id rpid = *pid; + struct ll_fid rpfid = *pfid; struct lmv_obj *obj, *obj2; struct mea *mea; int rc = 0, mds; ENTRY; - if (cid) { + if (cfid) { /* caller wants to revalidate attrs of obj we have to revalidate * slaves if requested object is splitted directory */ - CDEBUG(D_OTHER, "revalidate attrs for "DLID4"\n", OLID4(cid)); - mds = id_group(cid); - obj = lmv_grab_obj(obd, cid); + CDEBUG(D_OTHER, "revalidate attrs for %lu/%lu/%lu\n", + (unsigned long)cfid->mds, (unsigned long)cfid->id, + (unsigned long)cfid->generation); + mds = cfid->mds; + obj = lmv_grab_obj(obd, cfid); if (obj) { /* in fact, we need not this with current intent_lock(), * but it may change some day */ - if (!lmv_id_equal(pid, cid)){ - rpid = obj->objs[mds].id; - mds = id_group(&rpid); + if (!fid_equal(pfid, cfid)){ + rpfid = obj->objs[mds].fid; + mds = rpfid.mds; } lmv_put_obj(obj); } } else { - CDEBUG(D_OTHER, "INTENT getattr for %*s on "DLID4"\n", - len, name, OLID4(pid)); - mds = id_group(pid); - obj = lmv_grab_obj(obd, pid); + CDEBUG(D_OTHER, "INTENT getattr for %*s on %lu/%lu/%lu\n", + len, name, (unsigned long)pfid->mds, (unsigned long)pfid->id, + (unsigned long)pfid->generation); + mds = pfid->mds; + obj = lmv_grab_obj(obd, pfid); if (obj && len) { /* directory is already splitted. calculate mds */ - mds = raw_name2idx(obj->hashtype, obj->objcount, - (char *) name, len); - rpid = obj->objs[mds].id; - mds = id_group(&rpid); + mds = raw_name2idx(obj->hashtype, obj->objcount, (char *) name, len); + rpfid = obj->objs[mds].fid; + mds = rpfid.mds; lmv_put_obj(obj); - CDEBUG(D_OTHER, "forward to MDS #%u (slave "DLID4")\n", - mds, OLID4(&rpid)); + CDEBUG(D_OTHER, "forward to MDS #%u (slave %lu/%lu/%lu)\n", + mds, (unsigned long)rpfid.mds, (unsigned long)rpfid.id, + (unsigned long)rpfid.generation); } } - rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &rpid, name, - len, lmm, lmmsize, cid, it, flags, reqp, + rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &rpfid, name, + len, lmm, lmmsize, cfid, it, flags, reqp, cb_blocking); if (rc < 0) RETURN(rc); @@ -277,13 +284,14 @@ int lmv_intent_getattr(struct obd_export *exp, struct lustre_id *pid, * be fine if we don't. this means that nobody should * use UPDATE lock to notify about object * removal */ CDEBUG(D_OTHER, - "revalidate slaves for "DLID4", rc %d\n", - OLID4(cid), rc); + "revalidate slaves for %lu/%lu/%lu, rc %d\n", + (unsigned long)cfid->mds, (unsigned long)cfid->id, + (unsigned long)cfid->generation, rc); - LASSERT(cid != 0); - rc = lmv_revalidate_slaves(exp, reqp, cid, it, rc, + LASSERT(cfid != 0); + rc = lmv_revalidate_slaves(exp, reqp, cfid, it, rc, cb_blocking); - RETURN(rc); + RETURN(rc); } if (*reqp == NULL) @@ -299,25 +307,26 @@ int lmv_intent_getattr(struct obd_export *exp, struct lustre_id *pid, body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body)); LASSERT(body != NULL); - cid = &body->id1; - obj2 = lmv_grab_obj(obd, cid); + cfid = &body->fid1; + obj2 = lmv_grab_obj(obd, cfid); - if (!obj2 && (mea = lmv_splitted_dir_body(*reqp, 1))) { + if (!obj2 && (mea = body_of_splitted_dir(*reqp, 1))) { /* wow! this is splitted dir, we'd like to handle it. */ body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body)); LASSERT(body != NULL); - obj2 = lmv_create_obj(exp, &body->id1, mea); + obj2 = lmv_create_obj(exp, &body->fid1, mea); if (IS_ERR(obj2)) RETURN(PTR_ERR(obj2)); } if (obj2) { /* this is splitted dir and we'd want to get attrs */ - CDEBUG(D_OTHER, "attrs from slaves for "DLID4", rc %d\n", - OLID4(cid), rc); + CDEBUG(D_OTHER, "attrs from slaves for %lu/%lu/%lu, rc %d\n", + (unsigned long)cfid->mds, (unsigned long)cfid->id, + (unsigned long)cfid->generation, rc); - rc = lmv_revalidate_slaves(exp, reqp, cid, it, 1, cb_blocking); + rc = lmv_revalidate_slaves(exp, reqp, cfid, it, 1, cb_blocking); lmv_put_obj(obj2); } RETURN(rc); @@ -327,6 +336,10 @@ void lmv_update_body_from_obj(struct mds_body *body, struct lmv_inode *obj) { /* update size */ body->size += obj->size; +/* body->atime = obj->atime; + body->ctime = obj->ctime; + body->mtime = obj->mtime; + body->nlink = obj->nlink;*/ } int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp) @@ -357,30 +370,34 @@ int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp) body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body)); LASSERT(body != NULL); - obj = lmv_grab_obj(obd, &body->id1); + obj = lmv_grab_obj(obd, &body->fid1); LASSERT(obj != NULL); - CDEBUG(D_OTHER, "lookup slaves for "DLID4"\n", - OLID4(&body->id1)); + CDEBUG(D_OTHER, "lookup slaves for %lu/%lu/%lu\n", + (unsigned long)body->fid1.mds, + (unsigned long)body->fid1.id, + (unsigned long)body->fid1.generation); lmv_lock_obj(obj); for (i = 0; i < obj->objcount; i++) { - struct lustre_id id = obj->objs[i].id; + struct ll_fid fid = obj->objs[i].fid; struct ptlrpc_request *req = NULL; struct lookup_intent it; - if (lmv_id_equal(&id, &obj->id)) + if (fid_equal(&fid, &obj->fid)) /* skip master obj */ continue; - CDEBUG(D_OTHER, "lookup slave "DLID4"\n", OLID4(&id)); + CDEBUG(D_OTHER, "lookup slave %lu/%lu/%lu\n", + (unsigned long)fid.mds, (unsigned long)fid.id, + (unsigned long)fid.generation); /* is obj valid? */ memset(&it, 0, sizeof(it)); it.it_op = IT_GETATTR; - rc = md_intent_lock(lmv->tgts[id_group(&id)].ltd_exp, &id, - NULL, 0, NULL, 0, &id, &it, 0, &req, + rc = md_intent_lock(lmv->tgts[fid.mds].ltd_exp, &fid, + NULL, 0, NULL, 0, &fid, &it, 0, &req, lmv_dirobj_blocking_ast); lockh = (struct lustre_handle *)&it.d.lustre.it_lock_handle; @@ -424,86 +441,86 @@ cleanup: RETURN(rc); } -int lmv_intent_lookup(struct obd_export *exp, struct lustre_id *pid, - const char *name, int len, void *lmm, int lmmsize, - struct lustre_id *cid, struct lookup_intent *it, - int flags, struct ptlrpc_request **reqp, +int lmv_intent_lookup(struct obd_export *exp, + struct ll_fid *pfid, const char *name, int len, + void *lmm, int lmmsize, struct ll_fid *cfid, + struct lookup_intent *it, int flags, + struct ptlrpc_request **reqp, ldlm_blocking_callback cb_blocking) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct mds_body *body = NULL; - struct lustre_id rpid = *pid; + struct ll_fid rpfid = *pfid; struct lmv_obj *obj; struct mea *mea; int rc, mds, loop = 0; ENTRY; - /* - * IT_LOOKUP is intended to produce name -> id resolving (let's call + /* IT_LOOKUP is intended to produce name -> fid resolving (let's call * this lookup below) or to confirm requested resolving is still valid - * (let's call this revalidation) cid != NULL specifies revalidation. - */ - - if (cid) { - /* - * this is revalidation: we have to check is LOOKUP lock still - * valid for given id. Very important part is that we have to - * choose right mds because namespace is per mds. - */ - rpid = *pid; - obj = lmv_grab_obj(obd, pid); + * (let's call this revalidation) cfid != NULL specifies revalidation */ + + if (cfid) { + /* this is revalidation: we have to check is LOOKUP lock still + * valid for given fid. very important part is that we have to + * choose right mds because namespace is per mds */ + rpfid = *pfid; + obj = lmv_grab_obj(obd, pfid); if (obj) { - mds = raw_name2idx(obj->hashtype, obj->objcount, - (char *)name, len); - rpid = obj->objs[mds].id; + mds = raw_name2idx(obj->hashtype, obj->objcount, + (char *) name, len); + rpfid = obj->objs[mds].fid; lmv_put_obj(obj); } - mds = id_group(&rpid); + mds = rpfid.mds; - CDEBUG(D_OTHER, "revalidate lookup for "DLID4" to %d MDS\n", - OLID4(cid), mds); + CDEBUG(D_OTHER, "revalidate lookup for %lu/%lu/%lu to %d MDS\n", + (unsigned long)cfid->mds, (unsigned long)cfid->id, + (unsigned long)cfid->generation, mds); } else { - mds = id_group(pid); + mds = pfid->mds; repeat: LASSERT(++loop <= 2); /* this is lookup. during lookup we have to update all the * attributes, because returned values will be put in struct * inode */ - obj = lmv_grab_obj(obd, pid); + obj = lmv_grab_obj(obd, pfid); if (obj) { if (len) { /* directory is already splitted. calculate mds */ mds = raw_name2idx(obj->hashtype, obj->objcount, (char *)name, len); - rpid = obj->objs[mds].id; - mds = id_group(&rpid); + rpfid = obj->objs[mds].fid; + mds = rpfid.mds; } lmv_put_obj(obj); } } - rc = md_intent_lock(lmv->tgts[mds].ltd_exp, pid, name, - len, lmm, lmmsize, cid, it, flags, reqp, + rc = md_intent_lock(lmv->tgts[mds].ltd_exp, pfid, name, + len, lmm, lmmsize, cfid, it, flags, reqp, cb_blocking); if (rc > 0) { - LASSERT(cid != 0); + LASSERT(cfid != 0); RETURN(rc); } if (rc > 0) { /* very interesting. it seems object is still valid but for some * reason llite calls lookup, not revalidate */ - CDEBUG(D_OTHER, "lookup for "DLID4" and data should be uptodate\n", - OLID4(&rpid)); + CDEBUG(D_OTHER, "lookup for %lu/%lu/%lu and data should be uptodate\n", + (unsigned long)rpfid.mds, (unsigned long)rpfid.id, + (unsigned long)rpfid.generation); LASSERT(*reqp == NULL); RETURN(rc); } if (rc == 0 && *reqp == NULL) { /* once again, we're asked for lookup, not revalidate */ - CDEBUG(D_OTHER, "lookup for "DLID4" and data should be uptodate\n", - OLID4(&rpid)); + CDEBUG(D_OTHER, "lookup for %lu/%lu/%lu and data should be uptodate\n", + (unsigned long)rpfid.mds, (unsigned long)rpfid.id, + (unsigned long)rpfid.generation); RETURN(rc); } @@ -514,7 +531,7 @@ repeat: CWARN("we haven't knew about directory splitting!\n"); LASSERT(obj == NULL); - obj = lmv_create_obj(exp, &rpid, NULL); + obj = lmv_create_obj(exp, &rpfid, NULL); if (IS_ERR(obj)) RETURN(PTR_ERR(obj)); lmv_put_obj(obj); @@ -529,14 +546,14 @@ repeat: rc = lmv_handle_remote_inode(exp, lmm, lmmsize, it, flags, reqp, cb_blocking); - if (rc == 0 && (mea = lmv_splitted_dir_body(*reqp, 1))) { + if (rc == 0 && (mea = body_of_splitted_dir(*reqp, 1))) { /* wow! this is splitted dir, we'd like to handle it */ body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body)); LASSERT(body != NULL); - obj = lmv_grab_obj(obd, &body->id1); + obj = lmv_grab_obj(obd, &body->fid1); if (!obj) { - obj = lmv_create_obj(exp, &body->id1, mea); + obj = lmv_create_obj(exp, &body->fid1, mea); if (IS_ERR(obj)) RETURN(PTR_ERR(obj)); } @@ -546,10 +563,11 @@ repeat: RETURN(rc); } -int lmv_intent_lock(struct obd_export *exp, struct lustre_id *pid, - const char *name, int len, void *lmm, int lmmsize, - struct lustre_id *cid, struct lookup_intent *it, - int flags, struct ptlrpc_request **reqp, +int lmv_intent_lock(struct obd_export *exp, + struct ll_fid *pfid, const char *name, int len, + void *lmm, int lmmsize, struct ll_fid *cfid, + struct lookup_intent *it, int flags, + struct ptlrpc_request **reqp, ldlm_blocking_callback cb_blocking) { struct obd_device *obd = exp->exp_obd; @@ -557,27 +575,27 @@ int lmv_intent_lock(struct obd_export *exp, struct lustre_id *pid, ENTRY; LASSERT(it); - LASSERT(pid); + LASSERT(pfid); - CDEBUG(D_OTHER, "INTENT LOCK '%s' for '%*s' on %lu/%lu -> %lu\n", - LL_IT2STR(it), len, name, (unsigned long)id_ino(pid), - (unsigned long)id_gen(pid), (unsigned long)id_group(pid)); + CDEBUG(D_OTHER, "INTENT LOCK '%s' for '%*s' on %lu/%lu -> %u\n", + LL_IT2STR(it), len, name, (unsigned long) pfid->id, + (unsigned long) pfid->generation, pfid->mds); rc = lmv_check_connect(obd); if (rc) RETURN(rc); if (it->it_op == IT_LOOKUP) - rc = lmv_intent_lookup(exp, pid, name, len, lmm, - lmmsize, cid, it, flags, reqp, + rc = lmv_intent_lookup(exp, pfid, name, len, lmm, + lmmsize, cfid, it, flags, reqp, cb_blocking); else if (it->it_op & IT_OPEN) - rc = lmv_intent_open(exp, pid, name, len, lmm, - lmmsize, cid, it, flags, reqp, + rc = lmv_intent_open(exp, pfid, name, len, lmm, + lmmsize, cfid, it, flags, reqp, cb_blocking); else if (it->it_op == IT_GETATTR || it->it_op == IT_CHDIR) - rc = lmv_intent_getattr(exp, pid, name, len, lmm, - lmmsize, cid, it, flags, reqp, + rc = lmv_intent_getattr(exp, pfid, name, len, lmm, + lmmsize, cfid, it, flags, reqp, cb_blocking); else LBUG(); @@ -585,7 +603,7 @@ int lmv_intent_lock(struct obd_export *exp, struct lustre_id *pid, } int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, - struct lustre_id *mid, struct lookup_intent *oit, + struct ll_fid *mfid, struct lookup_intent *oit, int master_valid, ldlm_blocking_callback cb_blocking) { struct obd_device *obd = exp->exp_obd; @@ -605,7 +623,7 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, * the fields. say, common fields (that are equal on all the subojects * need not to be update, another fields (i_size, for example) are * cached all the time */ - obj = lmv_grab_obj(obd, mid); + obj = lmv_grab_obj(obd, mfid); LASSERT(obj != NULL); master_lock_mode = 0; @@ -613,21 +631,22 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, lmv_lock_obj(obj); for (i = 0; i < obj->objcount; i++) { - struct lustre_id id = obj->objs[i].id; + struct ll_fid fid = obj->objs[i].fid; struct lustre_handle *lockh = NULL; struct ptlrpc_request *req = NULL; ldlm_blocking_callback cb; struct lookup_intent it; int master = 0; - CDEBUG(D_OTHER, "revalidate subobj "DLID4"\n", - OLID4(&id)); + CDEBUG(D_OTHER, "revalidate subobj %lu/%lu/%lu\n", + (unsigned long)fid.mds, (unsigned long)fid.id, + (unsigned long) fid.generation); memset(&it, 0, sizeof(it)); it.it_op = IT_GETATTR; cb = lmv_dirobj_blocking_ast; - if (lmv_id_equal(&id, &obj->id)) { + if (fid_equal(&fid, &obj->fid)) { if (master_valid) { /* lmv_intent_getattr() already checked * validness and took the lock */ @@ -649,9 +668,8 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, } /* is obj valid? */ - rc = md_intent_lock(lmv->tgts[id_group(&id)].ltd_exp, - &id, NULL, 0, NULL, 0, &id, &it, 0, - &req, cb); + rc = md_intent_lock(lmv->tgts[fid.mds].ltd_exp, &fid, + NULL, 0, NULL, 0, &fid, &it, 0, &req, cb); lockh = (struct lustre_handle *) &it.d.lustre.it_lock_handle; if (rc > 0 && req == NULL) { /* nice, this slave is valid */ @@ -680,8 +698,8 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, } if (*reqp == NULL) { - /* this is first reply, we'll use it to return updated - * data back to the caller */ + /* this is first reply, we'll use it to return + * updated data back to the caller */ LASSERT(req); ptlrpc_request_addref(req); *reqp = req; @@ -723,7 +741,7 @@ release_lock: * of revalidation. mreq == NULL means that caller has * no reply and the only attr we can return is size */ body->valid = OBD_MD_FLSIZE; -// body->mds = id_group(&obj->id); + body->mds = obj->fid.mds; } if (master_valid == 0) { memcpy(&oit->d.lustre.it_lock_handle, diff --git a/lustre/lmv/lmv_internal.h b/lustre/lmv/lmv_internal.h index dfd698a..ccceb95 100644 --- a/lustre/lmv/lmv_internal.h +++ b/lustre/lmv/lmv_internal.h @@ -6,10 +6,10 @@ #define MEA_SIZE_LMV(lmv) \ ((lmv)->desc.ld_tgt_count * \ - sizeof(struct lustre_id) + sizeof(struct mea)) + sizeof(struct ll_fid) + sizeof(struct mea)) struct lmv_inode { - struct lustre_id id; /* id of dirobj */ + struct ll_fid fid; /* fid of dirobj */ unsigned long size; /* slave size value */ int flags; }; @@ -21,7 +21,7 @@ struct lmv_obj { struct semaphore guard; int state; /* object state. */ atomic_t count; /* ref counter. */ - struct lustre_id id; /* master id of dir */ + struct ll_fid fid; /* master fid of dir */ void *update; /* bitmap of status (uptodate) */ __u32 hashtype; int objcount; /* number of slaves */ @@ -60,47 +60,48 @@ int lmv_check_connect(struct obd_device *obd); struct lmv_obj *lmv_get_obj(struct lmv_obj *obj); struct lmv_obj *lmv_grab_obj(struct obd_device *obd, - struct lustre_id *id); + struct ll_fid *fid); struct lmv_obj *lmv_alloc_obj(struct obd_device *obd, - struct lustre_id *id, + struct ll_fid *fid, struct mea *mea); struct lmv_obj *lmv_create_obj(struct obd_export *exp, - struct lustre_id *id, + struct ll_fid *fid, struct mea *mea); -int lmv_delete_obj(struct obd_export *exp, struct lustre_id *id); +int lmv_delete_obj(struct obd_export *exp, struct ll_fid *fid); -int lmv_intent_lock(struct obd_export *, struct lustre_id *, - const char *, int, void *, int, - struct lustre_id *, struct lookup_intent *, int, +int lmv_intent_lock(struct obd_export *, + struct ll_fid *, const char *, int, void *, int, + struct ll_fid *, struct lookup_intent *, int, struct ptlrpc_request **, ldlm_blocking_callback); -int lmv_intent_lookup(struct obd_export *, struct lustre_id *, - const char *, int, void *, int, - struct lustre_id *, struct lookup_intent *, int, +int lmv_intent_lookup(struct obd_export *, + struct ll_fid *, const char *, int, void *, int, + struct ll_fid *, struct lookup_intent *, int, struct ptlrpc_request **, ldlm_blocking_callback); -int lmv_intent_getattr(struct obd_export *, struct lustre_id *, - const char *, int, void *, int, - struct lustre_id *, struct lookup_intent *, int, +int lmv_intent_getattr(struct obd_export *, + struct ll_fid *, const char *, int, void *, int, + struct ll_fid *, struct lookup_intent *, int, struct ptlrpc_request **, ldlm_blocking_callback); -int lmv_intent_open(struct obd_export *, struct lustre_id *, const char *, - int, void *, int, struct lustre_id *, struct lookup_intent *, - int, struct ptlrpc_request **, ldlm_blocking_callback); +int lmv_intent_open(struct obd_export *, + struct ll_fid *, const char *, int, void *, int, + struct ll_fid *, struct lookup_intent *, int, + struct ptlrpc_request **, ldlm_blocking_callback); int lmv_revalidate_slaves(struct obd_export *, struct ptlrpc_request **, - struct lustre_id *, struct lookup_intent *, int, + struct ll_fid *, struct lookup_intent *, int, ldlm_blocking_callback cb_blocking); -int lmv_get_mea_and_update_object(struct obd_export *, struct lustre_id *); +int lmv_get_mea_and_update_object(struct obd_export *, struct ll_fid *); int lmv_dirobj_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *, void *, int); static inline struct mea * -lmv_splitted_dir_body(struct ptlrpc_request *req, int offset) +body_of_splitted_dir(struct ptlrpc_request *req, int offset) { struct mds_body *body; struct mea *mea; @@ -112,8 +113,8 @@ lmv_splitted_dir_body(struct ptlrpc_request *req, int offset) if (!body || !S_ISDIR(body->mode) || !body->eadatasize) return NULL; - mea = lustre_msg_buf(req->rq_repmsg, offset + 1, - body->eadatasize); + mea = lustre_msg_buf(req->rq_repmsg, + offset + 1, body->eadatasize); LASSERT(mea); if (mea->mea_count == 0) @@ -122,18 +123,15 @@ lmv_splitted_dir_body(struct ptlrpc_request *req, int offset) return mea; } -/* this checks if passed ids are eaqual. We check here only group (that is mds - * number) and fid number as store cookie is not known outside of its MDS - * anymore and should not be used. */ static inline int -lmv_id_equal(struct lustre_id *id1, struct lustre_id *id2) +fid_equal(struct ll_fid *fid1, struct ll_fid *fid2) { - if (id1->li_fid.lf_group != id2->li_fid.lf_group) + if (fid1->mds != fid2->mds) return 0; - - if (id1->li_fid.lf_id != id2->li_fid.lf_id) + if (fid1->id != fid2->id) + return 0; + if (fid1->generation != fid2->generation) return 0; - return 1; } diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 86aad39..286b031 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -49,17 +49,6 @@ #include #include "lmv_internal.h" -static void lmv_activate_target(struct lmv_obd *lmv, - struct lmv_tgt_desc *tgt, - int activate) -{ - if (tgt->active == activate) - return; - - tgt->active = activate; - lmv->desc.ld_active_tgt_count += (activate ? 1 : -1); -} - /* Error codes: * * -EINVAL : UUID can't be found in the LMV's target list @@ -84,17 +73,16 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, CDEBUG(D_INFO, "lmv idx %d is %s conn "LPX64"\n", i, tgt->uuid.uuid, tgt->ltd_exp->exp_handle.h_cookie); - if (strncmp(uuid->uuid, tgt->uuid.uuid, sizeof uuid->uuid) == 0) break; } if (i == lmv->desc.ld_tgt_count) - GOTO(out_lmv_lock, rc = -EINVAL); + GOTO(out, rc = -EINVAL); obd = class_exp2obd(tgt->ltd_exp); if (obd == NULL) - GOTO(out_lmv_lock, rc = -ENOTCONN); + GOTO(out, rc = -ENOTCONN); CDEBUG(D_INFO, "Found OBD %s=%s device %d (%p) type %s at LMV idx %d\n", obd->obd_name, obd->obd_uuid.uuid, obd->obd_minor, obd, @@ -104,17 +92,19 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, if (tgt->active == activate) { CDEBUG(D_INFO, "OBD %p already %sactive!\n", obd, activate ? "" : "in"); - GOTO(out_lmv_lock, rc); + GOTO(out, rc); } - CDEBUG(D_INFO, "Marking OBD %p %sactive\n", - obd, activate ? "" : "in"); + CDEBUG(D_INFO, "Marking OBD %p %sactive\n", obd, activate ? "" : "in"); - lmv_activate_target(lmv, tgt, activate); + tgt->active = activate; + if (activate) + lmv->desc.ld_active_tgt_count++; + else + lmv->desc.ld_active_tgt_count--; EXIT; - - out_lmv_lock: + out: spin_unlock(&lmv->lmv_lock); return rc; } @@ -133,8 +123,8 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, } uuid = &watched->u.cli.cl_import->imp_target_uuid; - /* Set MDC as active before notifying the observer, so the observer can - * use the MDC normally. + /* Set MDC as active before notifying the observer, so the + * observer can use the MDC normally. */ rc = lmv_set_mdc_active(&obd->u.lmv, uuid, active); if (rc) { @@ -178,8 +168,9 @@ int lmv_detach(struct obd_device *dev) return lprocfs_obd_detach(dev); } -/* this is fake connect function. Its purpose is to initialize lmv and say - * caller that everything is okay. Real connection will be performed later. */ +/* This is fake connect function. Its purpose is to initialize lmv and + * say caller that everything is okay. Real connection will be performed + * later. */ static int lmv_connect(struct lustre_handle *conn, struct obd_device *obd, struct obd_uuid *cluuid, unsigned long connect_flags) { @@ -196,8 +187,7 @@ static int lmv_connect(struct lustre_handle *conn, struct obd_device *obd, } exp = class_conn2export(conn); - - /* we don't want to actually do the underlying connections more than + /* We don't want to actually do the underlying connections more than * once, so keep track. */ lmv->refcount++; if (lmv->refcount > 1) { @@ -205,11 +195,11 @@ static int lmv_connect(struct lustre_handle *conn, struct obd_device *obd, RETURN(0); } - lmv->exp = exp; - lmv->connected = 0; lmv->cluuid = *cluuid; - sema_init(&lmv->init_sem, 1); lmv->connect_flags = connect_flags; + lmv->connected = 0; + lmv->exp = exp; + sema_init(&lmv->init_sem, 1); lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry, NULL, NULL); @@ -239,29 +229,25 @@ void lmv_set_timeouts(struct obd_device *obd) for (i = 0, tgts = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgts++) { if (tgts->ltd_exp == NULL) continue; - obd_set_info(tgts->ltd_exp, strlen("inter_mds"), "inter_mds", 0, NULL); } } +/* Performs a check if passed obd is connected. If no - connect it. */ #define MAX_STRING_SIZE 128 - -/* performs a check if passed obd is connected. If no - connect it. */ int lmv_check_connect(struct obd_device *obd) { -#ifdef __KERNEL__ - struct proc_dir_entry *lmv_proc_dir; -#endif struct lmv_obd *lmv = &obd->u.lmv; - struct lmv_tgt_desc *tgts; struct obd_uuid *cluuid; + struct lmv_tgt_desc *tgts; + struct proc_dir_entry *lmv_proc_dir; struct obd_export *exp; int rc, rc2, i; if (lmv->connected) return 0; - + down(&lmv->init_sem); if (lmv->connected) { up(&lmv->init_sem); @@ -276,8 +262,8 @@ int lmv_check_connect(struct obd_device *obd) for (i = 0, tgts = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgts++) { struct obd_device *tgt_obd; + struct obd_uuid lmv_osc_uuid = { "LMV_OSC_UUID" }; struct lustre_handle conn = {0, }; - struct obd_uuid lmv_mdc_uuid = { "LMV_MDC_UUID" }; LASSERT(tgts != NULL); @@ -305,8 +291,8 @@ int lmv_check_connect(struct obd_device *obd) CERROR("Target %s not set up\n", tgts->uuid.uuid); GOTO(out_disc, rc = -EINVAL); } - - rc = obd_connect(&conn, tgt_obd, &lmv_mdc_uuid, + + rc = obd_connect(&conn, tgt_obd, &lmv_osc_uuid, lmv->connect_flags); if (rc) { CERROR("Target %s connect error %d\n", @@ -333,7 +319,6 @@ int lmv_check_connect(struct obd_device *obd) tgt_obd->obd_name, tgt_obd->obd_uuid.uuid, atomic_read(&obd->obd_refcount)); -#ifdef __KERNEL__ lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds"); if (lmv_proc_dir) { struct obd_device *mdc_obd = class_conn2obd(&conn); @@ -358,7 +343,6 @@ int lmv_check_connect(struct obd_device *obd) lmv_proc_dir = NULL; } } -#endif } lmv_set_timeouts(obd); @@ -377,7 +361,7 @@ int lmv_check_connect(struct obd_device *obd) uuid = tgts->uuid; rc2 = obd_disconnect(tgts->ltd_exp, 0); if (rc2) - CERROR("error: LMV target %s disconnect on MDC idx %d: " + CERROR("error: LMV target %s disconnect on MDT idx %d: " "error %d\n", uuid.uuid, i, rc2); } class_disconnect(exp, 0); @@ -389,10 +373,7 @@ static int lmv_disconnect(struct obd_export *exp, int flags) { struct obd_device *obd = class_exp2obd(exp); struct lmv_obd *lmv = &obd->u.lmv; - -#ifdef __KERNEL__ struct proc_dir_entry *lmv_proc_dir; -#endif int rc, i; ENTRY; @@ -404,9 +385,7 @@ static int lmv_disconnect(struct obd_export *exp, int flags) if (lmv->refcount != 0) goto out_local; -#ifdef __KERNEL__ lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds"); -#endif for (i = 0; i < lmv->desc.ld_tgt_count; i++) { struct obd_device *mdc_obd; @@ -415,8 +394,6 @@ static int lmv_disconnect(struct obd_export *exp, int flags) continue; mdc_obd = class_exp2obd(lmv->tgts[i].ltd_exp); - -#ifdef __KERNEL__ if (lmv_proc_dir) { struct proc_dir_entry *mdc_symlink; @@ -429,8 +406,13 @@ static int lmv_disconnect(struct obd_export *exp, int flags) mdc_obd->obd_name); } } -#endif if (obd->obd_no_recov) { + /* Pass it on to our clients. + * XXX This should be an argument to disconnect, + * XXX not a back-door flag on the OBD. Ah well. + */ + struct obd_device *mdc_obd; + mdc_obd = class_exp2obd(lmv->tgts[i].ltd_exp); if (mdc_obd) mdc_obd->obd_no_recov = 1; } @@ -439,6 +421,7 @@ static int lmv_disconnect(struct obd_export *exp, int flags) lmv->tgts[i].ltd_exp->exp_obd->obd_uuid.uuid); obd_register_observer(lmv->tgts[i].ltd_exp->exp_obd, NULL); + rc = obd_disconnect(lmv->tgts[i].ltd_exp, flags); if (rc) { if (lmv->tgts[i].active) { @@ -447,19 +430,20 @@ static int lmv_disconnect(struct obd_export *exp, int flags) } rc = 0; } - - lmv_activate_target(lmv, &lmv->tgts[i], 0); + if (lmv->tgts[i].active) { + lmv->desc.ld_active_tgt_count--; + lmv->tgts[i].active = 0; + } lmv->tgts[i].ltd_exp = NULL; } -#ifdef __KERNEL__ if (lmv_proc_dir) { lprocfs_remove(lmv_proc_dir); } else { CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n", obd->obd_type->typ_name, obd->obd_name); } -#endif + out_local: /* this is the case when no real connection is established by @@ -487,8 +471,10 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, for (i = 0; i < lmv->desc.ld_tgt_count; i++) { int err; - if (lmv->tgts[i].ltd_exp == NULL) + if (lmv->tgts[i].ltd_exp == NULL) { + CWARN("%s: NULL export for %d\n", obddev->obd_name, i); continue; + } err = obd_iocontrol(cmd, lmv->tgts[i].ltd_exp, len, karg, uarg); if (err) { @@ -543,8 +529,8 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf) RETURN(-EINVAL); } - lmv->tgts_size = sizeof(struct lmv_tgt_desc) * desc->ld_tgt_count; - OBD_ALLOC(lmv->tgts, lmv->tgts_size); + lmv->bufsize = sizeof(struct lmv_tgt_desc) * desc->ld_tgt_count; + OBD_ALLOC(lmv->tgts, lmv->bufsize); if (lmv->tgts == NULL) { CERROR("Out of memory\n"); RETURN(-ENOMEM); @@ -558,14 +544,14 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf) lmv->max_cookiesize = 0; - lmv->max_easize = sizeof(struct lustre_id) * + lmv->max_easize = sizeof(struct ll_fid) * desc->ld_tgt_count + sizeof(struct mea); rc = lmv_setup_mgr(obd); if (rc) { CERROR("Can't setup LMV object manager, " "error %d.\n", rc); - OBD_FREE(lmv->tgts, lmv->tgts_size); + OBD_FREE(lmv->tgts, lmv->bufsize); } tgt_obd = class_find_client_obd(&lmv->tgts->uuid, LUSTRE_MDC_NAME, @@ -578,17 +564,6 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf) RETURN(rc); } -static int lmv_cleanup(struct obd_device *obd, int flags) -{ - struct lmv_obd *lmv = &obd->u.lmv; - ENTRY; - - lmv_cleanup_mgr(obd); - OBD_FREE(lmv->tgts, lmv->tgts_size); - - RETURN(0); -} - static int lmv_statfs(struct obd_device *obd, struct obd_statfs *osfs, unsigned long max_age) { @@ -625,30 +600,36 @@ static int lmv_statfs(struct obd_device *obd, struct obd_statfs *osfs, RETURN(rc); } -static int lmv_getstatus(struct obd_export *exp, struct lustre_id *id) +static int lmv_cleanup(struct obd_device *obd, int flags) +{ + struct lmv_obd *lmv = &obd->u.lmv; + ENTRY; + lmv_cleanup_mgr(obd); + OBD_FREE(lmv->tgts, lmv->bufsize); + RETURN(0); +} + +static int lmv_getstatus(struct obd_export *exp, struct ll_fid *fid) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; int rc; ENTRY; - rc = lmv_check_connect(obd); if (rc) RETURN(rc); - - rc = md_getstatus(lmv->tgts[0].ltd_exp, id); - id_group(id) = 0; - + rc = md_getstatus(lmv->tgts[0].ltd_exp, fid); + fid->mds = 0; RETURN(rc); } -static int lmv_getattr(struct obd_export *exp, struct lustre_id *id, +static int lmv_getattr(struct obd_export *exp, struct ll_fid *fid, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - int rc, i = id_group(id); + int rc, i = fid->mds; struct lmv_obj *obj; ENTRY; @@ -658,15 +639,16 @@ static int lmv_getattr(struct obd_export *exp, struct lustre_id *id, LASSERT(i < lmv->desc.ld_tgt_count); - rc = md_getattr(lmv->tgts[i].ltd_exp, id, valid, + rc = md_getattr(lmv->tgts[i].ltd_exp, fid, valid, ea_size, request); if (rc) RETURN(rc); - obj = lmv_grab_obj(obd, id); + obj = lmv_grab_obj(obd, fid); - CDEBUG(D_OTHER, "GETATTR for "DLID4" %s\n", - OLID4(id), obj ? "(splitted)" : ""); + CDEBUG(D_OTHER, "GETATTR for %lu/%lu/%lu %s\n", + (unsigned long)fid->mds, (unsigned long)fid->id, + (unsigned long)fid->generation, obj ? "(splitted)" : ""); /* if object is splitted, then we loop over all the slaves and gather * size attribute. In ideal world we would have to gather also mds field @@ -696,7 +678,7 @@ static int lmv_getattr(struct obd_export *exp, struct lustre_id *id, } /* skip master obj. */ - if (lmv_id_equal(&obj->id, &obj->objs[i].id)) + if (fid_equal(&obj->fid, &obj->objs[i].fid)) continue; body->size += obj->objs[i].size; @@ -709,10 +691,8 @@ static int lmv_getattr(struct obd_export *exp, struct lustre_id *id, RETURN(rc); } -static int lmv_change_cbdata(struct obd_export *exp, - struct lustre_id *id, - ldlm_iterator_t it, - void *data) +static int lmv_change_cbdata(struct obd_export *exp, struct ll_fid *fid, + ldlm_iterator_t it, void *data) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -723,19 +703,19 @@ static int lmv_change_cbdata(struct obd_export *exp, if (rc) RETURN(rc); - CDEBUG(D_OTHER, "CBDATA for "DLID4"\n", OLID4(id)); - LASSERT(id_group(id) < lmv->desc.ld_tgt_count); + CDEBUG(D_OTHER, "CBDATA for %lu/%lu/%lu\n", (unsigned long)fid->mds, + (unsigned long)fid->id, (unsigned long)fid->generation); + + LASSERT(fid->mds < lmv->desc.ld_tgt_count); - rc = md_change_cbdata(lmv->tgts[id_group(id)].ltd_exp, - id, it, data); + rc = md_change_cbdata(lmv->tgts[fid->mds].ltd_exp, + fid, it, data); RETURN(rc); } -static int lmv_change_cbdata_name(struct obd_export *exp, - struct lustre_id *pid, - char *name, int len, - struct lustre_id *cid, +static int lmv_change_cbdata_name(struct obd_export *exp, struct ll_fid *pfid, + char *name, int len, struct ll_fid *cfid, ldlm_iterator_t it, void *data) { struct obd_device *obd = exp->exp_obd; @@ -748,39 +728,41 @@ static int lmv_change_cbdata_name(struct obd_export *exp, if (rc) RETURN(rc); - LASSERT(id_group(pid) < lmv->desc.ld_tgt_count); - LASSERT(id_group(cid) < lmv->desc.ld_tgt_count); + LASSERT(pfid->mds < lmv->desc.ld_tgt_count); + LASSERT(cfid->mds < lmv->desc.ld_tgt_count); - CDEBUG(D_OTHER, "CBDATA for "DLID4":%*s -> "DLID4"\n", - OLID4(pid), len, name, OLID4(cid)); + CDEBUG(D_OTHER, "CBDATA for %lu/%lu/%lu:%*s -> %lu/%lu/%lu\n", + (unsigned long)pfid->mds, (unsigned long)pfid->id, + (unsigned long)pfid->generation, len, name, + (unsigned long)cfid->mds, (unsigned long)cfid->id, + (unsigned long)cfid->generation); /* this is default mds for directory name belongs to. */ - mds = id_group(pid); - obj = lmv_grab_obj(obd, pid); + mds = pfid->mds; + obj = lmv_grab_obj(obd, pfid); if (obj) { /* directory is splitted. look for right mds for this name. */ mds = raw_name2idx(obj->hashtype, obj->objcount, name, len); - mds = id_group(&obj->objs[mds].id); + mds = obj->objs[mds].fid.mds; lmv_put_obj(obj); } - rc = md_change_cbdata(lmv->tgts[mds].ltd_exp, cid, it, data); + rc = md_change_cbdata(lmv->tgts[mds].ltd_exp, cfid, it, data); RETURN(rc); } -static int lmv_valid_attrs(struct obd_export *exp, struct lustre_id *id) +static int lmv_valid_attrs(struct obd_export *exp, struct ll_fid *fid) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; int rc = 0; ENTRY; - rc = lmv_check_connect(obd); if (rc) RETURN(rc); - - CDEBUG(D_OTHER, "validate "DLID4"\n", OLID4(id)); - LASSERT(id_group(id) < lmv->desc.ld_tgt_count); - rc = md_valid_attrs(lmv->tgts[id_group(id)].ltd_exp, id); + CDEBUG(D_OTHER, "validate %lu/%lu/%lu\n", (unsigned long) fid->mds, + (unsigned long) fid->id, (unsigned long) fid->generation); + LASSERT(fid->mds < lmv->desc.ld_tgt_count); + rc = md_valid_attrs(lmv->tgts[fid->mds].ltd_exp, fid); RETURN(rc); } @@ -796,14 +778,13 @@ int lmv_close(struct obd_export *exp, struct obdo *obdo, if (rc) RETURN(rc); LASSERT(i < lmv->desc.ld_tgt_count); - CDEBUG(D_OTHER, "CLOSE %lu/%lu/%lu\n", (unsigned long)obdo->o_mds, - (unsigned long)obdo->o_id, (unsigned long)obdo->o_generation); + CDEBUG(D_OTHER, "CLOSE %lu/%lu/%lu\n", (unsigned long) obdo->o_mds, + (unsigned long) obdo->o_id, (unsigned long) obdo->o_generation); rc = md_close(lmv->tgts[i].ltd_exp, obdo, och, request); RETURN(rc); } -int lmv_get_mea_and_update_object(struct obd_export *exp, - struct lustre_id *id) +int lmv_get_mea_and_update_object(struct obd_export *exp, struct ll_fid *fid) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -818,9 +799,9 @@ int lmv_get_mea_and_update_object(struct obd_export *exp, valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA; - /* time to update mea of parent id */ - rc = md_getattr(lmv->tgts[id_group(id)].ltd_exp, - id, valid, mealen, &req); + /* time to update mea of parent fid */ + rc = md_getattr(lmv->tgts[fid->mds].ltd_exp, fid, + valid, mealen, &req); if (rc) { CERROR("md_getattr() failed, error %d\n", rc); GOTO(cleanup, rc); @@ -835,7 +816,7 @@ int lmv_get_mea_and_update_object(struct obd_export *exp, if (md.mea == NULL) GOTO(cleanup, rc = -ENODATA); - obj = lmv_create_obj(exp, id, md.mea); + obj = lmv_create_obj(exp, fid, md.mea); if (IS_ERR(obj)) rc = PTR_ERR(obj); @@ -867,19 +848,21 @@ int lmv_create(struct obd_export *exp, struct mdc_op_data *op_data, RETURN(-EIO); repeat: LASSERT(++loop <= 2); - obj = lmv_grab_obj(obd, &op_data->id1); + obj = lmv_grab_obj(obd, &op_data->fid1); if (obj) { - mds = raw_name2idx(obj->hashtype, obj->objcount, - op_data->name, op_data->namelen); - op_data->id1 = obj->objs[mds].id; + mds = raw_name2idx(obj->hashtype, obj->objcount, op_data->name, + op_data->namelen); + op_data->fid1 = obj->objs[mds].fid; lmv_put_obj(obj); } - CDEBUG(D_OTHER, "CREATE '%*s' on "DLID4"\n", op_data->namelen, - op_data->name, OLID4(&op_data->id1)); + CDEBUG(D_OTHER, "CREATE '%*s' on %lu/%lu/%lu\n", op_data->namelen, + op_data->name, (unsigned long)op_data->fid1.mds, + (unsigned long)op_data->fid1.id, + (unsigned long)op_data->fid1.generation); - rc = md_create(lmv->tgts[id_group(&op_data->id1)].ltd_exp, - op_data, data, datalen, mode, uid, gid, rdev, request); + rc = md_create(lmv->tgts[op_data->fid1.mds].ltd_exp, op_data, data, + datalen, mode, uid, gid, rdev, request); if (rc == 0) { if (*request == NULL) RETURN(rc); @@ -888,14 +871,16 @@ repeat: sizeof(*body)); LASSERT(body != NULL); - CDEBUG(D_OTHER, "created. "DLID4"\n", OLID4(&op_data->id1)); + CDEBUG(D_OTHER, "created. id = %lu, generation = %lu, " + "mds = %d\n", (unsigned long)body->fid1.id, + (unsigned long)body->fid1.generation, op_data->fid1.mds); -/* LASSERT(body->valid & OBD_MD_MDS || - body->mds == id_group(&op_data->id1));*/ + LASSERT(body->valid & OBD_MD_MDS || + body->mds == op_data->fid1.mds); } else if (rc == -ERESTART) { /* directory got splitted. time to update local object and * repeat the request with proper MDS */ - rc = lmv_get_mea_and_update_object(exp, &op_data->id1); + rc = lmv_get_mea_and_update_object(exp, &op_data->fid1); if (rc == 0) { ptlrpc_req_finished(*request); goto repeat; @@ -923,7 +908,7 @@ int lmv_done_writing(struct obd_export *exp, struct obdo *obdo) int lmv_enqueue_slaves(struct obd_export *exp, int locktype, struct lookup_intent *it, int lockmode, struct mdc_op_data *data, struct lustre_handle *lockh, - void *lmm, int lmmsize, ldlm_completion_callback cb_compl, + void *lmm, int lmmsize, ldlm_completion_callback cb_completion, ldlm_blocking_callback cb_blocking, void *cb_data) { struct obd_device *obd = exp->exp_obd; @@ -936,18 +921,21 @@ int lmv_enqueue_slaves(struct obd_export *exp, int locktype, LASSERT(mea != NULL); for (i = 0; i < mea->mea_count; i++) { memset(&data2, 0, sizeof(data2)); - data2.id1 = mea->mea_ids[i]; - mds = id_group(&data2.id1); + data2.fid1 = mea->mea_fids[i]; + mds = data2.fid1.mds; if (lmv->tgts[mds].ltd_exp == NULL) continue; - rc = md_enqueue(lmv->tgts[mds].ltd_exp, locktype, it, - lockmode, &data2, lockh + i, lmm, lmmsize, - cb_compl, cb_blocking, cb_data); + rc = md_enqueue(lmv->tgts[mds].ltd_exp, locktype, it, lockmode, + &data2, lockh + i, lmm, lmmsize, cb_completion, + cb_blocking, cb_data); - CDEBUG(D_OTHER, "take lock on slave "DLID4" -> %d/%d\n", - OLID4(&mea->mea_ids[i]), rc, it->d.lustre.it_status); + CDEBUG(D_OTHER, "take lock on slave %lu/%lu/%lu -> %d/%d\n", + (unsigned long)mea->mea_fids[i].mds, + (unsigned long)mea->mea_fids[i].id, + (unsigned long)mea->mea_fids[i].generation, + rc, it->d.lustre.it_status); if (rc) GOTO(cleanup, rc); if (it->d.lustre.it_data) { @@ -974,7 +962,7 @@ cleanup: int lmv_enqueue(struct obd_export *exp, int lock_type, struct lookup_intent *it, int lock_mode, struct mdc_op_data *data, struct lustre_handle *lockh, - void *lmm, int lmmsize, ldlm_completion_callback cb_compl, + void *lmm, int lmmsize, ldlm_completion_callback cb_completion, ldlm_blocking_callback cb_blocking, void *cb_data) { struct obd_device *obd = exp->exp_obd; @@ -990,39 +978,39 @@ int lmv_enqueue(struct obd_export *exp, int lock_type, if (it->it_op == IT_UNLINK) { rc = lmv_enqueue_slaves(exp, lock_type, it, lock_mode, data, lockh, lmm, lmmsize, - cb_compl, cb_blocking, cb_data); + cb_completion, cb_blocking, cb_data); RETURN(rc); } if (data->namelen) { - obj = lmv_grab_obj(obd, &data->id1); + obj = lmv_grab_obj(obd, &data->fid1); if (obj) { /* directory is splitted. look for right mds for this * name */ mds = raw_name2idx(obj->hashtype, obj->objcount, (char *)data->name, data->namelen); - data->id1 = obj->objs[mds].id; + data->fid1 = obj->objs[mds].fid; lmv_put_obj(obj); } } - CDEBUG(D_OTHER, "ENQUEUE '%s' on "DLID4"\n", LL_IT2STR(it), - OLID4(&data->id1)); + CDEBUG(D_OTHER, "ENQUEUE '%s' on %lu/%lu\n", LL_IT2STR(it), + (unsigned long)data->fid1.id, (unsigned long)data->fid1.generation); - rc = md_enqueue(lmv->tgts[id_group(&data->id1)].ltd_exp, - lock_type, it, lock_mode, data, lockh, lmm, - lmmsize, cb_compl, cb_blocking, cb_data); + rc = md_enqueue(lmv->tgts[data->fid1.mds].ltd_exp, lock_type, it, + lock_mode, data, lockh, lmm, lmmsize, cb_completion, + cb_blocking, cb_data); RETURN(rc); } -int lmv_getattr_name(struct obd_export *exp, struct lustre_id *id, +int lmv_getattr_name(struct obd_export *exp, struct ll_fid *fid, char *filename, int namelen, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request) { - int rc, mds = id_group(id), loop = 0; struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - struct lustre_id rid = *id; + struct ll_fid rfid = *fid; + int rc, mds = fid->mds, loop = 0; struct mds_body *body; struct lmv_obj *obj; ENTRY; @@ -1031,20 +1019,22 @@ int lmv_getattr_name(struct obd_export *exp, struct lustre_id *id, RETURN(rc); repeat: LASSERT(++loop <= 2); - obj = lmv_grab_obj(obd, id); + obj = lmv_grab_obj(obd, fid); if (obj) { /* directory is splitted. look for right mds for this name */ - mds = raw_name2idx(obj->hashtype, obj->objcount, - filename, namelen - 1); - rid = obj->objs[mds].id; + mds = raw_name2idx(obj->hashtype, obj->objcount, filename, namelen - 1); + rfid = obj->objs[mds].fid; lmv_put_obj(obj); } - CDEBUG(D_OTHER, "getattr_name for %*s on "DLID4" -> "DLID4"\n", - namelen, filename, OLID4(id), OLID4(&rid)); - - rc = md_getattr_name(lmv->tgts[id_group(&rid)].ltd_exp, - &rid, filename, namelen, valid, ea_size, request); + CDEBUG(D_OTHER, "getattr_name for %*s on %lu/%lu/%lu -> %lu/%lu/%lu\n", + namelen, filename, (unsigned long)fid->mds, + (unsigned long)fid->id, (unsigned long)fid->generation, + (unsigned long)rfid.mds, (unsigned long)rfid.id, + (unsigned long)rfid.generation); + + rc = md_getattr_name(lmv->tgts[rfid.mds].ltd_exp, &rfid, filename, + namelen, valid, ea_size, request); if (rc == 0) { /* this could be cross-node reference. in this case all we have * right now is mds/ino/generation triple. we'd like to find @@ -1053,19 +1043,20 @@ repeat: LASSERT(body != NULL); if (body->valid & OBD_MD_MDS) { struct ptlrpc_request *req = NULL; - - rid = body->id1; - CDEBUG(D_OTHER, "request attrs for "DLID4"\n", OLID4(&rid)); - - rc = md_getattr_name(lmv->tgts[id_group(&rid)].ltd_exp, - &rid, NULL, 1, valid, ea_size, &req); + rfid = body->fid1; + CDEBUG(D_OTHER, "request attrs for %lu/%lu/%lu\n", + (unsigned long) rfid.mds, + (unsigned long) rfid.id, + (unsigned long) rfid.generation); + rc = md_getattr_name(lmv->tgts[rfid.mds].ltd_exp, &rfid, + NULL, 1, valid, ea_size, &req); ptlrpc_req_finished(*request); *request = req; } } else if (rc == -ERESTART) { /* directory got splitted. time to update local object and * repeat the request with proper MDS */ - rc = lmv_get_mea_and_update_object(exp, &rid); + rc = lmv_get_mea_and_update_object(exp, &rfid); if (rc == 0) { ptlrpc_req_finished(*request); goto repeat; @@ -1074,9 +1065,10 @@ repeat: RETURN(rc); } + /* - * llite passes id of an target inode in data->id1 and id of directory in - * data->id2 + * llite passes fid of an target inode in data->fid1 and fid of directory in + * data->fid2 */ int lmv_link(struct obd_export *exp, struct mdc_op_data *data, struct ptlrpc_request **request) @@ -1093,25 +1085,32 @@ int lmv_link(struct obd_export *exp, struct mdc_op_data *data, if (data->namelen != 0) { /* usual link request */ - obj = lmv_grab_obj(obd, &data->id1); + obj = lmv_grab_obj(obd, &data->fid1); if (obj) { - rc = raw_name2idx(obj->hashtype, obj->objcount, - data->name, data->namelen); - data->id1 = obj->objs[rc].id; + rc = raw_name2idx(obj->hashtype, obj->objcount, data->name, + data->namelen); + data->fid1 = obj->objs[rc].fid; lmv_put_obj(obj); } - CDEBUG(D_OTHER,"link "DLID4":%*s to "DLID4"\n", - OLID4(&data->id2), data->namelen, data->name, - OLID4(&data->id1)); + CDEBUG(D_OTHER,"link %lu/%lu/%lu:%*s to %lu/%lu/%lu mds %lu\n", + (unsigned long)data->fid2.mds, + (unsigned long)data->fid2.id, + (unsigned long)data->fid2.generation, + data->namelen, data->name, + (unsigned long)data->fid1.mds, + (unsigned long)data->fid1.id, + (unsigned long)data->fid1.generation, + (unsigned long)data->fid1.mds); } else { - /* request from MDS to acquire i_links for inode by id1 */ - CDEBUG(D_OTHER, "inc i_nlinks for "DLID4"\n", - OLID4(&data->id1)); + /* request from MDS to acquire i_links for inode by fid1 */ + CDEBUG(D_OTHER, "inc i_nlinks for %lu/%lu/%lu\n", + (unsigned long)data->fid1.mds, + (unsigned long)data->fid1.id, + (unsigned long)data->fid1.generation); } - rc = md_link(lmv->tgts[id_group(&data->id1)].ltd_exp, - data, request); + rc = md_link(lmv->tgts[data->fid1.mds].ltd_exp, data, request); RETURN(rc); } @@ -1125,14 +1124,22 @@ int lmv_rename(struct obd_export *exp, struct mdc_op_data *data, int rc, mds; ENTRY; - CDEBUG(D_OTHER, "rename %*s in "DLID4" to %*s in "DLID4"\n", - oldlen, old, OLID4(&data->id1), newlen, new, OLID4(&data->id2)); + CDEBUG(D_OTHER, "rename %*s in %lu/%lu/%lu to %*s in %lu/%lu/%lu\n", + oldlen, old, (unsigned long)data->fid1.mds, + (unsigned long)data->fid1.id, + (unsigned long)data->fid1.generation, + newlen, new, (unsigned long) data->fid2.mds, + (unsigned long) data->fid2.id, + (unsigned long) data->fid2.generation); - if (!lmv_id_equal(&data->id1, &data->id2)) { - CDEBUG(D_OTHER,"cross-node rename "DLID4"/%*s to "DLID4"/%*s\n", - OLID4(&data->id1), oldlen, old, OLID4(&data->id2), - newlen, new); - } + if (!fid_equal(&data->fid1, &data->fid2)) + CDEBUG(D_OTHER, "cross-node rename %lu/%lu/%lu:%*s to %lu/%lu/%lu:%*s\n", + (unsigned long)data->fid1.mds, + (unsigned long)data->fid1.id, + (unsigned long)data->fid1.generation, oldlen, old, + (unsigned long)data->fid2.mds, + (unsigned long)data->fid2.id, + (unsigned long)data->fid2.generation, newlen, new); rc = lmv_check_connect(obd); if (rc) @@ -1142,39 +1149,45 @@ int lmv_rename(struct obd_export *exp, struct mdc_op_data *data, /* MDS with old dir entry is asking another MDS to create name * there */ CDEBUG(D_OTHER, - "create %*s(%d/%d) in "DLID4" pointing " - "to "DLID4"\n", newlen, new, oldlen, newlen, - OLID4(&data->id2), OLID4(&data->id1)); - mds = id_group(&data->id2); + "create %*s(%d/%d) in %lu/%lu/%lu pointing to %lu/%lu/%lu\n", + newlen, new, oldlen, newlen, + (unsigned long)data->fid2.mds, + (unsigned long)data->fid2.id, + (unsigned long)data->fid2.generation, + (unsigned long)data->fid1.mds, + (unsigned long)data->fid1.id, + (unsigned long)data->fid1.generation); + mds = data->fid2.mds; goto request; } - obj = lmv_grab_obj(obd, &data->id1); + obj = lmv_grab_obj(obd, &data->fid1); if (obj) { /* directory is already splitted, so we have to forward request * to the right MDS */ - mds = raw_name2idx(obj->hashtype, obj->objcount, - (char *)old, oldlen); - data->id1 = obj->objs[mds].id; - CDEBUG(D_OTHER, "forward to MDS #%u ("DLID4")\n", mds, - OLID4(&obj->objs[mds].id)); + mds = raw_name2idx(obj->hashtype, obj->objcount, (char *)old, oldlen); + data->fid1 = obj->objs[mds].fid; + CDEBUG(D_OTHER, "forward to MDS #%u (%lu/%lu/%lu)\n", mds, + (unsigned long)obj->objs[mds].fid.mds, + (unsigned long)obj->objs[mds].fid.id, + (unsigned long)obj->objs[mds].fid.generation); lmv_put_obj(obj); } - obj = lmv_grab_obj(obd, &data->id2); + obj = lmv_grab_obj(obd, &data->fid2); if (obj) { /* directory is already splitted, so we have to forward request * to the right MDS */ - mds = raw_name2idx(obj->hashtype, obj->objcount, - (char *)new, newlen); - - data->id2 = obj->objs[mds].id; - CDEBUG(D_OTHER, "forward to MDS #%u ("DLID4")\n", mds, - OLID4(&obj->objs[mds].id)); + mds = raw_name2idx(obj->hashtype, obj->objcount, (char *)new, newlen); + data->fid2 = obj->objs[mds].fid; + CDEBUG(D_OTHER, "forward to MDS #%u (%lu/%lu/%lu)\n", mds, + (unsigned long)obj->objs[mds].fid.mds, + (unsigned long)obj->objs[mds].fid.id, + (unsigned long)obj->objs[mds].fid.generation); lmv_put_obj(obj); } - mds = id_group(&data->id1); + mds = data->fid1.mds; request: rc = md_rename(lmv->tgts[mds].ltd_exp, data, old, oldlen, @@ -1198,19 +1211,21 @@ int lmv_setattr(struct obd_export *exp, struct mdc_op_data *data, if (rc) RETURN(rc); - obj = lmv_grab_obj(obd, &data->id1); + obj = lmv_grab_obj(obd, &data->fid1); - CDEBUG(D_OTHER, "SETATTR for "DLID4", valid 0x%x%s\n", - OLID4(&data->id1), iattr->ia_valid, obj ? ", splitted" : ""); + CDEBUG(D_OTHER, "SETATTR for %lu/%lu/%lu, valid 0x%x%s\n", + (unsigned long)data->fid1.mds, (unsigned long)data->fid1.id, + (unsigned long)data->fid1.generation, iattr->ia_valid, + obj ? ", splitted" : ""); if (obj) { for (i = 0; i < obj->objcount; i++) { - data->id1 = obj->objs[i].id; + data->fid1 = obj->objs[i].fid; - rc = md_setattr(lmv->tgts[id_group(&data->id1)].ltd_exp, - data, iattr, ea, ealen, ea2, ea2len, &req); + rc = md_setattr(lmv->tgts[data->fid1.mds].ltd_exp, data, + iattr, ea, ealen, ea2, ea2len, &req); - if (lmv_id_equal(&obj->id, &obj->objs[i].id)) { + if (fid_equal(&obj->fid, &obj->objs[i].fid)) { /* this is master object and this request should * be returned back to llite */ *request = req; @@ -1223,20 +1238,20 @@ int lmv_setattr(struct obd_export *exp, struct mdc_op_data *data, } lmv_put_obj(obj); } else { - LASSERT(id_group(&data->id1) < lmv->desc.ld_tgt_count); - rc = md_setattr(lmv->tgts[id_group(&data->id1)].ltd_exp, - data, iattr, ea, ealen, ea2, ea2len, request); + LASSERT(data->fid1.mds < lmv->desc.ld_tgt_count); + rc = md_setattr(lmv->tgts[data->fid1.mds].ltd_exp, data, + iattr, ea, ealen, ea2, ea2len, request); if (rc == 0) { body = lustre_msg_buf((*request)->rq_repmsg, 0, sizeof(*body)); LASSERT(body != NULL); -// LASSERT(body->mds == id_group(&data->id1)); + LASSERT(body->mds == data->fid1.mds); } } RETURN(rc); } -int lmv_sync(struct obd_export *exp, struct lustre_id *id, +int lmv_sync(struct obd_export *exp, struct ll_fid *fid, struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; @@ -1248,13 +1263,11 @@ int lmv_sync(struct obd_export *exp, struct lustre_id *id, if (rc) RETURN(rc); - rc = md_sync(lmv->tgts[id_group(id)].ltd_exp, - id, request); + rc = md_sync(lmv->tgts[fid->mds].ltd_exp, fid, request); RETURN(rc); } -int lmv_dirobj_blocking_ast(struct ldlm_lock *lock, - struct ldlm_lock_desc *desc, +int lmv_dirobj_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, void *data, int flag) { struct lustre_handle lockh; @@ -1276,12 +1289,12 @@ int lmv_dirobj_blocking_ast(struct ldlm_lock *lock, obj = lock->l_ast_data; if (obj) { CDEBUG(D_OTHER, "cancel %s on "LPU64"/"LPU64 - ", master "DLID4"\n", + ", master %u/"LPU64"/%u\n", lock->l_resource->lr_name.name[3] == 1 ? - "LOOKUP" : "UPDATE", + "LOOKUP" : "UPDATE", lock->l_resource->lr_name.name[0], - lock->l_resource->lr_name.name[1], - OLID4(&obj->id)); + lock->l_resource->lr_name.name[1], obj->fid.mds, + obj->fid.id, obj->fid.generation); lmv_put_obj(obj); } break; @@ -1308,27 +1321,28 @@ void lmv_remove_dots(struct page *page) } } -int lmv_readpage(struct obd_export *exp, struct lustre_id *id, +int lmv_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, __u64 offset, struct page *page, struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - struct lustre_id rid = *id; + struct ll_fid rfid = *mdc_fid; struct lmv_obj *obj; int rc, i; ENTRY; -#warning "we need well-desgined readdir() implementation" rc = lmv_check_connect(obd); if (rc) RETURN(rc); - LASSERT(id_group(id) < lmv->desc.ld_tgt_count); - CDEBUG(D_OTHER, "READPAGE at %llu from "DLID4"\n", - offset, OLID4(&rid)); + LASSERT(mdc_fid->mds < lmv->desc.ld_tgt_count); + CDEBUG(D_OTHER, "READPAGE at %llu from %lu/%lu/%lu\n", + offset, (unsigned long) rfid.mds, + (unsigned long) rfid.id, + (unsigned long) rfid.generation); - obj = lmv_grab_obj(obd, id); + obj = lmv_grab_obj(obd, mdc_fid); if (obj) { lmv_lock_obj(obj); @@ -1338,18 +1352,19 @@ int lmv_readpage(struct obd_export *exp, struct lustre_id *id, break; offset -= obj->objs[i].size; } - rid = obj->objs[i].id; + rfid = obj->objs[i].fid; lmv_unlock_obj(obj); lmv_put_obj(obj); - CDEBUG(D_OTHER, "forward to "DLID4" with offset %lu\n", - OLID4(&rid), (unsigned long)offset); + CDEBUG(D_OTHER, "forward to %lu/%lu/%lu with offset %lu\n", + (unsigned long)rfid.mds, (unsigned long)rfid.id, + (unsigned long)rfid.generation, (unsigned long)offset); } - rc = md_readpage(lmv->tgts[id_group(&rid)].ltd_exp, &rid, - offset, page, request); + rc = md_readpage(lmv->tgts[rfid.mds].ltd_exp, &rfid, offset, + page, request); - if (rc == 0 && !lmv_id_equal(&rid, id)) + if (rc == 0 && !fid_equal(&rfid, mdc_fid)) /* this page isn't from master object. To avoid "." and ".." * duplication in directory, we have to remove them from all * slave objects */ @@ -1371,17 +1386,18 @@ int lmv_unlink_slaves(struct obd_export *exp, struct mdc_op_data *data, LASSERT(mea != NULL); for (i = 0; i < mea->mea_count; i++) { memset(&data2, 0, sizeof(data2)); - data2.id1 = mea->mea_ids[i]; + data2.fid1 = mea->mea_fids[i]; data2.create_mode = MDS_MODE_DONT_LOCK | S_IFDIR; - - mds = id_group(&data2.id1); + mds = data2.fid1.mds; if (lmv->tgts[mds].ltd_exp == NULL) continue; rc = md_unlink(lmv->tgts[mds].ltd_exp, &data2, req); - CDEBUG(D_OTHER, "unlink slave "DLID4" -> %d\n", - OLID4(&mea->mea_ids[i]), rc); + CDEBUG(D_OTHER, "unlink slave %lu/%lu/%lu -> %d\n", + (unsigned long) mea->mea_fids[i].mds, + (unsigned long) mea->mea_fids[i].id, + (unsigned long) mea->mea_fids[i].generation, rc); if (*req) { ptlrpc_req_finished(*req); *req = NULL; @@ -1392,13 +1408,14 @@ int lmv_unlink_slaves(struct obd_export *exp, struct mdc_op_data *data, RETURN(rc); } -int lmv_delete_object(struct obd_export *exp, struct lustre_id *id) +int lmv_delete_object(struct obd_export *exp, struct ll_fid *fid) { ENTRY; - if (!lmv_delete_obj(exp, id)) { - CDEBUG(D_OTHER, "object "DLID4" is not found.\n", - OLID4(id)); + if (!lmv_delete_obj(exp, fid)) { + CDEBUG(D_OTHER, "Object %lu/%lu/%lu is not found.\n", + (unsigned long)fid->mds, (unsigned long)fid->id, + (unsigned long)fid->generation); } RETURN(0); @@ -1423,22 +1440,25 @@ int lmv_unlink(struct obd_export *exp, struct mdc_op_data *data, } else if (data->namelen != 0) { struct lmv_obj *obj; - obj = lmv_grab_obj(obd, &data->id1); + obj = lmv_grab_obj(obd, &data->fid1); if (obj) { - i = raw_name2idx(obj->hashtype, obj->objcount, - data->name, data->namelen); - data->id1 = obj->objs[i].id; + i = raw_name2idx(obj->hashtype, obj->objcount, data->name, + data->namelen); + data->fid1 = obj->objs[i].fid; lmv_put_obj(obj); } - CDEBUG(D_OTHER, "unlink '%*s' in "DLID4" -> %u\n", - data->namelen, data->name, OLID4(&data->id1), - i); + CDEBUG(D_OTHER, "unlink '%*s' in %lu/%lu/%lu -> %u\n", + data->namelen, data->name, + (unsigned long) data->fid1.mds, + (unsigned long) data->fid1.id, + (unsigned long) data->fid1.generation, i); } else { - CDEBUG(D_OTHER, "drop i_nlink on "DLID4"\n", - OLID4(&data->id1)); + CDEBUG(D_OTHER, "drop i_nlink on %lu/%lu/%lu\n", + (unsigned long) data->fid1.mds, + (unsigned long) data->fid1.id, + (unsigned long) data->fid1.generation); } - rc = md_unlink(lmv->tgts[id_group(&data->id1)].ltd_exp, - data, request); + rc = md_unlink(lmv->tgts[data->fid1.mds].ltd_exp, data, request); RETURN(rc); } @@ -1453,6 +1473,7 @@ struct obd_device *lmv_get_real_obd(struct obd_export *exp, rc = lmv_check_connect(obd); if (rc) RETURN(ERR_PTR(rc)); +#warning "we need well-desgined readdir() implementation to remove this mess" obd = lmv->tgts[0].ltd_exp->exp_obd; EXIT; return obd; @@ -1513,27 +1534,17 @@ int lmv_obd_create_single(struct obd_export *exp, struct obdo *oa, RETURN(rc); } -int lmv_getready(struct obd_export *exp) -{ - struct obd_device *obd = exp->exp_obd; - int rc = 0; - - ENTRY; - rc = lmv_check_connect(obd); - RETURN(rc); -} - /* - * to be called from MDS only. + * to be called from MDS only */ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md **ea, struct obd_trans_info *oti) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - struct lustre_id mid; int i, c, rc = 0; struct mea *mea; + struct ll_fid mfid; int lcount; ENTRY; @@ -1545,8 +1556,6 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, if (ea == NULL) { rc = lmv_obd_create_single(exp, oa, NULL, oti); - if (rc) - CERROR("Can't create object, rc = %d\n", rc); RETURN(rc); } @@ -1559,22 +1568,19 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, } if (*ea == NULL) - RETURN(-ENOMEM); + RETURN(-EINVAL); } rc = 0; + mfid.id = oa->o_id; + mfid.generation = oa->o_generation; - id_ino(&mid) = oa->o_id; - id_fid(&mid) = oa->o_fid; - id_gen(&mid) = oa->o_generation; - mea = (struct mea *)*ea; if (!mea->mea_count || mea->mea_count > lmv->desc.ld_tgt_count) mea->mea_count = lmv->desc.ld_tgt_count; - - mea->mea_master = -1; mea->mea_magic = MEA_MAGIC_ALL_CHARS; + mea->mea_master = -1; lcount = lmv->desc.ld_tgt_count; for (i = 0, c = 0; c < mea->mea_count && i < lcount; i++) { struct lov_stripe_md obj_md; @@ -1582,22 +1588,21 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, if (lmv->tgts[i].ltd_exp == NULL) { /* this is master MDS */ + mea->mea_fids[c].id = mfid.id; + mea->mea_fids[c].generation = mfid.generation; + mea->mea_fids[c].mds = i; mea->mea_master = i; - id_group(&mea->mea_ids[c]) = i; - id_ino(&mea->mea_ids[c]) = id_ino(&mid); - id_gen(&mea->mea_ids[c]) = id_gen(&mid); - id_fid(&mea->mea_ids[c]) = id_fid(&mid); c++; continue; } /* "master" MDS should always be part of stripped dir, so scan - * for it. */ + for it. */ if (mea->mea_master == -1 && c == mea->mea_count - 1) continue; - oa->o_valid = OBD_MD_FLGENER | OBD_MD_FLTYPE | OBD_MD_FLMODE | - OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLID; + oa->o_valid = OBD_MD_FLGENER | OBD_MD_FLTYPE | OBD_MD_FLMODE + | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLID; rc = obd_create(lmv->tgts[c].ltd_exp, oa, &obj_mdp, oti); if (rc) { @@ -1606,18 +1611,12 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, RETURN(rc); } + mea->mea_fids[c].id = oa->o_id; + mea->mea_fids[c].generation = oa->o_generation; + mea->mea_fids[c].mds = i; + c++; CDEBUG(D_OTHER, "dirobj at mds %d: "LPU64"/%u\n", i, oa->o_id, oa->o_generation); - - /* here after object is created on desired MDS we save its fid - * to local mea_ids. */ - LASSERT(oa->o_fid); - - id_group(&mea->mea_ids[c]) = i; - id_ino(&mea->mea_ids[c]) = oa->o_id; - id_fid(&mea->mea_ids[c]) = oa->o_fid; - id_gen(&mea->mea_ids[c]) = oa->o_generation; - c++; } LASSERT(c == mea->mea_count); CDEBUG(D_OTHER, "%d dirobjects created\n", (int) mea->mea_count); @@ -1658,7 +1657,6 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen, { struct obd_device *obd; struct lmv_obd *lmv; - int rc = 0; ENTRY; obd = class_exp2obd(exp); @@ -1672,8 +1670,8 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen, if (keylen == 6 && memcmp(key, "mdsize", 6) == 0) { __u32 *mdsize = val; *vallen = sizeof(__u32); - *mdsize = sizeof(struct lustre_id) * lmv->desc.ld_tgt_count - + sizeof(struct mea); + *mdsize = sizeof(struct ll_fid) * lmv->desc.ld_tgt_count + + sizeof(struct mea); RETURN(0); } else if (keylen == 6 && memcmp(key, "mdsnum", 6) == 0) { struct obd_uuid *cluuid = &lmv->cluuid; @@ -1689,15 +1687,6 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen, } } LASSERT(0); - } else if (keylen == 6 && memcmp(key, "rootid", 6) == 0) { - /* getting rootid from first MDS. */ - rc = obd_get_info(lmv->tgts[0].ltd_exp, keylen, key, - vallen, val); - RETURN(rc); - } else if (keylen >= strlen("lmvdesc") && strcmp(key, "lmvdesc") == 0) { - struct lmv_desc *desc_ret = val; - *desc_ret = lmv->desc; - RETURN(0); } CDEBUG(D_IOCTL, "invalid key\n"); @@ -1736,7 +1725,7 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, int mea_size; ENTRY; - mea_size = sizeof(struct lustre_id) * + mea_size = sizeof(struct ll_fid) * lmv->desc.ld_tgt_count + sizeof(struct mea); if (!lmmp) RETURN(mea_size); @@ -1771,7 +1760,7 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **mem_tgt, int mea_size; ENTRY; - mea_size = sizeof(struct lustre_id) * + mea_size = sizeof(struct ll_fid) * lmv->desc.ld_tgt_count + sizeof(struct mea); if (mem_tgt == NULL) return mea_size; @@ -1809,12 +1798,11 @@ int lmv_brw(int rw, struct obd_export *exp, struct obdo *oa, LASSERT(pgarr != NULL); LASSERT(oa->o_mds < lmv->desc.ld_tgt_count); - oa->o_gr = id_gen(&mea->mea_ids[oa->o_mds]); - oa->o_id = id_ino(&mea->mea_ids[oa->o_mds]); - oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP; - - err = obd_brw(rw, lmv->tgts[oa->o_mds].ltd_exp, - oa, NULL, oa_bufs, pgarr, oti); + oa->o_gr = mea->mea_fids[oa->o_mds].generation; + oa->o_id = mea->mea_fids[oa->o_mds].id; + oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP; + err = obd_brw(rw, lmv->tgts[oa->o_mds].ltd_exp, oa, + NULL, oa_bufs, pgarr, oti); RETURN(err); } @@ -1838,7 +1826,6 @@ struct obd_ops lmv_obd_ops = { .o_init_ea_size = lmv_init_ea_size, .o_notify = lmv_notify, .o_iocontrol = lmv_iocontrol, - .o_getready = lmv_getready, }; struct md_ops lmv_md_ops = { diff --git a/lustre/lmv/lmv_objmgr.c b/lustre/lmv/lmv_objmgr.c index 1aa6b4c..9485f9d 100644 --- a/lustre/lmv/lmv_objmgr.c +++ b/lustre/lmv/lmv_objmgr.c @@ -51,10 +51,9 @@ static LIST_HEAD(lmv_obj_list); static spinlock_t lmv_obj_list_lock = SPIN_LOCK_UNLOCKED; -/* creates new obj on passed @id and @mea. */ +/* creates new obj on passed @fid and @mea. */ struct lmv_obj * -lmv_alloc_obj(struct obd_device *obd, - struct lustre_id *id, +lmv_alloc_obj(struct obd_device *obd, struct ll_fid *fid, struct mea *mea) { int i; @@ -63,17 +62,17 @@ lmv_alloc_obj(struct obd_device *obd, struct lmv_obd *lmv = &obd->u.lmv; LASSERT(mea->mea_magic == MEA_MAGIC_LAST_CHAR - || mea->mea_magic == MEA_MAGIC_ALL_CHARS); + || mea->mea_magic == MEA_MAGIC_ALL_CHARS); OBD_ALLOC(obj, sizeof(*obj)); if (!obj) return NULL; - obj->id = *id; obj->obd = obd; obj->state = 0; + obj->fid = *fid; obj->hashtype = mea->mea_magic; - + init_MUTEX(&obj->guard); atomic_set(&obj->count, 0); obj->objcount = mea->mea_count; @@ -87,12 +86,13 @@ lmv_alloc_obj(struct obd_device *obd, memset(obj->objs, 0, obj_size); - /* put all ids in */ + /* put all fids in */ for (i = 0; i < mea->mea_count; i++) { - CDEBUG(D_OTHER, "subobj "DLID4"\n", - OLID4(&mea->mea_ids[i])); - obj->objs[i].id = mea->mea_ids[i]; - LASSERT(id_fid(&obj->objs[i].id)); + CDEBUG(D_OTHER, "subobj %lu/%lu/%lu\n", + (unsigned long)mea->mea_fids[i].mds, + (unsigned long)mea->mea_fids[i].id, + (unsigned long)mea->mea_fids[i].generation); + obj->objs[i].fid = mea->mea_fids[i]; } return obj; @@ -102,7 +102,7 @@ err_obj: return NULL; } -/* destroy passed @obj. */ +/* destroys passed @obj. */ void lmv_free_obj(struct lmv_obj *obj) { @@ -173,9 +173,10 @@ __put_obj(struct lmv_obj *obj) LASSERT(obj); if (atomic_dec_and_test(&obj->count)) { - struct lustre_id *id = &obj->id; - CDEBUG(D_OTHER, "last reference to "DLID4" - " - "destroying\n", OLID4(id)); + struct ll_fid *fid = &obj->fid; + CDEBUG(D_OTHER, "last reference to %lu/%lu/%lu - destroying\n", + (unsigned long)fid->mds, (unsigned long)fid->id, + (unsigned long)fid->generation); __del_obj(obj); } } @@ -189,7 +190,7 @@ lmv_put_obj(struct lmv_obj *obj) } static struct lmv_obj * -__grab_obj(struct obd_device *obd, struct lustre_id *id) +__grab_obj(struct obd_device *obd, struct ll_fid *fid) { struct lmv_obj *obj; struct list_head *cur; @@ -202,8 +203,8 @@ __grab_obj(struct obd_device *obd, struct lustre_id *id) if (obj->state & O_FREEING) continue; - /* check if this is what we're looking for. */ - if (lmv_id_equal(&obj->id, id)) + /* check if this is waht we're looking for. */ + if (fid_equal(&obj->fid, fid)) return __get_obj(obj); } @@ -211,39 +212,39 @@ __grab_obj(struct obd_device *obd, struct lustre_id *id) } struct lmv_obj * -lmv_grab_obj(struct obd_device *obd, struct lustre_id *id) +lmv_grab_obj(struct obd_device *obd, struct ll_fid *fid) { struct lmv_obj *obj; ENTRY; spin_lock(&lmv_obj_list_lock); - obj = __grab_obj(obd, id); + obj = __grab_obj(obd, fid); spin_unlock(&lmv_obj_list_lock); RETURN(obj); } -/* looks in objects list for an object that matches passed @id. If it is not +/* looks in objects list for an object that matches passed @fid. If it is not * found -- creates it using passed @mea and puts onto list. */ static struct lmv_obj * -__create_obj(struct obd_device *obd, struct lustre_id *id, struct mea *mea) +__create_obj(struct obd_device *obd, struct ll_fid *fid, struct mea *mea) { struct lmv_obj *new, *obj; ENTRY; - obj = lmv_grab_obj(obd, id); + obj = lmv_grab_obj(obd, fid); if (obj) RETURN(obj); /* no such object yet, allocate and initialize it. */ - new = lmv_alloc_obj(obd, id, mea); + new = lmv_alloc_obj(obd, fid, mea); if (!new) RETURN(NULL); /* check if someone create it already while we were dealing with * allocating @obj. */ spin_lock(&lmv_obj_list_lock); - obj = __grab_obj(obd, id); + obj = __grab_obj(obd, fid); if (obj) { /* someone created it already - put @obj and getting out. */ lmv_free_obj(new); @@ -256,17 +257,18 @@ __create_obj(struct obd_device *obd, struct lustre_id *id, struct mea *mea) spin_unlock(&lmv_obj_list_lock); - CDEBUG(D_OTHER, "new obj in lmv cache: "DLID4"\n", - OLID4(id)); + CDEBUG(D_OTHER, "new obj in lmv cache: %lu/%lu/%lu\n", + (unsigned long)fid->mds, (unsigned long)fid->id, + (unsigned long)fid->generation); RETURN(new); } -/* creates object from passed @id and @mea. If @mea is NULL, it will be +/* creates object from passed @fid and @mea. If @mea is NULL, it will be * obtained from correct MDT and used for constructing the object. */ struct lmv_obj * -lmv_create_obj(struct obd_export *exp, struct lustre_id *id, struct mea *mea) +lmv_create_obj(struct obd_export *exp, struct ll_fid *fid, struct mea *mea) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -276,8 +278,9 @@ lmv_create_obj(struct obd_export *exp, struct lustre_id *id, struct mea *mea) int mealen, i, rc; ENTRY; - CDEBUG(D_OTHER, "get mea for "DLID4" and create lmv obj\n", - OLID4(id)); + CDEBUG(D_OTHER, "get mea for %lu/%lu/%lu and create lmv obj\n", + (unsigned long)fid->mds, (unsigned long)fid->id, + (unsigned long)fid->generation); if (!mea) { unsigned long valid; @@ -285,13 +288,13 @@ lmv_create_obj(struct obd_export *exp, struct lustre_id *id, struct mea *mea) CDEBUG(D_OTHER, "mea isn't passed in, get it now\n"); mealen = MEA_SIZE_LMV(lmv); - /* time to update mea of parent id */ - i = id->li_fid.lf_group; + /* time to update mea of parent fid */ + i = fid->mds; md.mea = NULL; valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA; - rc = md_getattr(lmv->tgts[id->li_fid.lf_group].ltd_exp, - id, valid, mealen, &req); + rc = md_getattr(lmv->tgts[fid->mds].ltd_exp, fid, + valid, mealen, &req); if (rc) { CERROR("md_getattr() failed, error %d\n", rc); GOTO(cleanup, obj = ERR_PTR(rc)); @@ -310,10 +313,11 @@ lmv_create_obj(struct obd_export *exp, struct lustre_id *id, struct mea *mea) } /* got mea, now create obj for it. */ - obj = __create_obj(obd, id, mea); + obj = __create_obj(obd, fid, mea); if (!obj) { - CERROR("Can't create new object "DLID4"\n", - OLID4(id)); + CERROR("Can't create new object %lu/%lu/%lu\n", + (unsigned long)fid->mds, (unsigned long)fid->id, + (unsigned long)fid->generation); GOTO(cleanup, obj = ERR_PTR(-ENOMEM)); } cleanup: @@ -322,12 +326,12 @@ cleanup: RETURN(obj); } -/* looks for object with @id and orders to destroy it. It is possible the - * object will not be destroyed right now, because it is still using by - * someone. In this case it will be marked as "freeing" and will not be - * accessible anymore for subsequent callers of lmv_grab_obj(). */ +/* looks for object with @fid and orders to destroy it. It possible the object + * will not be destroyed right now, because it is still using by someone. In + * this case it will be marked as "freeing" and will not be accessible anymore + * for subsequent callers of lmv_grab_obj(). */ int -lmv_delete_obj(struct obd_export *exp, struct lustre_id *id) +lmv_delete_obj(struct obd_export *exp, struct ll_fid *fid) { struct obd_device *obd = exp->exp_obd; struct lmv_obj *obj; @@ -336,13 +340,16 @@ lmv_delete_obj(struct obd_export *exp, struct lustre_id *id) spin_lock(&lmv_obj_list_lock); - obj = __grab_obj(obd, id); + obj = __grab_obj(obd, fid); if (obj) { obj->state |= O_FREEING; if (atomic_read(&obj->count) > 1) - CERROR("obj "DLID4" has count > 2 (%d)\n", - OLID4(&obj->id), atomic_read(&obj->count)); + CERROR("obj %lu/%lu/%lu has count > 2 (%d)\n", + (unsigned long) obj->fid.mds, + (unsigned long) obj->fid.id, + (unsigned long) obj->fid.generation, + atomic_read(&obj->count)); __put_obj(obj); __put_obj(obj); rc = 1; @@ -355,8 +362,7 @@ lmv_delete_obj(struct obd_export *exp, struct lustre_id *id) int lmv_setup_mgr(struct obd_device *obd) { - CDEBUG(D_INFO, "LMV object manager setup (%s)\n", - obd->obd_uuid.uuid); + CDEBUG(D_INFO, "LMV object manager setup (%s)\n", obd->obd_uuid.uuid); return 0; } @@ -366,8 +372,7 @@ lmv_cleanup_mgr(struct obd_device *obd) struct lmv_obj *obj; struct list_head *cur, *tmp; - CDEBUG(D_INFO, "LMV object manager cleanup (%s)\n", - obd->obd_uuid.uuid); + CDEBUG(D_INFO, "LMV object manager cleanup (%s)\n", obd->obd_uuid.uuid); spin_lock(&lmv_obj_list_lock); list_for_each_safe(cur, tmp, &lmv_obj_list) { @@ -378,8 +383,11 @@ lmv_cleanup_mgr(struct obd_device *obd) obj->state |= O_FREEING; if (atomic_read(&obj->count) > 1) - CERROR("obj "DLID4" has count > 1 (%d)\n", - OLID4(&obj->id), atomic_read(&obj->count)); + CERROR("obj %lu/%lu/%lu has count > 1 (%d)\n", + (unsigned long) obj->fid.mds, + (unsigned long) obj->fid.id, + (unsigned long) obj->fid.generation, + atomic_read(&obj->count)); __put_obj(obj); } spin_unlock(&lmv_obj_list_lock); diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 4f291df..fb34c8b 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -118,15 +118,12 @@ static void lov_llh_destroy(struct lov_lock_handles *llh) static int lov_connect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt, int activate, unsigned long connect_flags) { - struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; - struct obd_uuid *tgt_uuid = &tgt->uuid; - -#ifdef __KERNEL__ - struct proc_dir_entry *lov_proc_dir; -#endif struct lov_obd *lov = &obd->u.lov; - struct lustre_handle conn = {0, }; + struct obd_uuid *tgt_uuid = &tgt->uuid; struct obd_device *tgt_obd; + struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; + struct lustre_handle conn = {0, }; + struct proc_dir_entry *lov_proc_dir; int rc; ENTRY; @@ -179,7 +176,6 @@ static int lov_connect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt, tgt->active = 1; lov->desc.ld_active_tgt_count++; -#ifdef __KERNEL__ lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds"); if (lov_proc_dir) { struct obd_device *osc_obd = class_conn2obd(&conn); @@ -204,7 +200,6 @@ static int lov_connect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt, lov_proc_dir = NULL; } } -#endif RETURN(0); } @@ -212,12 +207,10 @@ static int lov_connect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt, static int lov_connect(struct lustre_handle *conn, struct obd_device *obd, struct obd_uuid *cluuid, unsigned long connect_flags) { -#ifdef __KERNEL__ - struct proc_dir_entry *lov_proc_dir; -#endif struct lov_obd *lov = &obd->u.lov; struct lov_tgt_desc *tgt; struct obd_export *exp; + struct proc_dir_entry *lov_proc_dir; int rc, rc2, i; ENTRY; @@ -235,7 +228,6 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd, RETURN(0); } -#ifdef __KERNEL__ lov_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry, NULL, NULL); if (IS_ERR(lov_proc_dir)) { @@ -243,7 +235,6 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd, obd->obd_type->typ_name, obd->obd_name); lov_proc_dir = NULL; } -#endif /* connect_flags is the MDS number, save for use in lov_add_obd */ lov->lov_connect_flags = connect_flags; @@ -259,10 +250,8 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd, RETURN (0); out_disc: -#ifdef __KERNEL__ if (lov_proc_dir) lprocfs_remove(lov_proc_dir); -#endif while (i-- > 0) { struct obd_uuid uuid; @@ -283,15 +272,12 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd, static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt, int flags) { -#ifdef __KERNEL__ struct proc_dir_entry *lov_proc_dir; -#endif struct obd_device *osc_obd = class_exp2obd(tgt->ltd_exp); struct lov_obd *lov = &obd->u.lov; int rc; ENTRY; -#ifdef __KERNEL__ lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds"); if (lov_proc_dir) { struct proc_dir_entry *osc_symlink; @@ -305,8 +291,7 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt, osc_obd->obd_name); } } -#endif - + if (obd->obd_no_recov) { /* Pass it on to our clients. * XXX This should be an argument to disconnect, @@ -317,6 +302,7 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt, } obd_register_observer(tgt->ltd_exp->exp_obd, NULL); + rc = obd_disconnect(tgt->ltd_exp, flags); if (rc) { if (tgt->active) { @@ -338,11 +324,9 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt, static int lov_disconnect(struct obd_export *exp, int flags) { struct obd_device *obd = class_exp2obd(exp); -#ifdef __KERNEL__ - struct proc_dir_entry *lov_proc_dir; -#endif struct lov_obd *lov = &obd->u.lov; struct lov_tgt_desc *tgt; + struct proc_dir_entry *lov_proc_dir; int rc, i; ENTRY; @@ -358,8 +342,6 @@ static int lov_disconnect(struct obd_export *exp, int flags) if (tgt->ltd_exp) lov_disconnect_obd(obd, tgt, flags); } - -#ifdef __KERNEL__ lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds"); if (lov_proc_dir) { lprocfs_remove(lov_proc_dir); @@ -367,7 +349,7 @@ static int lov_disconnect(struct obd_export *exp, int flags) CERROR("/proc/fs/lustre/%s/%s/target_obds missing.", obd->obd_type->typ_name, obd->obd_name); } -#endif + out_local: rc = class_disconnect(exp, 0); diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c index 02609e0..3d631dc 100644 --- a/lustre/lvfs/fsfilt_ext3.c +++ b/lustre/lvfs/fsfilt_ext3.c @@ -59,17 +59,14 @@ struct fsfilt_cb_data { struct journal_callback cb_jcb; /* jbd private data - MUST BE FIRST */ fsfilt_cb_t cb_func; /* MDS/OBD completion function */ struct obd_device *cb_obd; /* MDS/OBD completion device */ - __u64 cb_last_num; /* MDS/OST last committed operation */ + __u64 cb_last_rcvd; /* MDS/OST last committed operation */ void *cb_data; /* MDS/OST completion function data */ }; #ifndef EXT3_XATTR_INDEX_TRUSTED /* temporary until we hit l28 kernel */ #define EXT3_XATTR_INDEX_TRUSTED 4 #endif - #define XATTR_LUSTRE_MDS_LOV_EA "lov" -#define XATTR_LUSTRE_MDS_MID_EA "mid" -#define XATTR_LUSTRE_MDS_SID_EA "sid" /* * We don't currently need any additional blocks for rmdir and @@ -444,45 +441,6 @@ static int fsfilt_ext3_iocontrol(struct inode * inode, struct file *file, RETURN(rc); } -static int fsfilt_ext3_set_xattr(struct inode * inode, void *handle, char *name, - void *buffer, int buffer_size) -{ - int rc = 0; - - lock_kernel(); - - rc = ext3_xattr_set_handle(handle, inode, EXT3_XATTR_INDEX_TRUSTED, - name, buffer, buffer_size, 0); - unlock_kernel(); - if (rc) - CERROR("set xattr %s from inode %lu: rc %d\n", - name, inode->i_ino, rc); - return rc; -} - -static int fsfilt_ext3_get_xattr(struct inode *inode, char *name, - void *buffer, int buffer_size) -{ - int rc = 0; - - lock_kernel(); - - rc = ext3_xattr_get(inode, EXT3_XATTR_INDEX_TRUSTED, - name, buffer, buffer_size); - unlock_kernel(); - - if (buffer == NULL) - return (rc == -ENODATA) ? 0 : rc; - if (rc < 0) { - CDEBUG(D_INFO, "error getting EA %s from inode %lu: rc %d\n", - name, inode->i_ino, rc); - memset(buffer, 0, buffer_size); - return (rc == -ENODATA) ? 0 : rc; - } - - return rc; -} - static int fsfilt_ext3_set_md(struct inode *inode, void *handle, void *lmm, int lmm_size) { @@ -493,60 +451,44 @@ static int fsfilt_ext3_set_md(struct inode *inode, void *handle, /* keep this when we get rid of OLD_EA (too noisy during conversion) */ if (EXT3_I(inode)->i_file_acl /* || large inode EA flag */) CWARN("setting EA on %lu/%u again... interesting\n", - inode->i_ino, inode->i_generation); - - rc = fsfilt_ext3_set_xattr(inode, handle, XATTR_LUSTRE_MDS_LOV_EA, - lmm, lmm_size); - return rc; -} + inode->i_ino, inode->i_generation); -/* Must be called with i_sem held */ -static int fsfilt_ext3_get_md(struct inode *inode, void *lmm, int lmm_size) -{ - int rc; - - rc = fsfilt_ext3_get_xattr(inode, XATTR_LUSTRE_MDS_LOV_EA, - lmm, lmm_size); - return rc; -} + lock_kernel(); + rc = ext3_xattr_set_handle(handle, inode, EXT3_XATTR_INDEX_TRUSTED, + XATTR_LUSTRE_MDS_LOV_EA, lmm, lmm_size, 0); -static int fsfilt_ext3_set_mid(struct inode *inode, void *handle, - void *mid, int mid_size) -{ - int rc; + unlock_kernel(); - rc = fsfilt_ext3_set_xattr(inode, handle, XATTR_LUSTRE_MDS_MID_EA, - mid, mid_size); + if (rc) + CERROR("error adding MD data to inode %lu: rc = %d\n", + inode->i_ino, rc); return rc; } /* Must be called with i_sem held */ -static int fsfilt_ext3_get_mid(struct inode *inode, void *mid, int mid_size) +static int fsfilt_ext3_get_md(struct inode *inode, void *lmm, int lmm_size) { int rc; - rc = fsfilt_ext3_get_xattr(inode, XATTR_LUSTRE_MDS_MID_EA, - mid, mid_size); - return rc; -} + LASSERT(down_trylock(&inode->i_sem) != 0); + lock_kernel(); -static int fsfilt_ext3_set_sid(struct inode *inode, void *handle, - void *sid, int sid_size) -{ - int rc; + rc = ext3_xattr_get(inode, EXT3_XATTR_INDEX_TRUSTED, + XATTR_LUSTRE_MDS_LOV_EA, lmm, lmm_size); + unlock_kernel(); - rc = fsfilt_ext3_set_xattr(inode, handle, XATTR_LUSTRE_MDS_SID_EA, - sid, sid_size); - return rc; -} + /* This gives us the MD size */ + if (lmm == NULL) + return (rc == -ENODATA) ? 0 : rc; -/* Must be called with i_sem held */ -static int fsfilt_ext3_get_sid(struct inode *inode, void *sid, int sid_size) -{ - int rc; + if (rc < 0) { + CDEBUG(D_INFO, "error getting EA %d/%s from inode %lu: rc %d\n", + EXT3_XATTR_INDEX_TRUSTED, XATTR_LUSTRE_MDS_LOV_EA, + inode->i_ino, rc); + memset(lmm, 0, lmm_size); + return (rc == -ENODATA) ? 0 : rc; + } - rc = fsfilt_ext3_get_xattr(inode, XATTR_LUSTRE_MDS_SID_EA, - sid, sid_size); return rc; } @@ -660,7 +602,7 @@ static void fsfilt_ext3_cb_func(struct journal_callback *jcb, int error) { struct fsfilt_cb_data *fcb = (struct fsfilt_cb_data *)jcb; - fcb->cb_func(fcb->cb_obd, fcb->cb_last_num, fcb->cb_data, error); + fcb->cb_func(fcb->cb_obd, fcb->cb_last_rcvd, fcb->cb_data, error); OBD_SLAB_FREE(fcb, fcb_cache, sizeof *fcb); atomic_dec(&fcb_cache_count); @@ -668,8 +610,8 @@ static void fsfilt_ext3_cb_func(struct journal_callback *jcb, int error) static int fsfilt_ext3_add_journal_cb(struct obd_device *obd, struct super_block *sb, - __u64 last_num, void *handle, - fsfilt_cb_t cb_func, + __u64 last_rcvd, + void *handle, fsfilt_cb_t cb_func, void *cb_data) { struct fsfilt_cb_data *fcb; @@ -681,11 +623,10 @@ static int fsfilt_ext3_add_journal_cb(struct obd_device *obd, atomic_inc(&fcb_cache_count); fcb->cb_func = cb_func; fcb->cb_obd = obd; - fcb->cb_last_num = last_num; + fcb->cb_last_rcvd = last_rcvd; fcb->cb_data = cb_data; - CDEBUG(D_EXT2, "set callback for last_num: "LPD64"\n", last_num); - + CDEBUG(D_EXT2, "set callback for last_rcvd: "LPD64"\n", last_rcvd); lock_kernel(); journal_callback_set(handle, fsfilt_ext3_cb_func, (struct journal_callback *)fcb); @@ -1093,7 +1034,7 @@ static int fsfilt_ext3_write_record(struct file *file, void *buf, int bufsize, loff_t new_size = inode->i_size; journal_t *journal; handle_t *handle; - int err = 0, block_count = 0, blocksize, size, boffs; + int err, block_count = 0, blocksize, size, boffs; /* Determine how many transaction credits are needed */ blocksize = 1 << inode->i_blkbits; @@ -1224,12 +1165,11 @@ extern int ext3_add_dir_entry(struct dentry *dentry); extern int ext3_del_dir_entry(struct dentry *dentry); static int fsfilt_ext3_add_dir_entry(struct obd_device *obd, - struct dentry *parent, - char *name, int namelen, - unsigned long ino, - unsigned long generation, - unsigned long mds, - unsigned long fid) + struct dentry *parent, + char *name, int namelen, + unsigned long ino, + unsigned long generation, + unsigned mds) { #ifdef EXT3_FEATURE_INCOMPAT_MDSNUM struct dentry *dentry; @@ -1260,7 +1200,6 @@ static int fsfilt_ext3_add_dir_entry(struct obd_device *obd, dentry->d_inum = ino; dentry->d_mdsnum = mds; dentry->d_generation = generation; - dentry->d_fid = fid; lock_kernel(); err = ext3_add_dir_entry(dentry); unlock_kernel(); @@ -1291,6 +1230,45 @@ static int fsfilt_ext3_del_dir_entry(struct obd_device *obd, #endif } +static int fsfilt_ext3_set_xattr(struct inode * inode, void *handle, char *name, + void *buffer, int buffer_size) +{ + int rc = 0; + + lock_kernel(); + + rc = ext3_xattr_set_handle(handle, inode, EXT3_XATTR_INDEX_TRUSTED, + name, buffer, buffer_size, 0); + unlock_kernel(); + if (rc) + CERROR("set xattr %s from inode %lu: rc %d\n", + name, inode->i_ino, rc); + return rc; +} + +static int fsfilt_ext3_get_xattr(struct inode *inode, char *name, + void *buffer, int buffer_size) +{ + int rc = 0; + + lock_kernel(); + + rc = ext3_xattr_get(inode, EXT3_XATTR_INDEX_TRUSTED, + name, buffer, buffer_size); + unlock_kernel(); + + if (buffer == NULL) + return (rc == -ENODATA) ? 0 : rc; + if (rc < 0) { + CDEBUG(D_INFO, "error getting EA %s from inode %lu: rc %d\n", + name, inode->i_ino, rc); + memset(buffer, 0, buffer_size); + return (rc == -ENODATA) ? 0 : rc; + } + + return rc; +} + /* If fso is NULL, op is FSFILT operation, otherwise op is number of fso objects. Logs is number of logfiles to update */ static int fsfilt_ext3_get_op_len(int op, struct fsfilt_objinfo *fso, int logs) @@ -1385,37 +1363,33 @@ static int fsfilt_ext3_get_write_extents_num(struct inode *inode, int *size) } static struct fsfilt_operations fsfilt_ext3_ops = { - .fs_type = "ext3", - .fs_owner = THIS_MODULE, - .fs_start = fsfilt_ext3_start, - .fs_brw_start = fsfilt_ext3_brw_start, - .fs_commit = fsfilt_ext3_commit, - .fs_commit_async = fsfilt_ext3_commit_async, - .fs_commit_wait = fsfilt_ext3_commit_wait, - .fs_setattr = fsfilt_ext3_setattr, - .fs_iocontrol = fsfilt_ext3_iocontrol, - .fs_set_md = fsfilt_ext3_set_md, - .fs_get_md = fsfilt_ext3_get_md, - .fs_set_mid = fsfilt_ext3_set_mid, - .fs_get_mid = fsfilt_ext3_get_mid, - .fs_set_sid = fsfilt_ext3_set_sid, - .fs_get_sid = fsfilt_ext3_get_sid, - .fs_readpage = fsfilt_ext3_readpage, - .fs_add_journal_cb = fsfilt_ext3_add_journal_cb, - .fs_statfs = fsfilt_ext3_statfs, - .fs_sync = fsfilt_ext3_sync, - .fs_map_inode_pages = fsfilt_ext3_map_inode_pages, - .fs_prep_san_write = fsfilt_ext3_prep_san_write, - .fs_write_record = fsfilt_ext3_write_record, - .fs_read_record = fsfilt_ext3_read_record, - .fs_setup = fsfilt_ext3_setup, - .fs_getpage = fsfilt_ext3_getpage, - .fs_send_bio = fsfilt_ext3_send_bio, - .fs_set_xattr = fsfilt_ext3_set_xattr, - .fs_get_xattr = fsfilt_ext3_get_xattr, - .fs_get_op_len = fsfilt_ext3_get_op_len, - .fs_add_dir_entry = fsfilt_ext3_add_dir_entry, - .fs_del_dir_entry = fsfilt_ext3_del_dir_entry, + .fs_type = "ext3", + .fs_owner = THIS_MODULE, + .fs_start = fsfilt_ext3_start, + .fs_brw_start = fsfilt_ext3_brw_start, + .fs_commit = fsfilt_ext3_commit, + .fs_commit_async = fsfilt_ext3_commit_async, + .fs_commit_wait = fsfilt_ext3_commit_wait, + .fs_setattr = fsfilt_ext3_setattr, + .fs_iocontrol = fsfilt_ext3_iocontrol, + .fs_set_md = fsfilt_ext3_set_md, + .fs_get_md = fsfilt_ext3_get_md, + .fs_readpage = fsfilt_ext3_readpage, + .fs_add_journal_cb = fsfilt_ext3_add_journal_cb, + .fs_statfs = fsfilt_ext3_statfs, + .fs_sync = fsfilt_ext3_sync, + .fs_map_inode_pages = fsfilt_ext3_map_inode_pages, + .fs_prep_san_write = fsfilt_ext3_prep_san_write, + .fs_write_record = fsfilt_ext3_write_record, + .fs_read_record = fsfilt_ext3_read_record, + .fs_setup = fsfilt_ext3_setup, + .fs_getpage = fsfilt_ext3_getpage, + .fs_send_bio = fsfilt_ext3_send_bio, + .fs_set_xattr = fsfilt_ext3_set_xattr, + .fs_get_xattr = fsfilt_ext3_get_xattr, + .fs_get_op_len = fsfilt_ext3_get_op_len, + .fs_add_dir_entry = fsfilt_ext3_add_dir_entry, + .fs_del_dir_entry = fsfilt_ext3_del_dir_entry, .fs_init_extents_ea = fsfilt_ext3_init_extents_ea, .fs_insert_extents_ea = fsfilt_ext3_insert_extents_ea, .fs_remove_extents_ea = fsfilt_ext3_remove_extents_ea, diff --git a/lustre/lvfs/fsfilt_smfs.c b/lustre/lvfs/fsfilt_smfs.c index b0b77b1..b64cf91 100644 --- a/lustre/lvfs/fsfilt_smfs.c +++ b/lustre/lvfs/fsfilt_smfs.c @@ -241,12 +241,8 @@ static int fsfilt_smfs_iocontrol(struct inode *inode, struct file *file, RETURN(rc); } -typedef int (*set_ea_func_t) (struct inode *, void *, void *, int); -typedef int (*get_ea_func_t) (struct inode *, void *, int); - -static int fsfilt_smfs_set_ea(struct inode *inode, void *handle, - void *ea, int ea_size, - set_ea_func_t set_ea_func) +static int fsfilt_smfs_set_md(struct inode *inode, void *handle, + void *lmm, int lmm_size) { struct fsfilt_operations *cache_fsfilt = I2FOPS(inode); struct inode *cache_inode = NULL; @@ -260,22 +256,24 @@ static int fsfilt_smfs_set_ea(struct inode *inode, void *handle, if (!cache_inode) RETURN(-ENOENT); - if (!set_ea_func) - RETURN(-ENOSYS); - pre_smfs_inode(inode, cache_inode); + if (!cache_fsfilt->fs_set_md) + RETURN(-ENOSYS); + down(&cache_inode->i_sem); - rc = set_ea_func(cache_inode, handle, ea, ea_size); + rc = cache_fsfilt->fs_set_md(cache_inode, handle, lmm, lmm_size); up(&cache_inode->i_sem); post_smfs_inode(inode, cache_inode); + smfs_rec_md(inode, lmm, lmm_size); + RETURN(rc); } -static int fsfilt_smfs_get_ea(struct inode *inode, void *ea, - int ea_size, get_ea_func_t get_ea_func) +/* Must be called with i_sem held */ +static int fsfilt_smfs_get_md(struct inode *inode, void *lmm, int lmm_size) { struct fsfilt_operations *cache_fsfilt = I2FOPS(inode); struct inode *cache_inode = NULL; @@ -289,13 +287,13 @@ static int fsfilt_smfs_get_ea(struct inode *inode, void *ea, if (!cache_inode) RETURN(-ENOENT); - if (!get_ea_func) - RETURN(-ENOSYS); - pre_smfs_inode(inode, cache_inode); + if (!cache_fsfilt->fs_get_md) + RETURN(-ENOSYS); + down(&cache_inode->i_sem); - rc = get_ea_func(cache_inode, ea, ea_size); + rc = cache_fsfilt->fs_get_md(cache_inode, lmm, lmm_size); up(&cache_inode->i_sem); post_smfs_inode(inode, cache_inode); @@ -303,61 +301,6 @@ static int fsfilt_smfs_get_ea(struct inode *inode, void *ea, RETURN(rc); } -static int fsfilt_smfs_set_md(struct inode *inode, void *handle, - void *lmm, int lmm_size) -{ - int rc = 0; - struct fsfilt_operations *cache_fsfilt = I2FOPS(inode); - - rc = fsfilt_smfs_set_ea(inode, handle, lmm, lmm_size, - cache_fsfilt->fs_set_md); - if (rc) - return rc; - - smfs_rec_md(inode, lmm, lmm_size); - return rc; -} - -static int fsfilt_smfs_get_md(struct inode *inode, void *lmm, int - lmm_size) -{ - struct fsfilt_operations *cache_fsfilt = I2FOPS(inode); - return fsfilt_smfs_get_ea(inode, lmm, lmm_size, - cache_fsfilt->fs_get_md); -} - -static int fsfilt_smfs_set_mid(struct inode *inode, void *handle, - void *mid, int mid_size) -{ - struct fsfilt_operations *cache_fsfilt = I2FOPS(inode); - return fsfilt_smfs_set_ea(inode, handle, mid, mid_size, - cache_fsfilt->fs_set_mid); -} - -static int fsfilt_smfs_get_mid(struct inode *inode, void *mid, - int mid_size) -{ - struct fsfilt_operations *cache_fsfilt = I2FOPS(inode); - return fsfilt_smfs_get_ea(inode, mid, mid_size, - cache_fsfilt->fs_get_mid); -} - -static int fsfilt_smfs_set_sid(struct inode *inode, void *handle, - void *sid, int sid_size) -{ - struct fsfilt_operations *cache_fsfilt = I2FOPS(inode); - return fsfilt_smfs_set_ea(inode, handle, sid, sid_size, - cache_fsfilt->fs_set_sid); -} - -static int fsfilt_smfs_get_sid(struct inode *inode, void *sid, - int sid_size) -{ - struct fsfilt_operations *cache_fsfilt = I2FOPS(inode); - return fsfilt_smfs_get_ea(inode, sid, sid_size, - cache_fsfilt->fs_get_sid); -} - static int fsfilt_smfs_send_bio(int rw, struct inode *inode, struct kiobuf *bio) { struct inode *cache_inode; @@ -1061,10 +1004,6 @@ static struct fsfilt_operations fsfilt_smfs_ops = { .fs_iocontrol = fsfilt_smfs_iocontrol, .fs_set_md = fsfilt_smfs_set_md, .fs_get_md = fsfilt_smfs_get_md, - .fs_set_mid = fsfilt_smfs_set_mid, - .fs_get_mid = fsfilt_smfs_get_mid, - .fs_set_sid = fsfilt_smfs_set_sid, - .fs_get_sid = fsfilt_smfs_get_sid, .fs_readpage = fsfilt_smfs_readpage, .fs_getpage = fsfilt_smfs_getpage, .fs_add_journal_cb = fsfilt_smfs_add_journal_cb, @@ -1077,9 +1016,9 @@ static struct fsfilt_operations fsfilt_smfs_ops = { .fs_setup = fsfilt_smfs_setup, .fs_post_setup = fsfilt_smfs_post_setup, .fs_post_cleanup = fsfilt_smfs_post_cleanup, - .fs_set_fs_flags = fsfilt_smfs_set_fs_flags, - .fs_clear_fs_flags = fsfilt_smfs_clear_fs_flags, - .fs_get_fs_flags = fsfilt_smfs_get_fs_flags, + .fs_set_fs_flags = fsfilt_smfs_set_fs_flags, + .fs_clear_fs_flags = fsfilt_smfs_clear_fs_flags, + .fs_get_fs_flags = fsfilt_smfs_get_fs_flags, .fs_set_ost_flags = fsfilt_smfs_set_ost_flags, .fs_set_mds_flags = fsfilt_smfs_set_mds_flags, .fs_precreate_rec = fsfilt_smfs_precreate_rec, @@ -1095,6 +1034,8 @@ static struct fsfilt_operations fsfilt_smfs_ops = { .fs_write_extents = fsfilt_smfs_write_extents, .fs_set_snap_item = fsfilt_smfs_set_snap_item, .fs_do_write_cow = fsfilt_smfs_do_write_cow, + /* FIXME-UMKA: probably fsfilt_smfs_get_op_len() should be + * put here too. */ }; static int __init fsfilt_smfs_init(void) diff --git a/lustre/lvfs/llog_lvfs.c b/lustre/lvfs/llog_lvfs.c index 1b533f4..1aa8be9 100644 --- a/lustre/lvfs/llog_lvfs.c +++ b/lustre/lvfs/llog_lvfs.c @@ -517,15 +517,12 @@ llog_object_create_alone(struct llog_ctxt *ctxt, struct llog_logid *lgh_id) LASSERT(lgh_id != NULL); if (lgh_id->lgl_oid) { struct dentry *dchild; - char id_name[LL_ID_NAMELEN]; - int id_len = 0; + char fidname[LL_FID_NAMELEN]; + int fidlen = 0; down(&ctxt->loc_objects_dir->d_inode->i_sem); - id_len = ll_id2str(id_name, lgh_id->lgl_oid, - lgh_id->lgl_ogen); - - dchild = lookup_one_len(id_name, ctxt->loc_objects_dir, - id_len); + fidlen = ll_fid2str(fidname, lgh_id->lgl_oid, lgh_id->lgl_ogen); + dchild = lookup_one_len(fidname, ctxt->loc_objects_dir, fidlen); if (IS_ERR(dchild)) { up(&ctxt->loc_objects_dir->d_inode->i_sem); RETURN((struct file *)dchild); @@ -564,8 +561,8 @@ llog_object_create_alone(struct llog_ctxt *ctxt, struct llog_logid *lgh_id) RETURN(filp); } if (!S_ISREG(filp->f_dentry->d_inode->i_mode)) { - CERROR("%s is not a regular file!: mode = %o\n", - id_name, filp->f_dentry->d_inode->i_mode); + CERROR("%s is not a regular file!: mode = %o\n", fidname, + filp->f_dentry->d_inode->i_mode); filp_close(filp, 0); up(&ctxt->loc_objects_dir->d_inode->i_sem); RETURN(ERR_PTR(-ENOENT)); @@ -576,13 +573,13 @@ llog_object_create_alone(struct llog_ctxt *ctxt, struct llog_logid *lgh_id) } else { unsigned int tmpname = ll_insecure_random_int(); - char id_name[LL_ID_NAMELEN]; + char fidname[LL_FID_NAMELEN]; struct dentry *new_child, *parent; - int err, id_len; void *handle; + int err, namelen; - sprintf(id_name, "OBJECTS/%u", tmpname); - filp = filp_open(id_name, O_CREAT | O_EXCL, 0644); + sprintf(fidname, "OBJECTS/%u", tmpname); + filp = filp_open(fidname, O_CREAT | O_EXCL, 0644); if (IS_ERR(filp)) { rc = PTR_ERR(filp); if (rc == -EEXIST) { @@ -594,11 +591,11 @@ llog_object_create_alone(struct llog_ctxt *ctxt, struct llog_logid *lgh_id) RETURN(filp); } - id_len = ll_id2str(id_name, filp->f_dentry->d_inode->i_ino, - filp->f_dentry->d_inode->i_generation); + namelen = ll_fid2str(fidname, filp->f_dentry->d_inode->i_ino, + filp->f_dentry->d_inode->i_generation); parent = filp->f_dentry->d_parent; down(&parent->d_inode->i_sem); - new_child = lookup_one_len(id_name, parent, id_len); + new_child = lookup_one_len(fidname, parent, namelen); if (IS_ERR(new_child)) { CERROR("getting neg dentry for obj rename: %d\n", rc); GOTO(out_close, rc = PTR_ERR(new_child)); @@ -660,8 +657,8 @@ llog_object_create_generic(struct llog_ctxt *ctxt, struct llog_logid *lgh_id) LASSERT(obd != NULL); if (lgh_id->lgl_oid) { - dchild = obd_lvfs_id2dentry(ctxt->loc_exp, lgh_id->lgl_oid, - lgh_id->lgl_ogen, lgh_id->lgl_ogr); + dchild = obd_lvfs_fid2dentry(ctxt->loc_exp, lgh_id->lgl_oid, + lgh_id->lgl_ogen, lgh_id->lgl_ogr); if (IS_ERR(dchild) == -ENOENT) { OBD_ALLOC(oa, sizeof(*oa)); if (!oa) @@ -679,8 +676,8 @@ llog_object_create_generic(struct llog_ctxt *ctxt, struct llog_logid *lgh_id) CDEBUG(D_HA, "re-create log object "LPX64":0x%x:"LPX64"\n", lgh_id->lgl_oid, lgh_id->lgl_ogen, lgh_id->lgl_ogr); - dchild = obd_lvfs_id2dentry(ctxt->loc_exp, lgh_id->lgl_oid, - lgh_id->lgl_ogen, lgh_id->lgl_ogr); + dchild = obd_lvfs_fid2dentry(ctxt->loc_exp, lgh_id->lgl_oid, + lgh_id->lgl_ogen, lgh_id->lgl_ogr); } else if (IS_ERR(dchild)) { CERROR("error looking up logfile "LPX64":0x%x: rc %d\n", lgh_id->lgl_oid, lgh_id->lgl_ogen, rc); @@ -710,8 +707,8 @@ llog_object_create_generic(struct llog_ctxt *ctxt, struct llog_logid *lgh_id) if (rc) GOTO(out_free_oa, rc); - dchild = obd_lvfs_id2dentry(ctxt->loc_exp, oa->o_id, - oa->o_generation, oa->o_gr); + dchild = obd_lvfs_fid2dentry(ctxt->loc_exp, oa->o_id, + oa->o_generation, oa->o_gr); if (IS_ERR(dchild)) GOTO(out_free_oa, rc = PTR_ERR(dchild)); @@ -750,14 +747,14 @@ static int llog_add_link_object(struct llog_ctxt *ctxt, struct llog_logid logid, struct dentry *dentry) { struct dentry *new_child; - char id_name[LL_ID_NAMELEN]; + char fidname[LL_FID_NAMELEN]; void *handle; - int id_len, rc = 0, err; + int namelen, rc = 0, err; ENTRY; - id_len = ll_id2str(id_name, logid.lgl_oid, logid.lgl_ogen); + namelen = ll_fid2str(fidname, logid.lgl_oid, logid.lgl_ogen); down(&ctxt->loc_objects_dir->d_inode->i_sem); - new_child = lookup_one_len(id_name, ctxt->loc_objects_dir, id_len); + new_child = lookup_one_len(fidname, ctxt->loc_objects_dir, namelen); if (IS_ERR(new_child)) { CERROR("getting neg dentry for obj rename: %d\n", rc); GOTO(out, rc = PTR_ERR(new_child)); @@ -876,9 +873,9 @@ static int llog_lvfs_destroy(struct llog_handle *loghandle) struct lvfs_run_ctxt saved; struct dentry *fdentry; struct inode *parent_inode; - char id_name[LL_ID_NAMELEN]; + char fidname[LL_FID_NAMELEN]; void *handle; - int rc = -EINVAL, err, id_len; + int rc = -EINVAL, err, namelen; ENTRY; if (ctxt->loc_lvfs_ctxt) @@ -890,8 +887,8 @@ static int llog_lvfs_destroy(struct llog_handle *loghandle) if (!strcmp(fdentry->d_parent->d_name.name, "LOGS")) { LASSERT(parent_inode == ctxt->loc_logs_dir->d_inode); - id_len = ll_id2str(id_name, fdentry->d_inode->i_ino, - fdentry->d_inode->i_generation); + namelen = ll_fid2str(fidname, fdentry->d_inode->i_ino, + fdentry->d_inode->i_generation); dget(fdentry); rc = llog_lvfs_close(loghandle); if (rc) { @@ -913,11 +910,10 @@ static int llog_lvfs_destroy(struct llog_handle *loghandle) if (!rc) { down(&ctxt->loc_objects_dir->d_inode->i_sem); - fdentry = lookup_one_len(id_name, ctxt->loc_objects_dir, - id_len); + fdentry = lookup_one_len(fidname, ctxt->loc_objects_dir, + namelen); if (fdentry == NULL || fdentry->d_inode == NULL) { - CERROR("destroy non_existent object %s\n", - id_name); + CERROR("destroy non_existent object %s\n", fidname); GOTO(out_err, rc = IS_ERR(fdentry) ? PTR_ERR(fdentry) : -ENOENT); } diff --git a/lustre/lvfs/lvfs_common.c b/lustre/lvfs/lvfs_common.c index caa6e01..d8ab4a3 100644 --- a/lustre/lvfs/lvfs_common.c +++ b/lustre/lvfs/lvfs_common.c @@ -27,9 +27,9 @@ #include -struct dentry *lvfs_id2dentry(struct lvfs_run_ctxt *ctxt, __u64 id, - __u32 gen, __u64 gr, void *data) +struct dentry *lvfs_fid2dentry(struct lvfs_run_ctxt *ctxt, __u64 id, + __u32 gen, __u64 gr, void *data) { - return ctxt->cb_ops.l_id2dentry(id, gen, gr, data); + return ctxt->cb_ops.l_fid2dentry(id, gen, gr, data); } -EXPORT_SYMBOL(lvfs_id2dentry); +EXPORT_SYMBOL(lvfs_fid2dentry); diff --git a/lustre/mdc/mdc_internal.h b/lustre/mdc/mdc_internal.h index 57e8d5d..702d3c7 100644 --- a/lustre/mdc/mdc_internal.h +++ b/lustre/mdc/mdc_internal.h @@ -27,7 +27,7 @@ void mdc_open_pack(struct lustre_msg *msg, int offset, struct mdc_op_data *op_data, __u32 mode, __u64 rdev, __u32 flags, const void *lmm, int lmmlen); void mdc_readdir_pack(struct ptlrpc_request *req, int req_offset, - __u64 offset, __u32 size, struct lustre_id *mdc_id); + __u64 offset, __u32 size, struct ll_fid *mdc_fid); void mdc_close_pack(struct ptlrpc_request *req, int offset, struct obdo *oa, int valid, struct obd_client_handle *och); diff --git a/lustre/mdc/mdc_lib.c b/lustre/mdc/mdc_lib.c index 7658bc5..74d3030 100644 --- a/lustre/mdc/mdc_lib.c +++ b/lustre/mdc/mdc_lib.c @@ -40,12 +40,12 @@ #endif void mdc_readdir_pack(struct ptlrpc_request *req, int req_offset, - __u64 offset, __u32 size, struct lustre_id *mdc_id) + __u64 offset, __u32 size, struct ll_fid *mdc_fid) { struct mds_body *b; b = lustre_msg_buf(req->rq_reqmsg, req_offset, sizeof (*b)); - b->id1 = *mdc_id; + b->fid1 = *mdc_fid; b->size = offset; /* !! */ b->nlink = size; /* !! */ } @@ -64,7 +64,6 @@ static __u32 mds_pack_open_flags(__u32 flags) ((flags & O_DIRECTORY) ? MDS_OPEN_DIRECTORY : 0) | 0; } - /* packing of MDS records */ void mdc_open_pack(struct lustre_msg *msg, int offset, struct mdc_op_data *op_data, __u32 mode, __u64 rdev, @@ -77,8 +76,8 @@ void mdc_open_pack(struct lustre_msg *msg, int offset, /* XXX do something about time, uid, gid */ rec->cr_opcode = REINT_OPEN; if (op_data != NULL) - rec->cr_id = op_data->id1; - memset(&rec->cr_replayid, 0, sizeof(rec->cr_replayid)); + rec->cr_fid = op_data->fid1; + memset(&rec->cr_replayfid, 0, sizeof(rec->cr_replayfid)); rec->cr_mode = mode; rec->cr_flags = mds_pack_open_flags(flags); rec->cr_rdev = rdev; @@ -106,8 +105,8 @@ void mdc_getattr_pack(struct lustre_msg *msg, int offset, int valid, b->valid = valid; b->flags = flags; - b->id1 = data->id1; - b->id2 = data->id2; + b->fid1 = data->fid1; + b->fid2 = data->fid2; if (data->name) { char *tmp; tmp = lustre_msg_buf(msg, offset + 1, @@ -122,8 +121,8 @@ void mdc_close_pack(struct ptlrpc_request *req, int offset, struct obdo *oa, struct mds_body *body; body = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*body)); - mdc_pack_id(&body->id1, oa->o_id, 0, oa->o_mode, 0, 0); + mdc_pack_fid(&body->fid1, oa->o_id, 0, oa->o_mode); memcpy(&body->handle, &och->och_fh, sizeof(body->handle)); if (oa->o_valid & OBD_MD_FLATIME) { body->atime = oa->o_atime; diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index ad5b95f..7998565 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -36,6 +36,8 @@ #include #include #include +//#include +//#include #include #include "mdc_internal.h" @@ -51,20 +53,18 @@ void it_set_disposition(struct lookup_intent *it, int flag) } EXPORT_SYMBOL(it_set_disposition); -static void mdc_id2mdc_op_data(struct mdc_op_data *data, - struct lustre_id *f1, - struct lustre_id *f2, - const char *name, - int namelen, int mode) +static void mdc_fid2mdc_op_data(struct mdc_op_data *data, + struct ll_fid *f1, struct ll_fid *f2, + const char *name, int namelen, int mode) { LASSERT(data); LASSERT(f1); - data->id1 = *f1; + data->fid1 = *f1; if (f2) - data->id2 = *f2; - - data->valid = 0; + data->fid2 = *f2; + else + memset(&data->fid2, 0, sizeof(data->fid2)); data->name = name; data->namelen = namelen; data->create_mode = mode; @@ -144,8 +144,8 @@ int mdc_set_lock_data(struct obd_export *exp, __u64 *l, void *data) "Found existing inode %p/%lu/%u state %lu in lock: " "setting data to %p/%lu/%u\n", old_inode, old_inode->i_ino, old_inode->i_generation, - old_inode->i_state, new_inode, new_inode->i_ino, - new_inode->i_generation); + old_inode->i_state, + new_inode, new_inode->i_ino, new_inode->i_generation); } #endif lock->l_ast_data = data; @@ -157,17 +157,17 @@ int mdc_set_lock_data(struct obd_export *exp, __u64 *l, void *data) } EXPORT_SYMBOL(mdc_set_lock_data); -int mdc_change_cbdata(struct obd_export *exp, struct lustre_id *id, +int mdc_change_cbdata(struct obd_export *exp, struct ll_fid *fid, ldlm_iterator_t it, void *data) { struct ldlm_res_id res_id = { .name = {0} }; ENTRY; - res_id.name[0] = id_fid(id); - res_id.name[1] = id_group(id); + res_id.name[0] = fid->id; + res_id.name[1] = fid->generation; - ldlm_change_cbdata(class_exp2obd(exp)->obd_namespace, - &res_id, it, data); + ldlm_change_cbdata(class_exp2obd(exp)->obd_namespace, &res_id, it, + data); EXIT; return 0; @@ -188,10 +188,9 @@ int mdc_enqueue(struct obd_export *exp, void *cb_data) { struct ptlrpc_request *req; - struct ldlm_res_id res_id = { - .name = {id_fid(&data->id1), id_group(&data->id1)} - }; struct obd_device *obddev = class_exp2obd(exp); + struct ldlm_res_id res_id = + { .name = {data->fid1.id, data->fid1.generation} }; ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_LOOKUP } }; struct ldlm_intent *lit; struct ldlm_request *lockreq; @@ -243,14 +242,13 @@ int mdc_enqueue(struct obd_export *exp, reply_buffers = 3; req->rq_replen = lustre_msg_size(3, repsize); } else if (it->it_op & (IT_GETATTR | IT_LOOKUP | IT_CHDIR)) { - int valid = data->valid | OBD_MD_FLNOTOBD | OBD_MD_FLEASIZE; + int valid = OBD_MD_FLNOTOBD | OBD_MD_FLEASIZE; reqsize[req_buffers++] = sizeof(struct mds_body); reqsize[req_buffers++] = data->namelen + 1; if (it->it_op & IT_GETATTR) policy.l_inodebits.bits = MDS_INODELOCK_UPDATE; - req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_DLM_VERSION, LDLM_ENQUEUE, req_buffers, reqsize, NULL); @@ -265,7 +263,6 @@ int mdc_enqueue(struct obd_export *exp, /* pack the intended request */ mdc_getattr_pack(req->rq_reqmsg, MDS_REQ_INTENT_REC_OFF, valid, it->it_flags, data); - /* get ready for the reply */ reply_buffers = 3; req->rq_replen = lustre_msg_size(3, repsize); @@ -438,42 +435,43 @@ EXPORT_SYMBOL(mdc_enqueue); * Else, if DISP_LOOKUP_EXECD then d.lustre.it_status is the rc of the * child lookup. */ -int mdc_intent_lock(struct obd_export *exp, struct lustre_id *pid, - const char *name, int len, void *lmm, int lmmsize, - struct lustre_id *cid, struct lookup_intent *it, - int lookup_flags, struct ptlrpc_request **reqp, +int mdc_intent_lock(struct obd_export *exp, + struct ll_fid *pfid, const char *name, int len, + void *lmm, int lmmsize, struct ll_fid *cfid, + struct lookup_intent *it, int lookup_flags, + struct ptlrpc_request **reqp, ldlm_blocking_callback cb_blocking) { struct lustre_handle lockh; struct ptlrpc_request *request; + int rc = 0; struct mds_body *mds_body; struct lustre_handle old_lock; struct ldlm_lock *lock; - int rc = 0; ENTRY; LASSERT(it); - CDEBUG(D_DLMTRACE, "name: %*s in obj "DLID4", intent: %s flags %#o\n", - len, name, OLID4(pid), ldlm_it2str(it->it_op), it->it_flags); + CDEBUG(D_DLMTRACE, "name: %*s in inode "LPU64", intent: %s flags %#o\n", + len, name, pfid->id, ldlm_it2str(it->it_op), it->it_flags); - if (cid && (it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR || - it->it_op == IT_CHDIR)) { + if (cfid && (it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR || + it->it_op == IT_CHDIR)) { /* We could just return 1 immediately, but since we should only * be called in revalidate_it if we already have a lock, let's * verify that. */ - struct ldlm_res_id res_id = {.name = {id_fid(cid), - id_group(cid)}}; + struct ldlm_res_id res_id ={.name = {cfid->id, + cfid->generation}}; struct lustre_handle lockh; ldlm_policy_data_t policy; int mode = LCK_PR; /* For the GETATTR case, ll_revalidate_it issues two separate - queries - for LOOKUP and for UPDATE lock because it cannot + queries - for LOOKUP and for UPDATE lock because if cannot check them together - we might have those two bits to be present in two separate granted locks */ - policy.l_inodebits.bits = (it->it_op == IT_GETATTR) ? - MDS_INODELOCK_UPDATE: MDS_INODELOCK_LOOKUP; - + policy.l_inodebits.bits = + (it->it_op == IT_GETATTR)?MDS_INODELOCK_UPDATE: + MDS_INODELOCK_LOOKUP; mode = LCK_PR; rc = ldlm_lock_match(exp->exp_obd->obd_namespace, LDLM_FL_BLOCK_GRANTED, &res_id, @@ -507,23 +505,13 @@ int mdc_intent_lock(struct obd_export *exp, struct lustre_id *pid, * never dropped its reference, so the refcounts are all OK */ if (!it_disposition(it, DISP_ENQ_COMPLETE)) { struct mdc_op_data op_data; - - mdc_id2mdc_op_data(&op_data, pid, cid, name, len, 0); - - /* - * if we getting inode by name (ll_lookup_it() case), we always - * should ask for fid, as later we will not be able to take - * locks, revalidate dentry, etc. with invalid fid in inode. - */ - if (cid == NULL && name != NULL) - op_data.valid |= OBD_MD_FID; + mdc_fid2mdc_op_data(&op_data, pfid, cfid, name, len, 0); rc = mdc_enqueue(exp, LDLM_IBITS, it, it_to_lock_mode(it), &op_data, &lockh, lmm, lmmsize, ldlm_completion_ast, cb_blocking, NULL); if (rc < 0) RETURN(rc); - memcpy(&it->d.lustre.it_lock_handle, &lockh, sizeof(lockh)); } request = *reqp = it->d.lustre.it_data; @@ -557,21 +545,20 @@ int mdc_intent_lock(struct obd_export *exp, struct lustre_id *pid, RETURN(rc); mds_body = lustre_msg_buf(request->rq_repmsg, 1, sizeof(*mds_body)); - LASSERT(mds_body != NULL); /* mdc_enqueue checked */ + LASSERT(mds_body != NULL); /* mdc_enqueue checked */ LASSERT_REPSWABBED(request, 1); /* mdc_enqueue swabbed */ - /* If we were revalidating a fid/name pair, mark the intent in case we - * fail and get called again from lookup */ - if (cid != NULL) { + /* If we were revalidating a fid/name pair, mark the intent in + * case we fail and get called again from lookup */ + if (cfid != NULL) { it_set_disposition(it, DISP_ENQ_COMPLETE); /* Also: did we find the same inode? */ - - /* we have to compare all the fields but type, because MDS can - * return fid/mds/ino/gen if inode lives on another MDS -bzzz */ - if (id_gen(cid) != id_gen(&mds_body->id1) || - id_ino(cid) != id_ino(&mds_body->id1) || - id_fid(cid) != id_fid(&mds_body->id1) || - id_group(cid) != id_group(&mds_body->id1)) + /* we have to compare all the fields but type, because + * MDS can return mds/ino/generation triple if inode + * lives on another MDS -bzzz */ + if (cfid->generation != mds_body->fid1.generation || + cfid->id != mds_body->fid1.id || + cfid->mds != mds_body->fid1.mds) RETURN(-ESTALE); } @@ -579,9 +566,8 @@ int mdc_intent_lock(struct obd_export *exp, struct lustre_id *pid, if (rc) RETURN(rc); - /* - * keep requests around for the multiple phases of the call this shows - * the DISP_XX must guarantee we make it into the call. + /* keep requests around for the multiple phases of the call + * this shows the DISP_XX must guarantee we make it into the call */ if (it_disposition(it, DISP_OPEN_CREATE) && !it_open_error(DISP_OPEN_CREATE, it)) @@ -598,27 +584,16 @@ int mdc_intent_lock(struct obd_export *exp, struct lustre_id *pid, LASSERT(it->it_op & (IT_GETATTR | IT_LOOKUP | IT_CHDIR)); } - /* - * if we already have a matching lock, then cancel the new one. We have - * to set the data here instead of in mdc_enqueue, because we need to - * use the child's inode as the l_ast_data to match, and that's not - * available until intent_finish has performed the iget().) - */ + /* If we already have a matching lock, then cancel the new + * one. We have to set the data here instead of in + * mdc_enqueue, because we need to use the child's inode as + * the l_ast_data to match, and that's not available until + * intent_finish has performed the iget().) */ lock = ldlm_handle2lock(&lockh); if (lock) { ldlm_policy_data_t policy = lock->l_policy_data; LDLM_DEBUG(lock, "matching against this"); LDLM_LOCK_PUT(lock); - - LASSERTF(id_fid(&mds_body->id1) == lock->l_resource->lr_name.name[0] && - id_group(&mds_body->id1) == lock->l_resource->lr_name.name[1], - "Invalid lock is returned to client. Lock res_is: %lu/%lu, " - "response res_id: %lu/%lu.\n", - (unsigned long)lock->l_resource->lr_name.name[0], - (unsigned long)lock->l_resource->lr_name.name[1], - (unsigned long)id_fid(&mds_body->id1), - (unsigned long)id_group(&mds_body->id1)); - memcpy(&old_lock, &lockh, sizeof(lockh)); if (ldlm_lock_match(NULL, LDLM_FL_BLOCK_GRANTED, NULL, LDLM_IBITS, &policy, LCK_NL, &old_lock)) { diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c index 3b5d382..b34e1e1 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -36,10 +36,9 @@ #include #include "mdc_internal.h" -/* this function actually sends request to desired target. */ -static int mdc_reint(struct ptlrpc_request *request, - struct mdc_rpc_lock *rpc_lock, - int level) +/* mdc_setattr does its own semaphore handling */ +int mdc_reint(struct ptlrpc_request *request, + struct mdc_rpc_lock *rpc_lock, int level) { int rc; @@ -61,16 +60,16 @@ static int mdc_reint(struct ptlrpc_request *request, } return rc; } - -/* If mdc_setattr is called with an 'iattr', then it is a normal RPC that should - * take the normal semaphore and go to the normal portal. +EXPORT_SYMBOL(mdc_reint); +/* If mdc_setattr is called with an 'iattr', then it is a normal RPC that + * should take the normal semaphore and go to the normal portal. * - * If it is called with iattr->ia_valid & ATTR_FROM_OPEN, then it is a magic - * open-path setattr that should take the setattr semaphore and go to the - * setattr portal. */ + * If it is called with iattr->ia_valid & ATTR_FROM_OPEN, then it is a + * magic open-path setattr that should take the setattr semaphore and + * go to the setattr portal. */ int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data, - struct iattr *iattr, void *ea, int ealen, void *ea2, - int ea2len, struct ptlrpc_request **request) + struct iattr *iattr, void *ea, int ealen, void *ea2, int ea2len, + struct ptlrpc_request **request) { struct ptlrpc_request *req; struct mds_rec_setattr *rec; @@ -120,8 +119,8 @@ int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data, } int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data, - const void *data, int datalen, int mode, __u32 uid, - __u32 gid, __u64 rdev, struct ptlrpc_request **request) + const void *data, int datalen, int mode, __u32 uid, __u32 gid, + __u64 rdev, struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; struct ptlrpc_request *req; @@ -143,10 +142,8 @@ int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data, mdc_pack_secdesc(req, size[0]); - /* - * mdc_create_pack() fills msg->bufs[1] with name and msg->bufs[2] with - * tgt, for symlinks or lov MD data. - */ + /* mdc_create_pack fills msg->bufs[1] with name + * and msg->bufs[2] with tgt, for symlinks or lov MD data */ mdc_create_pack(req->rq_reqmsg, 1, op_data, mode, rdev, data, datalen); size[0] = sizeof(struct mds_body); @@ -155,8 +152,7 @@ int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data, level = LUSTRE_IMP_FULL; resend: rc = mdc_reint(req, obd->u.cli.cl_rpc_lock, level); - - /* resend if we were told to. */ + /* Resend if we were told to. */ if (rc == -ERESTARTSYS) { level = LUSTRE_IMP_RECOVER; goto resend; diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index f633ad3..4d0151a 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -45,31 +45,25 @@ static int mdc_cleanup(struct obd_device *obd, int flags); int mdc_get_secdesc_size(void) { -#ifdef __KERNEL__ int ngroups = current_ngroups; if (ngroups > LUSTRE_MAX_GROUPS) ngroups = LUSTRE_MAX_GROUPS; - return sizeof(struct mds_req_sec_desc) + - sizeof(__u32) * ngroups; -#else - return 0; -#endif + sizeof(__u32) * ngroups; } /* - * because group info might have changed since last time we call - * get_secdesc_size(), so here we did more sanity check to prevent garbage gids + * because group info might have changed since last time + * we call get_secdesc_size(), so here we did more sanity check + * to prevent garbage gids */ void mdc_pack_secdesc(struct ptlrpc_request *req, int size) { -#ifdef __KERNEL__ struct mds_req_sec_desc *rsd; + struct group_info *ginfo; - rsd = lustre_msg_buf(req->rq_reqmsg, - MDS_REQ_SECDESC_OFF, size); - + rsd = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_SECDESC_OFF, size); rsd->rsd_uid = current->uid; rsd->rsd_gid = current->gid; rsd->rsd_fsuid = current->fsuid; @@ -94,13 +88,12 @@ void mdc_pack_secdesc(struct ptlrpc_request *req, int size) memcpy(rsd->rsd_groups, current->groups, rsd->rsd_ngroups * sizeof(__u32)); #endif -#endif } extern int mds_queue_req(struct ptlrpc_request *); /* Helper that implements most of mdc_getstatus and signal_completed_replay. */ /* XXX this should become mdc_get_info("key"), sending MDS_GET_INFO RPC */ -static int send_getstatus(struct obd_import *imp, struct lustre_id *rootid, +static int send_getstatus(struct obd_import *imp, struct ll_fid *rootfid, int level, int msg_flags) { struct ptlrpc_request *req; @@ -132,11 +125,12 @@ static int send_getstatus(struct obd_import *imp, struct lustre_id *rootid, GOTO (out, rc = -EPROTO); } - memcpy(rootid, &body->id1, sizeof(*rootid)); + memcpy(rootfid, &body->fid1, sizeof(*rootfid)); CDEBUG(D_NET, "root ino="LPU64", last_committed="LPU64 - ", last_xid="LPU64"\n", rootid->li_stc.u.e3s.l3s_ino, - req->rq_repmsg->last_committed, req->rq_repmsg->last_xid); + ", last_xid="LPU64"\n", + rootfid->id, req->rq_repmsg->last_committed, + req->rq_repmsg->last_xid); } EXIT; @@ -145,11 +139,11 @@ static int send_getstatus(struct obd_import *imp, struct lustre_id *rootid, return rc; } -/* This should be mdc_get_info("rootid") */ -int mdc_getstatus(struct obd_export *exp, struct lustre_id *rootid) +/* This should be mdc_get_info("rootfid") */ +int mdc_getstatus(struct obd_export *exp, struct ll_fid *rootfid) { - return send_getstatus(class_exp2cliimp(exp), rootid, - LUSTRE_IMP_FULL, 0); + return send_getstatus(class_exp2cliimp(exp), rootfid, LUSTRE_IMP_FULL, + 0); } int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, @@ -199,7 +193,7 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, RETURN (0); } -int mdc_getattr(struct obd_export *exp, struct lustre_id *id, +int mdc_getattr(struct obd_export *exp, struct ll_fid *fid, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request) { @@ -222,7 +216,7 @@ int mdc_getattr(struct obd_export *exp, struct lustre_id *id, mdc_pack_secdesc(req, size[0]); body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body)); - memcpy(&body->id1, id, sizeof(*id)); + memcpy(&body->fid1, fid, sizeof(*fid)); body->valid = valid; body->eadatasize = ea_size; @@ -236,7 +230,7 @@ int mdc_getattr(struct obd_export *exp, struct lustre_id *id, RETURN (rc); } -int mdc_getattr_name(struct obd_export *exp, struct lustre_id *id, +int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid, char *filename, int namelen, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request) { @@ -255,7 +249,7 @@ int mdc_getattr_name(struct obd_export *exp, struct lustre_id *id, mdc_pack_secdesc(req, size[0]); body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body)); - memcpy(&body->id1, id, sizeof(*id)); + memcpy(&body->fid1, fid, sizeof(*fid)); body->valid = valid; body->eadatasize = ea_size; @@ -290,9 +284,9 @@ int mdc_store_inode_generation(struct obd_export *exp, LASSERT (rec != NULL); LASSERT (body != NULL); - memcpy(&rec->cr_replayid, &body->id1, sizeof(rec->cr_replayid)); - DEBUG_REQ(D_HA, req, "storing generation for ino "DLID4, - OLID4(&rec->cr_replayid)); + memcpy(&rec->cr_replayfid, &body->fid1, sizeof rec->cr_replayfid); + DEBUG_REQ(D_HA, req, "storing generation %u for ino "LPU64, + rec->cr_replayfid.generation, rec->cr_replayfid.id); return 0; } @@ -337,7 +331,6 @@ int mdc_req2lustre_md(struct obd_export *exp_mdc, struct ptlrpc_request *req, struct mea *mea; int mdsize; LASSERT(exp_mdc != NULL); - /* dir can be non-splitted */ if (md->body->eadatasize == 0) RETURN(0); @@ -346,33 +339,12 @@ int mdc_req2lustre_md(struct obd_export *exp_mdc, struct ptlrpc_request *req, mea = lustre_msg_buf(req->rq_repmsg, offset + 1, mdsize); LASSERT(mea != NULL); - /* - * check mea for validness, as there is possible that old tests - * will try to set lov EA to dir object and thus confuse this - * stuff. - */ - if (mea->mea_magic != MEA_MAGIC_LAST_CHAR && - mea->mea_magic != MEA_MAGIC_ALL_CHARS) - GOTO(out_invalid_mea, rc = -EINVAL); - - if (mea->mea_count > 256 || mea->mea_master > 256 || - mea->mea_master > mea->mea_count) - GOTO(out_invalid_mea, rc = -EINVAL); - - LASSERT(id_fid(&mea->mea_ids[0])); - - rc = obd_unpackmd(exp_mdc, (void *)&md->mea, - (void *)mea, mdsize); + rc = obd_unpackmd(exp_mdc, (void *) &md->mea, + (void *) mea, mdsize); if (rc >= 0) { LASSERT (rc >= sizeof (*md->mea)); rc = 0; } - - RETURN(rc); - - out_invalid_mea: - CERROR("Detected invalid mea, which does not " - "support neither old either new format.\n"); } else { LASSERT(0); } @@ -470,7 +442,7 @@ int mdc_set_open_replay_data(struct obd_export *exp, mod->mod_och = och; mod->mod_open_req = open_req; - memcpy(&rec->cr_replayid, &body->id1, sizeof rec->cr_replayid); + memcpy(&rec->cr_replayfid, &body->fid1, sizeof rec->cr_replayfid); open_req->rq_replay_cb = mdc_replay_open; open_req->rq_commit_cb = mdc_commit_open; open_req->rq_cb_data = mod; @@ -673,16 +645,13 @@ int mdc_done_writing(struct obd_export *exp, struct obdo *obdo) mdc_pack_secdesc(req, size[0]); - body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, - sizeof(*body)); - - mdc_pack_id(&body->id1, obdo->o_id, 0, obdo->o_mode, - obdo->o_mds, obdo->o_fid); - + body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof(*body)); + mdc_pack_fid(&body->fid1, obdo->o_id, 0, obdo->o_mode); body->size = obdo->o_size; body->blocks = obdo->o_blocks; body->flags = obdo->o_flags; body->valid = obdo->o_valid; +// memcpy(&body->handle, &och->och_fh, sizeof(body->handle)); req->rq_replen = lustre_msg_size(1, &size[1]); @@ -691,8 +660,7 @@ int mdc_done_writing(struct obd_export *exp, struct obdo *obdo) RETURN(rc); } -int mdc_readpage(struct obd_export *exp, - struct lustre_id *id, +int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, __u64 offset, struct page *page, struct ptlrpc_request **request) { @@ -703,7 +671,7 @@ int mdc_readpage(struct obd_export *exp, int rc, size[2] = {0, sizeof(*body)}; ENTRY; - CDEBUG(D_INODE, "inode: %ld\n", (long)id->li_stc.u.e3s.l3s_ino); + CDEBUG(D_INODE, "inode: %ld\n", (long)mdc_fid->id); size[0] = mdc_get_secdesc_size(); @@ -722,7 +690,8 @@ int mdc_readpage(struct obd_export *exp, /* NB req now owns desc and will free it when it gets freed */ ptlrpc_prep_bulk_page(desc, page, 0, PAGE_CACHE_SIZE); - mdc_readdir_pack(req, 1, offset, PAGE_CACHE_SIZE, id); + + mdc_readdir_pack(req, 1, offset, PAGE_CACHE_SIZE, mdc_fid); req->rq_replen = lustre_msg_size(1, &size[1]); rc = ptlrpc_queue_wait(req); @@ -769,15 +738,6 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, } #endif switch (cmd) { - case OBD_IOC_CMOBD_SYNC: - rc = 0; - break; - case OBD_IOC_COBD_CON: - rc = 0; - break; - case OBD_IOC_COBD_COFF: - rc = 0; - break; case OBD_IOC_CLIENT_RECOVER: rc = ptlrpc_recover_import(imp, data->ioc_inlbuf1); if (rc < 0) @@ -830,10 +790,10 @@ int mdc_set_info(struct obd_export *exp, obd_count keylen, exp->exp_obd->obd_name, imp->imp_initial_recov); RETURN(0); - } else if (keylen >= strlen("mds_type") && strcmp(key, "mds_type") == 0) { + } else if (keylen >= strlen("mds_num") && strcmp(key, "mds_num") == 0) { struct ptlrpc_request *req; - char *bufs[2] = {key, val}; int rc, size[2] = {keylen, vallen}; + char *bufs[2] = {key, val}; req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION, OST_SET_INFO, 2, size, bufs); @@ -912,11 +872,8 @@ static int mdc_pin(struct obd_export *exp, obd_id ino, __u32 gen, int type, //mdc_pack_secdesc(req, size[0]); - body = lustre_msg_buf(req->rq_reqmsg, - MDS_REQ_REC_OFF, sizeof(*body)); - - /* FIXME-UMKA: here should be also mdsnum and fid. */ - mdc_pack_id(&body->id1, ino, gen, type, 0, 0); + body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof(*body)); + mdc_pack_fid(&body->fid1, ino, gen, type); body->flags = flag; req->rq_replen = lustre_msg_size(1, &size[1]); @@ -987,7 +944,7 @@ static int mdc_unpin(struct obd_export *exp, RETURN(rc); } -int mdc_sync(struct obd_export *exp, struct lustre_id *id, +int mdc_sync(struct obd_export *exp, struct ll_fid *fid, struct ptlrpc_request **request) { struct ptlrpc_request *req; @@ -1005,10 +962,10 @@ int mdc_sync(struct obd_export *exp, struct lustre_id *id, //mdc_pack_secdesc(req, size[0]); - if (id) { + if (fid) { body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body)); - memcpy(&body->id1, id, sizeof(*id)); + memcpy(&body->fid1, fid, sizeof(*fid)); } req->rq_replen = lustre_msg_size(1, &size[1]); @@ -1180,56 +1137,40 @@ static struct obd_device *mdc_get_real_obd(struct obd_export *exp, } static int mdc_get_info(struct obd_export *exp, obd_count keylen, - void *key, __u32 *valsize, void *val) + void *key, __u32 *vallen, void *val) { - struct ptlrpc_request *req; - char *bufs[1] = {key}; - int rc = 0; ENTRY; - - if (!valsize || !val) + if (!vallen || !val) RETURN(-EFAULT); - if ((keylen < strlen("mdsize") || strcmp(key, "mdsize") != 0) && - (keylen < strlen("mdsnum") || strcmp(key, "mdsnum") != 0) && - (keylen < strlen("rootid") || strcmp(key, "rootid") != 0)) - RETURN(-EPROTO); - - req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION, - OST_GET_INFO, 1, &keylen, bufs); - if (req == NULL) - RETURN(-ENOMEM); - - req->rq_replen = lustre_msg_size(1, valsize); - rc = ptlrpc_queue_wait(req); - if (rc) - GOTO(out_req, rc); + if (keylen >= strlen("mdsize") && strcmp(key, "mdsize") == 0) { + struct ptlrpc_request *req; + __u32 *reply; + char *bufs[1] = {key}; + int rc; + req = ptlrpc_prep_req(class_exp2cliimp(exp), + LUSTRE_OBD_VERSION, OST_GET_INFO, + 1, &keylen, bufs); + if (req == NULL) + RETURN(-ENOMEM); - if (keylen >= strlen("rootid") && !strcmp(key, "rootid")) { - struct lustre_id *reply; - - reply = lustre_swab_repbuf(req, 0, sizeof(*reply), - lustre_swab_lustre_id); - if (reply == NULL) { - CERROR("Can't unpack %s\n", (char *)key); - GOTO(out_req, rc = -EPROTO); - } + req->rq_replen = lustre_msg_size(1, vallen); + rc = ptlrpc_queue_wait(req); + if (rc) + GOTO(out, rc); - *(struct lustre_id *)val = *reply; - } else { - __u32 *reply; - - reply = lustre_swab_repbuf(req, 0, sizeof(*reply), - lustre_swab_generic_32s); + /* FIXME: right swap routine here! */ + reply = lustre_swab_repbuf(req, 0, sizeof(*reply), NULL); if (reply == NULL) { - CERROR("Can't unpack %s\n", (char *)key); - GOTO(out_req, rc = -EPROTO); + CERROR("Can't unpack mdsize\n"); + GOTO(out, rc = -EPROTO); } *((__u32 *)val) = *reply; + out: + ptlrpc_req_finished(req); + RETURN(rc); } -out_req: - ptlrpc_req_finished(req); - RETURN(rc); + RETURN(-EINVAL); } int mdc_obj_create(struct obd_export *exp, struct obdo *oa, @@ -1344,8 +1285,7 @@ int mdc_brw(int rw, struct obd_export *exp, struct obdo *oa, return 0; } -static int mdc_valid_attrs(struct obd_export *exp, - struct lustre_id *id) +static int mdc_valid_attrs(struct obd_export *exp, struct ll_fid *fid) { struct ldlm_res_id res_id = { .name = {0} }; struct obd_device *obd = exp->exp_obd; @@ -1354,12 +1294,11 @@ static int mdc_valid_attrs(struct obd_export *exp, int flags; ENTRY; - res_id.name[0] = id_fid(id); - res_id.name[1] = id_group(id); + res_id.name[0] = fid->id; + res_id.name[1] = fid->generation; policy.l_inodebits.bits = MDS_INODELOCK_UPDATE; - CDEBUG(D_INFO, "trying to match res "LPU64"\n", - res_id.name[0]); + CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id.name[0]); /* FIXME use LDLM_FL_TEST_LOCK instead */ flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING; @@ -1376,15 +1315,12 @@ static int mdc_valid_attrs(struct obd_export *exp, } RETURN(0); } - -static int mdc_change_cbdata_name(struct obd_export *exp, - struct lustre_id *pid, - char *name, int len, - struct lustre_id *cid, +static int mdc_change_cbdata_name(struct obd_export *exp, struct ll_fid *pfid, + char *name, int len, struct ll_fid *cfid, ldlm_iterator_t it, void *data) { int rc; - rc = mdc_change_cbdata(exp, cid, it, data); + rc = mdc_change_cbdata(exp, cfid, it, data); RETURN(rc); } diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index a77cffe..d827236 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -178,20 +178,16 @@ int mds_lock_mode_for_dir(struct obd_device *obd, split = mds_splitting_expected(obd, dentry); - /* - * it is important to check here only for MDS_NO_SPLITTABLE. The reason - * is that MDS_NO_SPLITTABLE means dir is not splittable in principle - * and another thread will not split it on the quiet. But if we have - * MDS_NO_SPLIT_EXPECTED, this means, that dir may be splitted anytime, - * but not now (for current thread) and we should consider that it can - * happen soon and go that branch which can yield LCK_EX to protect from - * possible splitting. - */ + /* it is important to check here only for MDS_NO_SPLITTABLE. + * The reason is that MDS_NO_SPLITTABLE means dir is not splittable + * in principle and another thread will not split it on the quiet. + * But if we have MDS_NO_SPLIT_EXPECTED, this means, that dir may be + * splitted anytime, but not now (forcurrent thread) and we should + * consider that it can happen soon and go that branch which can yield + * LCK_EX to protect from possible splitting. */ if (split == MDS_NO_SPLITTABLE) { - /* - * this inode won't be splitted. so we need not to protect from - * just flush client's cache on modification. - */ + /* this inode won't be splitted. so we need not to protect from + * just flush client's cache on modification */ ret_mode = 0; if (mode == LCK_PW) ret_mode = LCK_CW; @@ -202,24 +198,20 @@ int mds_lock_mode_for_dir(struct obd_device *obd, if (mode == LCK_PR) { ret_mode = LCK_CR; } else if (mode == LCK_PW) { - /* - * caller gonna modify directory.we use concurrent write - * lock here to retract client's cache for readdir. - */ + /* caller gonna modify directory.we use concurrent + write lock here to retract client's cache for readdir */ ret_mode = LCK_CW; if (split == MDS_EXPECT_SPLIT) { - /* - * splitting possible. serialize any access the - * idea is that first one seen dir is splittable - * is given exclusive lock and split - * directory. caller passes lock mode to - * mds_try_to_split_dir() and splitting would be - * done with exclusive lock only -bzzz. - */ - CDEBUG(D_OTHER, "%s: gonna split %lu/%lu\n", + /* splitting possible. serialize any access + * the idea is that first one seen dir is + * splittable is given exclusive lock and + * split directory. caller passes lock mode + * to mds_try_to_split_dir() and splitting + * would be done with exclusive lock only -bzzz */ + CDEBUG(D_OTHER, "%s: gonna split %u/%u\n", obd->obd_name, - (unsigned long)dentry->d_inode->i_ino, - (unsigned long)dentry->d_inode->i_generation); + (unsigned) dentry->d_inode->i_ino, + (unsigned) dentry->d_inode->i_generation); ret_mode = LCK_EX; } } @@ -228,22 +220,24 @@ int mds_lock_mode_for_dir(struct obd_device *obd, } /* only valid locked dentries or errors should be returned */ -struct dentry *mds_id2locked_dentry(struct obd_device *obd, struct lustre_id *id, - struct vfsmount **mnt, int lock_mode, - struct lustre_handle *lockh, int *mode, - char *name, int namelen, __u64 lockpart) +struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid, + struct vfsmount **mnt, int lock_mode, + struct lustre_handle *lockh, int *mode, + char *name, int namelen, __u64 lockpart) { - struct dentry *de = mds_id2dentry(obd, id, mnt), *retval = de; - ldlm_policy_data_t policy = { .l_inodebits = { lockpart } }; + struct mds_obd *mds = &obd->u.mds; + struct dentry *de = mds_fid2dentry(mds, fid, mnt), *retval = de; struct ldlm_res_id res_id = { .name = {0} }; int flags = 0, rc; + ldlm_policy_data_t policy = { .l_inodebits = { lockpart } }; + ENTRY; if (IS_ERR(de)) RETURN(de); - res_id.name[0] = id_fid(id); - res_id.name[1] = id_group(id); + res_id.name[0] = de->d_inode->i_ino; + res_id.name[1] = de->d_inode->i_generation; lockh[1].cookie = 0; #ifdef S_PDIROPS if (name && IS_PDIROPS(de->d_inode)) { @@ -267,16 +261,17 @@ struct dentry *mds_id2locked_dentry(struct obd_device *obd, struct lustre_id *id res_id.name[2] = full_name_hash(name, namelen); - CDEBUG(D_INFO, "take lock on "DLID4":"LPX64"\n", - OLID4(id), res_id.name[2]); + CDEBUG(D_INFO, "take lock on %lu:%u:"LPX64"\n", + de->d_inode->i_ino, de->d_inode->i_generation, + res_id.name[2]); } #else #warning "No PDIROPS support in the kernel" #endif rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, res_id, LDLM_IBITS, &policy, lock_mode, &flags, - mds_blocking_ast, ldlm_completion_ast, - NULL, NULL, NULL, 0, NULL, lockh); + mds_blocking_ast, ldlm_completion_ast, NULL, NULL, + NULL, 0, NULL, lockh); if (rc != ELDLM_OK) { l_dput(de); retval = ERR_PTR(-EIO); /* XXX translate ldlm code */ @@ -294,31 +289,29 @@ struct dentry *mds_id2locked_dentry(struct obd_device *obd, struct lustre_id *id #endif -/* Look up an entry by inode number. This function ONLY returns valid dget'd - * dentries with an initialized inode or errors */ -struct dentry *mds_id2dentry(struct obd_device *obd, struct lustre_id *id, - struct vfsmount **mnt) +/* Look up an entry by inode number. */ +/* this function ONLY returns valid dget'd dentries with an initialized inode + or errors */ +struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, + struct vfsmount **mnt) { - char idname[32]; + char fid_name[32]; + unsigned long ino = fid->id; + __u32 generation = fid->generation; struct inode *inode; struct dentry *result; - struct mds_obd *mds = &obd->u.mds; - __u32 generation = (__u32)id_gen(id); - unsigned long ino = (unsigned long)id_ino(id); - if (ino == 0) RETURN(ERR_PTR(-ESTALE)); + + snprintf(fid_name, sizeof(fid_name), "0x%lx", ino); - snprintf(idname, sizeof(idname), "0x%lx", ino); - - CDEBUG(D_DENTRY, "--> mds_id2dentry: ino/gen %lu/%u, sb %p\n", + CDEBUG(D_DENTRY, "--> mds_fid2dentry: ino/gen %lu/%u, sb %p\n", ino, generation, mds->mds_sb); - /* under ext3 this is neither supposed to return bad inodes nor NULL - inodes. */ - result = ll_lookup_one_len(idname, mds->mds_id_de, - strlen(idname)); + /* under ext3 this is neither supposed to return bad inodes + nor NULL inodes. */ + result = ll_lookup_one_len(fid_name, mds->mds_fid_de, strlen(fid_name)); if (IS_ERR(result)) RETURN(result); @@ -335,8 +328,8 @@ struct dentry *mds_id2dentry(struct obd_device *obd, struct lustre_id *id, /* here we disabled generation check, as root inode i_generation * of cache mds and real mds are different. */ - if (inode->i_ino != id_ino(&mds->mds_rootid) && generation && - inode->i_generation != generation) { + if (inode->i_ino != mds->mds_rootfid.id && 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, @@ -357,45 +350,42 @@ struct dentry *mds_id2dentry(struct obd_device *obd, struct lustre_id *id, /* Establish a connection to the MDS. * - * This will set up an export structure for the client to hold state data about - * that client, like open files, the last operation number it did on the server, - * etc. + * This will set up an export structure for the client to hold state data + * about that client, like open files, the last operation number it did + * on the server, etc. */ static int mds_connect(struct lustre_handle *conn, struct obd_device *obd, - struct obd_uuid *cluuid, unsigned long flags) + struct obd_uuid *cluuid, unsigned long connect_flags) { - struct mds_obd *mds = &obd->u.mds; - struct mds_export_data *med; - struct mds_client_data *mcd; struct obd_export *exp; + struct mds_export_data *med; /* */ + struct mds_client_data *mcd; int rc; ENTRY; if (!conn || !obd || !cluuid) RETURN(-EINVAL); - /* XXX There is a small race between checking the list and adding a new - * connection for the same UUID, but the real threat (list corruption - * when multiple different clients connect) is solved. + /* XXX There is a small race between checking the list and adding a + * new connection for the same UUID, but the real threat (list + * corruption when multiple different clients connect) is solved. * - * There is a second race between adding the export to the list, and - * filling in the client data below. Hence skipping the case of NULL - * mcd above. We should already be controlling multiple connects at the - * client, and we can't hold the spinlock over memory allocations - * without risk of deadlocking. + * There is a second race between adding the export to the list, + * and filling in the client data below. Hence skipping the case + * of NULL mcd above. We should already be controlling multiple + * connects at the client, and we can't hold the spinlock over + * memory allocations without risk of deadlocking. */ rc = class_connect(conn, obd, cluuid); if (rc) RETURN(rc); exp = class_conn2export(conn); - - LASSERT(exp != NULL); + LASSERT(exp); med = &exp->exp_mds_data; OBD_ALLOC(mcd, sizeof(*mcd)); if (!mcd) { - CERROR("%s: out of memory for client data.\n", - obd->obd_name); + CERROR("mds: out of memory for client data\n"); GOTO(out, rc = -ENOMEM); } @@ -405,8 +395,9 @@ static int mds_connect(struct lustre_handle *conn, struct obd_device *obd, rc = mds_client_add(obd, &obd->u.mds, med, -1); if (rc) GOTO(out, rc); - - if (!(flags & OBD_OPT_MDS_CONNECTION)) { + + if (!(connect_flags & OBD_OPT_MDS_CONNECTION)) { + struct mds_obd *mds = &obd->u.mds; if (!(exp->exp_flags & OBD_OPT_REAL_CLIENT)) { atomic_inc(&mds->mds_real_clients); CDEBUG(D_OTHER,"%s: peer from %s is real client (%d)\n", @@ -417,16 +408,15 @@ static int mds_connect(struct lustre_handle *conn, struct obd_device *obd, if (mds->mds_lmv_name) rc = mds_lmv_connect(obd, mds->mds_lmv_name); } - EXIT; out: if (rc) { OBD_FREE(mcd, sizeof(*mcd)); class_disconnect(exp, 0); - } else { - class_export_put(exp); } - RETURN(rc); + class_export_put(exp); + + return rc; } static int mds_init_export(struct obd_export *exp) @@ -494,13 +484,15 @@ out: static int mds_disconnect(struct obd_export *exp, int flags) { - unsigned long irqflags; struct obd_device *obd; struct mds_obd *mds; + unsigned long irqflags; int rc; ENTRY; - LASSERT(exp != NULL); + LASSERT(exp); + class_export_get(exp); + obd = class_exp2obd(exp); if (obd == NULL) { CDEBUG(D_IOCTL, "invalid client cookie "LPX64"\n", @@ -509,22 +501,14 @@ static int mds_disconnect(struct obd_export *exp, int flags) } mds = &obd->u.mds; - /* - * suppress any inter-mds requests durring disconnecting lmv if this is - * detected --force mode. This is needed to avoid endless recovery. - */ - if (atomic_read(&mds->mds_real_clients) > 0 && - !(exp->exp_flags & OBD_OPT_REAL_CLIENT)) - flags |= OBD_OPT_FORCE; - if (!(exp->exp_flags & OBD_OPT_REAL_CLIENT) - && !atomic_read(&mds->mds_real_clients)) { + && !atomic_read(&mds->mds_real_clients)) { /* there was no client at all */ mds_lmv_disconnect(obd, flags); } if ((exp->exp_flags & OBD_OPT_REAL_CLIENT) - && atomic_dec_and_test(&mds->mds_real_clients)) { + && atomic_dec_and_test(&mds->mds_real_clients)) { /* time to drop LMV connections */ CDEBUG(D_OTHER, "%s: last real client %s disconnected. " "Disconnnect from LMV now\n", @@ -536,7 +520,7 @@ static int mds_disconnect(struct obd_export *exp, int flags) exp->exp_flags = flags; spin_unlock_irqrestore(&exp->exp_lock, irqflags); - /* disconnect early so that clients can't keep using export */ + /* Disconnect early so that clients can't keep using export */ rc = class_disconnect(exp, flags); ldlm_cancel_locks_for_export(exp); @@ -554,6 +538,8 @@ static int mds_disconnect(struct obd_export *exp, int flags) spin_unlock(&svc->srv_lock); } spin_unlock_irqrestore(&exp->exp_lock, irqflags); + + class_export_put(exp); RETURN(rc); } @@ -561,11 +547,9 @@ static int mds_getstatus(struct ptlrpc_request *req) { struct mds_obd *mds = mds_req2mds(req); struct mds_body *body; - int rc, size; + int rc, size = sizeof(*body); ENTRY; - size = sizeof(*body); - rc = lustre_pack_reply(req, 1, &size, NULL); if (rc || OBD_FAIL_CHECK(OBD_FAIL_MDS_GETSTATUS_PACK)) { CERROR("mds: out of memory for message: size=%d\n", size); @@ -573,14 +557,11 @@ static int mds_getstatus(struct ptlrpc_request *req) RETURN(-ENOMEM); } - body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - - body->valid |= OBD_MD_FID; - memcpy(&body->id1, &mds->mds_rootid, sizeof(body->id1)); + body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); + memcpy(&body->fid1, &mds->mds_rootfid, sizeof(body->fid1)); - /* - * the last_committed and last_xid fields are filled in for all replies - * already - no need to do so here also. + /* the last_committed and last_xid fields are filled in for all + * replies already - no need to do so here also. */ RETURN(0); } @@ -598,13 +579,11 @@ int mds_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, /* XXX layering violation! -phil */ l_lock(&lock->l_resource->lr_namespace->ns_lock); - - /* - * get this: if mds_blocking_ast is racing with mds_intent_policy, such - * that mds_blocking_ast is called just before l_i_p takes the ns_lock, - * then by the time we get the lock, we might not be the correct - * blocking function anymore. So check, and return early, if so. - */ + /* Get this: if mds_blocking_ast is racing with mds_intent_policy, + * such that mds_blocking_ast is called just before l_i_p takes the + * ns_lock, then by the time we get the lock, we might not be the + * correct blocking function anymore. So check, and return early, if + * so. */ if (lock->l_blocking_ast != mds_blocking_ast) { l_unlock(&lock->l_resource->lr_namespace->ns_lock); RETURN(0); @@ -720,24 +699,24 @@ void mds_squash_root(struct mds_obd *mds, struct mds_req_sec_desc *rsd, return; CDEBUG(D_OTHER, "squash req from 0x%llx, (%d:%d/%x)=>(%d:%d/%x)\n", - *peernid, rsd->rsd_fsuid, rsd->rsd_fsgid, rsd->rsd_cap, + *peernid, + rsd->rsd_fsuid, rsd->rsd_fsgid, rsd->rsd_cap, mds->mds_squash_uid, mds->mds_squash_gid, (rsd->rsd_cap & ~CAP_FS_MASK)); rsd->rsd_uid = mds->mds_squash_uid; rsd->rsd_fsuid = mds->mds_squash_uid; rsd->rsd_fsgid = mds->mds_squash_gid; - /* XXX should we remove all capabilities? */ rsd->rsd_cap &= ~CAP_FS_MASK; } static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry, - struct ptlrpc_request *req, struct mds_body *reqbody, - int reply_off) + struct ptlrpc_request *req, + struct mds_body *reqbody, int reply_off) { - struct inode *inode = dentry->d_inode; struct mds_body *body; + struct inode *inode = dentry->d_inode; int rc = 0; ENTRY; @@ -748,49 +727,50 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry, LASSERT(body != NULL); /* caller prepped reply */ if (dentry->d_flags & DCACHE_CROSS_REF) { - mds_pack_dentry2body(obd, body, dentry, - (reqbody->valid & OBD_MD_FID)); - CDEBUG(D_OTHER, "cross reference: "DLID4"\n", - OLID4(&body->id1)); + CDEBUG(D_OTHER, "cross reference: %lu/%lu/%lu\n", + (unsigned long) dentry->d_mdsnum, + (unsigned long) dentry->d_inum, + (unsigned long) dentry->d_generation); + body->valid |= OBD_MD_FLID | OBD_MD_MDS; + body->fid1.id = dentry->d_inum; + body->fid1.mds = dentry->d_mdsnum; + body->fid1.generation = dentry->d_generation; RETURN(0); } - - mds_pack_inode2body(obd, body, inode, (reqbody->valid & OBD_MD_FID)); + mds_pack_inode2fid(obd, &body->fid1, inode); + mds_pack_inode2body(obd, body, inode); if ((S_ISREG(inode->i_mode) && (reqbody->valid & OBD_MD_FLEASIZE)) || (S_ISDIR(inode->i_mode) && (reqbody->valid & OBD_MD_FLDIREA))) { rc = mds_pack_md(obd, req->rq_repmsg, reply_off + 1, body, inode, 1); - /* if we have LOV EA data, the OST holds size, atime, mtime. */ + /* If we have LOV EA data, the OST holds size, atime, mtime */ if (!(body->valid & OBD_MD_FLEASIZE) && !(body->valid & OBD_MD_FLDIREA)) body->valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLATIME | OBD_MD_FLMTIME); } else if (S_ISLNK(inode->i_mode) && (reqbody->valid & OBD_MD_LINKNAME) != 0) { - int len = req->rq_repmsg->buflens[reply_off + 1]; - char *symname = lustre_msg_buf(req->rq_repmsg, reply_off + 1, 0); + char *symname = lustre_msg_buf(req->rq_repmsg, reply_off + 1,0); + int len; - LASSERT(symname != NULL); /* caller prepped reply */ + LASSERT (symname != NULL); /* caller prepped reply */ + len = req->rq_repmsg->buflens[reply_off + 1]; - if (!inode->i_op->readlink) { - rc = -ENOSYS; + rc = inode->i_op->readlink(dentry, symname, len); + if (rc < 0) { + CERROR("readlink failed: %d\n", rc); + } else if (rc != len - 1) { + CERROR ("Unexpected readlink rc %d: expecting %d\n", + rc, len - 1); + rc = -EINVAL; } else { - rc = inode->i_op->readlink(dentry, symname, len); - if (rc < 0) { - CERROR("readlink failed: %d\n", rc); - } else if (rc != len - 1) { - CERROR("Unexpected readlink rc %d: expecting %d\n", - rc, len - 1); - rc = -EINVAL; - } else { - CDEBUG(D_INODE, "read symlink dest %s\n", symname); - body->valid |= OBD_MD_LINKNAME; - body->eadatasize = rc + 1; - symname[rc] = 0; - rc = 0; - } + CDEBUG(D_INODE, "read symlink dest %s\n", symname); + body->valid |= OBD_MD_LINKNAME; + body->eadatasize = rc + 1; + symname[rc] = 0; /* NULL terminate */ + rc = 0; } } @@ -816,8 +796,9 @@ static int mds_getattr_pack_msg_cf(struct ptlrpc_request *req, GOTO(out, req->rq_status = rc); } + EXIT; out: - RETURN(rc); + return(rc); } static int mds_getattr_pack_msg(struct ptlrpc_request *req, struct inode *inode, @@ -875,8 +856,9 @@ static int mds_getattr_pack_msg(struct ptlrpc_request *req, struct inode *inode, GOTO(out, req->rq_status = rc); } + EXIT; out: - RETURN(rc); + return(rc); } int mds_check_mds_num(struct obd_device *obd, struct inode* inode, @@ -885,21 +867,19 @@ int mds_check_mds_num(struct obd_device *obd, struct inode* inode, struct mea *mea = NULL; int mea_size, rc = 0; ENTRY; - + rc = mds_get_lmv_attr(obd, inode, &mea, &mea_size); if (rc) RETURN(rc); if (mea != NULL) { - /* - * dir is already splitted, check if requested filename should - * live at this MDS or at another one. - */ - int i = mea_name2idx(mea, name, namelen - 1); - if (mea->mea_master != id_group(&mea->mea_ids[i])) { + /* dir is already splitted, check if requested filename + * should live at this MDS or at another one */ + int i; + i = mea_name2idx(mea, name, namelen - 1); + if (mea->mea_master != mea->mea_fids[i].mds) { CDEBUG(D_OTHER, - "inapropriate MDS(%d) for %s. should be " - "%lu(%d)\n", mea->mea_master, name, - (unsigned long)id_group(&mea->mea_ids[i]), i); + "inapropriate MDS(%d) for %s. should be %d(%d)\n", + mea->mea_master, name, mea->mea_fids[i].mds, i); rc = -ERESTART; } } @@ -927,6 +907,7 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, ENTRY; LASSERT(!strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME)); + MDS_UPDATE_COUNTER((&obd->u.mds), MDS_GETATTR_NAME_COUNT); rsd = lustre_swab_mds_secdesc(req, MDS_REQ_SECDESC_OFF); @@ -936,7 +917,7 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, } mds_squash_root(mds, rsd, &req->rq_peer.peer_id.nid); - /* swab now, before anyone looks inside the request. */ + /* Swab now, before anyone looks inside the request */ body = lustre_swab_reqbuf(req, offset, sizeof(*body), lustre_swab_mds_body); if (body == NULL) { @@ -958,6 +939,7 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, name = NULL; LASSERT (offset == 1 || offset == 3); + /* if requests were at offset 2, the getattr reply goes back at 1 */ if (offset == 3) { rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*rep)); reply_offset = 1; @@ -982,21 +964,18 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, } #if 0 #if HAVE_LOOKUP_RAW + /* FIXME: handle raw lookup */ if (body->valid == OBD_MD_FLID) { struct mds_body *mds_reply; int size = sizeof(*mds_reply); struct inode *dir; ino_t inum; - - dparent = mds_id2dentry(obd, &body->id1, NULL); + dparent = mds_fid2dentry(mds, &body->fid1, NULL); if (IS_ERR(dparent)) { rc = PTR_ERR(dparent); GOTO(cleanup, rc); } - - /* - * the user requested ONLY the inode number, so do a raw lookup. - */ + // The user requested ONLY the inode number, so do a raw lookup rc = lustre_pack_reply(req, 1, &size, NULL); if (rc) { CERROR("out of memory\n"); @@ -1009,8 +988,7 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, l_dput(dparent); mds_reply = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*mds_reply)); - - id_ino(&mds_reply->id1) = inum; + mds_reply->fid1.id = inum; mds_reply->valid = OBD_MD_FLID; GOTO(cleanup, rc); } @@ -1018,7 +996,7 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, #endif if (resent_req == 0) { if (name) { - rc = mds_get_parent_child_locked(obd, mds, &body->id1, + rc = mds_get_parent_child_locked(obd, mds, &body->fid1, parent_lockh, &dparent, LCK_PR, MDS_INODELOCK_LOOKUP, @@ -1031,20 +1009,20 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, /*FIXME: we need MDS_INODELOCK_LOOKUP or not*/ child_part &= ~MDS_INODELOCK_LOOKUP; CDEBUG(D_OTHER, "%s: retrieve attrs for %lu/%lu\n", - obd->obd_name, (unsigned long)id_ino(&body->id1), - (unsigned long)id_gen(&body->id1)); + obd->obd_name, (unsigned long) body->fid1.id, + (unsigned long) body->fid1.generation); #if 0 - dchild = mds_id2locked_dentry(obd, &body->id1, NULL, - LCK_PR, parent_lockh, - &update_mode, - NULL, 0, child_part); + dchild = mds_fid2locked_dentry(obd, &body->fid1, NULL, + LCK_PR, parent_lockh, + &update_mode, + NULL, 0, child_part); #else - dchild = mds_id2locked_dentry(obd, &body->id1, NULL, - LCK_PR, parent_lockh, - &update_mode, - NULL, 0, - MDS_INODELOCK_UPDATE); + dchild = mds_fid2locked_dentry(obd, &body->fid1, NULL, + LCK_PR, parent_lockh, + &update_mode, + NULL, 0, + MDS_INODELOCK_UPDATE); #endif if (IS_ERR(dchild)) { CERROR("can't find inode: %d\n", @@ -1069,33 +1047,31 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset, GOTO(cleanup, rc); } else { struct ldlm_lock *granted_lock; - + struct ll_fid child_fid; + struct ldlm_resource *res; DEBUG_REQ(D_DLMTRACE, req, "resent, not enqueuing new locks"); granted_lock = ldlm_handle2lock(child_lockh); - LASSERTF(granted_lock != NULL, LPU64"/%lu lockh "LPX64"\n", - id_fid(&body->id1), (unsigned long)id_group(&body->id1), + LASSERTF(granted_lock != NULL, LPU64"/%u lockh "LPX64"\n", + body->fid1.id, body->fid1.generation, child_lockh->cookie); - dparent = mds_id2dentry(obd, &body->id1, NULL); - LASSERT(!IS_ERR(dparent)); - - dchild = ll_lookup_one_len(name, dparent, namesize - 1); - LASSERT(!IS_ERR(dchild)); - - l_dput(dparent); - resent_req = 1; + res = granted_lock->l_resource; + child_fid.id = res->lr_name.name[0]; + child_fid.generation = res->lr_name.name[1]; + dchild = mds_fid2dentry(mds, &child_fid, NULL); + LASSERT(dchild); + LDLM_LOCK_PUT(granted_lock); } cleanup_phase = 2; /* dchild, dparent, locks */ fill_inode: + if (!DENTRY_VALID(dchild)) { intent_set_disposition(rep, DISP_LOOKUP_NEG); - /* - * in the intent case, the policy clears this error: the - * disposition is enough. - */ + /* in the intent case, the policy clears this error: + the disposition is enough */ rc = -ENOENT; GOTO(cleanup, rc); } else { @@ -1136,14 +1112,15 @@ fill_inode: case 1: pop_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc); mds_exit_ucred(&uc); + default: ; } - RETURN(rc); + return rc; } static int mds_getattr(struct ptlrpc_request *req, int offset) { + struct mds_obd *mds = mds_req2mds(req); struct obd_device *obd = req->rq_export->exp_obd; - struct mds_obd *mds = &obd->u.mds; struct lvfs_run_ctxt saved; struct dentry *de; struct mds_req_sec_desc *rsd; @@ -1158,7 +1135,7 @@ static int mds_getattr(struct ptlrpc_request *req, int offset) RETURN(-EFAULT); } - body = lustre_swab_reqbuf(req, offset, sizeof(*body), + body = lustre_swab_reqbuf(req, offset, sizeof (*body), lustre_swab_mds_body); if (body == NULL) { CERROR ("Can't unpack body\n"); @@ -1174,7 +1151,7 @@ static int mds_getattr(struct ptlrpc_request *req, int offset) } push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc); - de = mds_id2dentry(obd, &body->id1, NULL); + de = mds_fid2dentry(mds, &body->fid1, NULL); if (IS_ERR(de)) { rc = req->rq_status = PTR_ERR(de); GOTO(out_pop, rc); @@ -1193,14 +1170,13 @@ static int mds_getattr(struct ptlrpc_request *req, int offset) out_pop: pop_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc); mds_exit_ucred(&uc); - RETURN(rc); + return rc; } static int mds_obd_statfs(struct obd_device *obd, struct obd_statfs *osfs, unsigned long max_age) { int rc; - ENTRY; spin_lock(&obd->obd_osfs_lock); rc = fsfilt_statfs(obd, obd->u.mds.mds_sb, max_age); @@ -1208,7 +1184,7 @@ static int mds_obd_statfs(struct obd_device *obd, struct obd_statfs *osfs, memcpy(osfs, &obd->obd_osfs, sizeof(*osfs)); spin_unlock(&obd->obd_osfs_lock); - RETURN(rc); + return rc; } static int mds_statfs(struct ptlrpc_request *req) @@ -1233,9 +1209,10 @@ static int mds_statfs(struct ptlrpc_request *req) GOTO(out, rc); } + EXIT; out: req->rq_status = rc; - RETURN(0); + return 0; } static int mds_sync(struct ptlrpc_request *req, int offset) @@ -1256,8 +1233,8 @@ static int mds_sync(struct ptlrpc_request *req, int offset) GOTO(out, rc); } - if (id_ino(&body->id1) == 0) { - /* an id of zero is taken to mean "sync whole filesystem" */ + if (body->fid1.id == 0) { + /* a fid of zero is taken to mean "sync whole filesystem" */ rc = fsfilt_sync(obd, mds->mds_sb); if (rc) GOTO(out, rc); @@ -1266,21 +1243,22 @@ static int mds_sync(struct ptlrpc_request *req, int offset) struct file *file = mds->mds_rcvd_filp; struct dentry *de; - de = mds_id2dentry(obd, &body->id1, NULL); + de = mds_fid2dentry(mds, &body->fid1, NULL); if (IS_ERR(de)) GOTO(out, rc = PTR_ERR(de)); rc = file->f_op->fsync(NULL, de, 1); + l_dput(de); if (rc) GOTO(out, rc); body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - mds_pack_inode2body(obd, body, de->d_inode, 0); - l_dput(de); + mds_pack_inode2fid(obd, &body->fid1, de->d_inode); + mds_pack_inode2body(obd, body, de->d_inode); } out: req->rq_status = rc; - RETURN(0); + return 0; } /* mds_readpage does not take a DLM lock on the inode, because the client must @@ -1329,7 +1307,7 @@ static int mds_readpage(struct ptlrpc_request *req, int offset) } push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc); - de = mds_id2dentry(obd, &body->id1, &mnt); + de = mds_fid2dentry(mds, &body->fid1, &mnt); if (IS_ERR(de)) GOTO(out_pop, rc = PTR_ERR(de)); @@ -1374,95 +1352,11 @@ out: RETURN(0); } -/* update master MDS ID, which is stored in local inode EA. */ -int mds_update_mid(struct obd_device *obd, struct lustre_id *id, - void *data, int data_len) -{ - struct mds_obd *mds = &obd->u.mds; - struct dentry *dentry; - void *handle; - int rc = 0; - ENTRY; - - LASSERT(id); - LASSERT(obd); - - dentry = mds_id2dentry(obd, id, NULL); - if (IS_ERR(dentry)) - GOTO(out, rc = PTR_ERR(dentry)); - - if (!dentry->d_inode) { - CERROR("Can't find object "DLID4".\n", - OLID4(id)); - GOTO(out_dentry, rc = -EINVAL); - } - - handle = fsfilt_start(obd, dentry->d_inode, - FSFILT_OP_SETATTR, NULL); - if (IS_ERR(handle)) - GOTO(out_dentry, rc = PTR_ERR(handle)); - - rc = mds_update_inode_mid(obd, dentry->d_inode, handle, - (struct lustre_id *)data); - if (rc) { - CERROR("Can't update inode "DLID4" master id, " - "error = %d.\n", OLID4(id), rc); - GOTO(out_commit, rc); - } - -out_commit: - fsfilt_commit(obd, mds->mds_sb, dentry->d_inode, - handle, 0); -out_dentry: - l_dput(dentry); -out: - RETURN(rc); -} -EXPORT_SYMBOL(mds_update_mid); - -/* read master MDS ID, which is stored in local inode EA. */ -int mds_read_mid(struct obd_device *obd, struct lustre_id *id, - void *data, int data_len) -{ - struct dentry *dentry; - int rc = 0; - ENTRY; - - LASSERT(id); - LASSERT(obd); - - dentry = mds_id2dentry(obd, id, NULL); - if (IS_ERR(dentry)) - GOTO(out, rc = PTR_ERR(dentry)); - - if (!dentry->d_inode) { - CERROR("Can't find object "DLID4".\n", - OLID4(id)); - GOTO(out_dentry, rc = -EINVAL); - } - - down(&dentry->d_inode->i_sem); - rc = mds_read_inode_mid(obd, dentry->d_inode, - (struct lustre_id *)data); - up(&dentry->d_inode->i_sem); - if (rc) { - CERROR("Can't read inode "DLID4" master id, " - "error = %d.\n", OLID4(id), rc); - GOTO(out_dentry, rc); - } - -out_dentry: - l_dput(dentry); -out: - RETURN(rc); -} -EXPORT_SYMBOL(mds_read_mid); - int mds_reint(struct ptlrpc_request *req, int offset, struct lustre_handle *lockh) { struct mds_obd *mds = &req->rq_export->exp_obd->u.mds; - struct mds_update_record *rec; + struct mds_update_record *rec; /* 116 bytes on the stack? no sir! */ struct mds_req_sec_desc *rsd; int rc; ENTRY; @@ -1492,6 +1386,7 @@ int mds_reint(struct ptlrpc_request *req, int offset, /* rc will be used to interrupt a for loop over multiple records */ rc = mds_reint_rec(rec, offset, req, lockh); + mds_exit_ucred(&rec->ur_uc); out: OBD_FREE(rec, sizeof(*rec)); @@ -1536,19 +1431,19 @@ static char *reint_names[] = { [REINT_OPEN] "open", }; -#define FILTER_VALID_FLAGS (OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLGENER | \ - OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ| \ - OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME| \ +#define FILTER_VALID_FLAGS (OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLGENER |\ + OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ|\ + OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME|\ OBD_MD_FLID) static void reconstruct_create(struct ptlrpc_request *req) { struct mds_export_data *med = &req->rq_export->exp_mds_data; + struct mds_obd *mds = &req->rq_export->exp_obd->u.mds; struct mds_client_data *mcd = med->med_mcd; struct dentry *dentry; struct ost_body *body; - struct lustre_id id; - int rc; + struct ll_fid fid; ENTRY; /* copy rc, transno and disp; steal locks */ @@ -1558,22 +1453,22 @@ static void reconstruct_create(struct ptlrpc_request *req) return; } - id_gen(&id) = 0; - id_group(&id) = 0; + fid.mds = 0; + fid.id = mcd->mcd_last_data; + fid.generation = 0; - id_ino(&id) = mcd->mcd_last_data; - LASSERT(id_ino(&id) != 0); + LASSERT(fid.id != 0); - dentry = mds_id2dentry(req2obd(req), &id, NULL); + dentry = mds_fid2dentry(mds, &fid, NULL); if (IS_ERR(dentry)) { - CERROR("can't find inode "LPU64"\n", id_ino(&id)); + CERROR("can't find inode "LPU64"\n", fid.id); req->rq_status = PTR_ERR(dentry); EXIT; return; } CWARN("reconstruct reply for x"LPU64" (remote ino) "LPU64" -> %lu/%u\n", - req->rq_xid, id_ino(&id), dentry->d_inode->i_ino, + req->rq_xid, fid.id, dentry->d_inode->i_ino, dentry->d_inode->i_generation); body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); @@ -1581,21 +1476,10 @@ static void reconstruct_create(struct ptlrpc_request *req) body->oa.o_id = dentry->d_inode->i_ino; body->oa.o_generation = dentry->d_inode->i_generation; body->oa.o_valid |= OBD_MD_FLID | OBD_MD_FLGENER; - - down(&dentry->d_inode->i_sem); - rc = mds_read_inode_sid(req2obd(req), dentry->d_inode, &id); - up(&dentry->d_inode->i_sem); - if (rc) { - CERROR("Can't read inode self id, inode %lu, " - "rc %d\n", dentry->d_inode->i_ino, rc); - id_fid(&id) = 0; - } - - body->oa.o_fid = id_fid(&id); - body->oa.o_mds = id_group(&id); + l_dput(dentry); - EXIT; + return; } static int mdt_obj_create(struct ptlrpc_request *req) @@ -1603,16 +1487,13 @@ static int mdt_obj_create(struct ptlrpc_request *req) struct obd_device *obd = req->rq_export->exp_obd; struct mds_obd *mds = &obd->u.mds; struct ost_body *body, *repbody; - char idname[LL_ID_NAMELEN]; - int size = sizeof(*repbody); + char fidname[LL_FID_NAMELEN]; struct inode *parent_inode; struct lvfs_run_ctxt saved; - int rc, cleanup_phase = 0; struct dentry *new = NULL; struct dentry_params dp; - int mealen, flags = 0; + int mealen, flags = 0, rc, size = sizeof(*repbody), cleanup_phase = 0; struct lvfs_ucred uc; - struct lustre_id id; struct mea *mea; void *handle = NULL; unsigned long cr_inum = 0; @@ -1622,8 +1503,7 @@ static int mdt_obj_create(struct ptlrpc_request *req) parent_inode = mds->mds_unnamed_dir->d_inode; - body = lustre_swab_reqbuf(req, 0, sizeof(*body), - lustre_swab_ost_body); + body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_ost_body); if (body == NULL) RETURN(-EFAULT); @@ -1645,57 +1525,32 @@ static int mdt_obj_create(struct ptlrpc_request *req) repbody = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repbody)); - /* in the case of recreate body->oa should have store cookie part - * initialized too, as it is needed to check if object is already - * created. But this is not cache flush case, as object was not created - * on this MDS at least once and its store cookie is not known. */ if (body->oa.o_flags & OBD_FL_RECREATE_OBJS) { /* this is re-create request from MDS holding directory name. - * we have to lookup given ino/gen first. if it exists - * (good case) then there is nothing to do. if it does not then - * we have to recreate it */ - id_fid(&id) = 0; - id_group(&id) = 0; - - id_ino(&id) = body->oa.o_id; - id_gen(&id) = body->oa.o_generation; - - new = mds_id2dentry(obd, &id, NULL); + * we have to lookup given ino/generation first. if it exists + * (good case) then there is nothing to do. if it does not + * then we have to recreate it */ + struct ll_fid fid; + fid.id = body->oa.o_id; + fid.generation = body->oa.o_generation; + new = mds_fid2dentry(mds, &fid, NULL); if (!IS_ERR(new) && new->d_inode) { - struct lustre_id sid; - - CWARN("mkdir() repairing is on its way: %lu/%lu\n", - (unsigned long)id_ino(&id), (unsigned long)id_gen(&id)); - + CDEBUG(D_HA, "mkdir() repairing is on its way: %lu/%lu\n", + (unsigned long) fid.id, + (unsigned long) fid.generation); obdo_from_inode(&repbody->oa, new->d_inode, FILTER_VALID_FLAGS); - repbody->oa.o_id = new->d_inode->i_ino; repbody->oa.o_generation = new->d_inode->i_generation; repbody->oa.o_valid |= OBD_MD_FLID | OBD_MD_FLGENER; cleanup_phase = 1; - - down(&new->d_inode->i_sem); - rc = mds_read_inode_sid(obd, new->d_inode, &sid); - up(&new->d_inode->i_sem); - if (rc) { - CERROR("Can't read inode self id " - "inode %lu, rc %d.\n", - new->d_inode->i_ino, rc); - GOTO(cleanup, rc); - } - - repbody->oa.o_fid = id_fid(&sid); - repbody->oa.o_mds = id_group(&sid); cr_inum = new->d_inode->i_ino; GOTO(cleanup, rc = 0); } - CWARN("for some reason dir %lu/%lu (or reply) got lost\n", - (unsigned long)id_ino(&id), (unsigned long)id_gen(&id)); - + CWARN("hmm. for some reason dir %lu/%lu (or reply) got lost\n", + (unsigned long) fid.id, (unsigned long) fid.generation); LASSERT(new->d_inode == NULL || - new->d_inode->i_generation != id_gen(&id)); - + new->d_inode->i_generation != fid.generation); l_dput(new); } @@ -1703,18 +1558,16 @@ static int mdt_obj_create(struct ptlrpc_request *req) handle = fsfilt_start(obd, parent_inode, FSFILT_OP_MKDIR, NULL); if (IS_ERR(handle)) { up(&parent_inode->i_sem); - CERROR("fsfilt_start() failed, rc = %d\n", - (int)PTR_ERR(handle)); GOTO(cleanup, rc = PTR_ERR(handle)); } cleanup_phase = 1; /* transaction */ repeat: - rc = sprintf(idname, "%u.%u", ll_insecure_random_int(), current->pid); - new = lookup_one_len(idname, mds->mds_unnamed_dir, rc); + rc = sprintf(fidname, "%u.%u", ll_insecure_random_int(), current->pid); + new = lookup_one_len(fidname, mds->mds_unnamed_dir, rc); if (IS_ERR(new)) { CERROR("%s: can't lookup new inode (%s) for mkdir: %d\n", - obd->obd_name, idname, (int) PTR_ERR(new)); + obd->obd_name, fidname, (int) PTR_ERR(new)); fsfilt_commit(obd, mds->mds_sb, new->d_inode, handle, 0); up(&parent_inode->i_sem); RETURN(PTR_ERR(new)); @@ -1723,95 +1576,53 @@ repeat: goto repeat; } - new->d_fsdata = (void *)&dp; + new->d_fsdata = (void *) &dp; dp.p_inum = 0; dp.p_ptr = req; if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) { DEBUG_REQ(D_HA, req, "replay create obj %lu/%lu", - (unsigned long)body->oa.o_id, - (unsigned long)body->oa.o_generation); + (unsigned long) body->oa.o_id, + (unsigned long) body->oa.o_generation); dp.p_inum = body->oa.o_id; } - rc = vfs_mkdir(parent_inode, new, body->oa.o_mode); if (rc == 0) { if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) { new->d_inode->i_generation = body->oa.o_generation; mark_inode_dirty(new->d_inode); - - /* - * avoiding asserts in cache flush case, as - * @body->oa.o_id should be zero. - */ - if (body->oa.o_id) { - LASSERTF(body->oa.o_id == new->d_inode->i_ino, - "BUG 3550: failed to recreate obj " - LPU64" -> %lu\n", body->oa.o_id, - new->d_inode->i_ino); - - LASSERTF(body->oa.o_generation == - new->d_inode->i_generation, - "BUG 3550: failed to recreate obj/gen " - LPU64"/%u -> %lu/%u\n", body->oa.o_id, - body->oa.o_generation, - new->d_inode->i_ino, - new->d_inode->i_generation); - } + LASSERTF(body->oa.o_id == new->d_inode->i_ino, + "BUG 3550: failed to recreate obj " + LPU64" -> %lu\n", + body->oa.o_id, new->d_inode->i_ino); + LASSERTF(body->oa.o_generation == + new->d_inode->i_generation, + "BUG 3550: failed to recreate obj/gen " + LPU64"/%u -> %lu/%u\n", + body->oa.o_id, body->oa.o_generation, + new->d_inode->i_ino, + new->d_inode->i_generation); } - + obdo_from_inode(&repbody->oa, new->d_inode, FILTER_VALID_FLAGS); repbody->oa.o_id = new->d_inode->i_ino; repbody->oa.o_generation = new->d_inode->i_generation; repbody->oa.o_valid |= OBD_MD_FLID | OBD_MD_FLGENER; - if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) { - /* building lustre_id on passed @oa. */ - id_group(&id) = mds->mds_num; - - LASSERT(body->oa.o_fid != 0); - id_fid(&id) = body->oa.o_fid; - - id_ino(&id) = repbody->oa.o_id; - id_gen(&id) = repbody->oa.o_generation; - - down(&new->d_inode->i_sem); - rc = mds_update_inode_sid(obd, new->d_inode, handle, &id); - up(&new->d_inode->i_sem); - - spin_lock(&mds->mds_fid_lock); - if (id_fid(&id) > mds->mds_last_fid) - mds->mds_last_fid = id_fid(&id); - spin_unlock(&mds->mds_fid_lock); - } else { - down(&new->d_inode->i_sem); - rc = mds_alloc_inode_sid(obd, new->d_inode, handle, &id); - up(&new->d_inode->i_sem); - } - if (rc) { - CERROR("Can't update lustre ID for inode %lu, " - "error = %d\n", new->d_inode->i_ino, rc); - GOTO(cleanup, rc); - } - - /* initializing o_fid after it is allocated. */ - repbody->oa.o_fid = id_fid(&id); - repbody->oa.o_mds = id_group(&id); - rc = fsfilt_del_dir_entry(obd, new); up(&parent_inode->i_sem); + if (rc) { CERROR("can't remove name for object: %d\n", rc); GOTO(cleanup, rc); } - + cleanup_phase = 2; /* created directory object */ - CDEBUG(D_OTHER, "created dirobj: %lu/%lu mode %o\n", - (unsigned long)new->d_inode->i_ino, - (unsigned long)new->d_inode->i_generation, - (unsigned)new->d_inode->i_mode); cr_inum = new->d_inode->i_ino; + CDEBUG(D_OTHER, "created dirobj: %lu/%u mode %o\n", + new->d_inode->i_ino, new->d_inode->i_generation, + new->d_inode->i_mode); } else { up(&parent_inode->i_sem); CERROR("%s: can't create dirobj: %d\n", obd->obd_name, rc); @@ -1819,24 +1630,18 @@ repeat: } if (body->oa.o_valid & OBD_MD_FLID) { - /* this is new object for splitted dir. We have to prevent - * recursive splitting on it -bzzz */ + /* this is new object for splitted dir. we have to + * prevent recursive splitting on it -bzzz */ mealen = obd_size_diskmd(mds->mds_lmv_exp, NULL); - OBD_ALLOC(mea, mealen); if (mea == NULL) GOTO(cleanup, rc = -ENOMEM); - mea->mea_magic = MEA_MAGIC_ALL_CHARS; mea->mea_master = 0; mea->mea_count = 0; - down(&new->d_inode->i_sem); rc = fsfilt_set_md(obd, new->d_inode, handle, mea, mealen); up(&new->d_inode->i_sem); - if (rc) - CERROR("fsfilt_set_md() failed, rc = %d\n", rc); - OBD_FREE(mea, mealen); CDEBUG(D_OTHER, "%s: mark non-splittable %lu/%u - %d\n", obd->obd_name, new->d_inode->i_ino, @@ -1845,14 +1650,7 @@ repeat: /* we pass LCK_EX to split routine to signal that we have * exclusive access to the directory. simple because nobody * knows it already exists -bzzz */ - rc = mds_try_to_split_dir(obd, new, NULL, - body->oa.o_easize, LCK_EX); - if (rc < 0) { - CERROR("Can't split directory %lu, error = %d.\n", - new->d_inode->i_ino, rc); - } else { - rc = 0; - } + mds_try_to_split_dir(obd, new, NULL, body->oa.o_easize, LCK_EX); } cleanup: @@ -1861,8 +1659,7 @@ cleanup: if (rc == 0) ptlrpc_require_repack(req); case 1: /* transaction */ - rc = mds_finish_transno(mds, parent_inode, handle, - req, rc, cr_inum); + rc = mds_finish_transno(mds, parent_inode, handle, req, rc, cr_inum); } l_dput(new); @@ -1873,9 +1670,10 @@ cleanup: static int mdt_get_info(struct ptlrpc_request *req) { - struct obd_export *exp = req->rq_export; - int keylen, rc = 0; char *key; + struct obd_export *exp = req->rq_export; + int keylen, rc = 0, size = sizeof(obd_id); + obd_id *reply; ENTRY; key = lustre_msg_buf(req->rq_reqmsg, 0, 1); @@ -1885,33 +1683,15 @@ static int mdt_get_info(struct ptlrpc_request *req) } keylen = req->rq_reqmsg->buflens[0]; - if ((keylen < strlen("mdsize") || strcmp(key, "mdsize") != 0) && - (keylen < strlen("mdsnum") || strcmp(key, "mdsnum") != 0) && - (keylen < strlen("rootid") || strcmp(key, "rootid") != 0)) + if (keylen < strlen("mdsize") || memcmp(key, "mdsize", 6) != 0) RETURN(-EPROTO); - if (keylen >= strlen("rootid") && !strcmp(key, "rootid")) { - struct lustre_id *reply; - int size = sizeof(*reply); - - rc = lustre_pack_reply(req, 1, &size, NULL); - if (rc) - RETURN(rc); - - reply = lustre_msg_buf(req->rq_repmsg, 0, size); - rc = obd_get_info(exp, keylen, key, &size, reply); - } else { - obd_id *reply; - int size = sizeof(*reply); - - rc = lustre_pack_reply(req, 1, &size, NULL); - if (rc) - RETURN(rc); - - reply = lustre_msg_buf(req->rq_repmsg, 0, size); - rc = obd_get_info(exp, keylen, key, &size, reply); - } + rc = lustre_pack_reply(req, 1, &size, NULL); + if (rc) + RETURN(rc); + reply = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*reply)); + rc = obd_get_info(exp, keylen, key, &size, reply); req->rq_repmsg->status = 0; RETURN(rc); } @@ -1921,7 +1701,7 @@ static int mds_set_info(struct obd_export *exp, __u32 keylen, { struct obd_device *obd; struct mds_obd *mds; - int rc = 0; + int rc = 0; ENTRY; obd = class_exp2obd(exp); @@ -1931,22 +1711,21 @@ static int mds_set_info(struct obd_export *exp, __u32 keylen, RETURN(-EINVAL); } +#define KEY_IS(str) \ + (keylen == strlen(str) && memcmp(key, str, keylen) == 0) + mds = &obd->u.mds; - if (keylen >= strlen("mds_type") && - memcmp(key, "mds_type", keylen) == 0) { + if (KEY_IS("mds_num")) { int valsize; __u32 group; - - CDEBUG(D_IOCTL, "set mds type to %x\n", *(int*)val); - - mds->mds_obd_type = *(int*)val; - group = FILTER_GROUP_FIRST_MDS + mds->mds_obd_type; + CDEBUG(D_IOCTL, "set mds num %d\n", *(int*)val); + mds->mds_num = *(int*)val; + group = FILTER_GROUP_FIRST_MDS + mds->mds_num; valsize = sizeof(group); - - /* mds number has been changed, so the corresponding obdfilter - * exp need to be changed too. */ - rc = obd_set_info(mds->mds_lov_exp, strlen("mds_conn"), - "mds_conn", valsize, &group); + /*mds number has been changed, so the corresponding obdfilter exp + *need to be changed too*/ + rc = obd_set_info(mds->mds_osc_exp, strlen("mds_conn"), "mds_conn", + valsize, &group); RETURN(rc); } CDEBUG(D_IOCTL, "invalid key\n"); @@ -1967,19 +1746,27 @@ static int mdt_set_info(struct ptlrpc_request *req) } keylen = req->rq_reqmsg->buflens[0]; - if (keylen == strlen("mds_type") && - memcmp(key, "mds_type", keylen) == 0) { + if (keylen == strlen("mds_num") && + memcmp(key, "mds_num", keylen) == 0) { rc = lustre_pack_reply(req, 0, NULL, NULL); if (rc) RETURN(rc); - val = lustre_msg_buf(req->rq_reqmsg, 1, 0); + vallen = req->rq_reqmsg->buflens[1]; rc = obd_set_info(exp, keylen, key, vallen, val); req->rq_repmsg->status = 0; RETURN(rc); - } + } else if (keylen == strlen("client") && + memcmp(key, "client", keylen) == 0) { + rc = lustre_pack_reply(req, 0, NULL, NULL); + if (rc) + RETURN(rc); + rc = obd_set_info(exp, keylen, key, sizeof(obd_id), NULL); + req->rq_repmsg->status = 0; + RETURN(rc); + } CDEBUG(D_IOCTL, "invalid key\n"); RETURN(-EINVAL); } @@ -2185,6 +1972,7 @@ int mds_handle(struct ptlrpc_request *req) } break; + case MDS_REINT: { __u32 *opcp = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*opcp)); @@ -2375,10 +2163,10 @@ int mds_handle(struct ptlrpc_request *req) return 0; } -/* Update the server data on disk. This stores the new mount_count and also the - * last_rcvd value to disk. If we don't have a clean shutdown, then the server - * last_rcvd value may be less than that of the clients. This will alert us - * that we may need to do client recovery. +/* Update the server data on disk. This stores the new mount_count and + * also the last_rcvd value to disk. If we don't have a clean shutdown, + * then the server last_rcvd value may be less than that of the clients. + * This will alert us that we may need to do client recovery. * * Also assumes for mds_last_transno that we are not modifying it (no locking). */ @@ -2405,187 +2193,6 @@ int mds_update_server_data(struct obd_device *obd, int force_sync) RETURN(rc); } -/* saves last allocated fid counter to file. */ -int mds_update_last_fid(struct obd_device *obd, int force_sync) -{ - struct mds_obd *mds = &obd->u.mds; - struct file *filp = mds->mds_fid_filp; - struct lvfs_run_ctxt saved; - loff_t off = 0; - int rc; - ENTRY; - - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - - CDEBUG(D_SUPER, "MDS last_fid is "LPU64"\n", mds->mds_last_fid); - - rc = fsfilt_write_record(obd, filp, &mds->mds_last_fid, - sizeof(mds->mds_last_fid), - &off, force_sync); - if (rc) - CERROR("error writing MDS last_fid: rc = %d\n", rc); - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - - RETURN(rc); -} - -void mds_commit_last_transno_cb(struct obd_device *obd, - __u64 transno, void *data, - int error) -{ - obd_transno_commit_cb(obd, transno, error); -} - -void mds_commit_last_fid_cb(struct obd_device *obd, - __u64 fid, void *data, - int error) -{ - if (error) { - CERROR("%s: fid "LPD64" commit error: %d\n", - obd->obd_name, fid, error); - return; - } - - CDEBUG(D_HA, "%s: fid "LPD64" committed\n", - obd->obd_name, fid); -} - -/* - * allocates new lustre_id on passed @inode and saves it to inode EA. - */ -int mds_alloc_inode_sid(struct obd_device *obd, struct inode *inode, - void *handle, struct lustre_id *id) -{ - struct mds_obd *mds = &obd->u.mds; - int rc = 0; - ENTRY; - - LASSERT(id != NULL); - LASSERT(obd != NULL); - - id_group(id) = mds->mds_num; - - spin_lock(&mds->mds_fid_lock); - id_fid(id) = mds->mds_last_fid++; - spin_unlock(&mds->mds_fid_lock); - - id_ino(id) = inode->i_ino; - id_gen(id) = inode->i_generation; - id_type(id) = (S_IFMT & inode->i_mode); - - rc = mds_update_inode_sid(obd, inode, handle, id); - if (rc) { - CERROR("Can't update inode FID EA, " - "rc = %d\n", rc); - } - RETURN(rc); -} - -/* - * reads inode self id from inode EA. Probably later this should be replaced by - * caching inode self id to avoid raeding it every time it is needed. - */ -int mds_read_inode_sid(struct obd_device *obd, struct inode *inode, - struct lustre_id *id) -{ - int rc; - ENTRY; - - LASSERT(id != NULL); - LASSERT(obd != NULL); - LASSERT(inode != NULL); - - rc = fsfilt_get_sid(obd, inode, &id->li_fid, - sizeof(id->li_fid)); - if (rc < 0) { - CERROR("fsfilt_get_sid() failed, " - "rc = %d\n", rc); - RETURN(rc); - } else if (!rc) { - rc = -ENODATA; - RETURN(rc); - } else { - rc = 0; - } - - RETURN(rc); -} - -/* updates inode self id in EA. */ -int mds_update_inode_sid(struct obd_device *obd, struct inode *inode, - void *handle, struct lustre_id *id) -{ - int rc = 0; - ENTRY; - - LASSERT(id != NULL); - LASSERT(obd != NULL); - LASSERT(inode != NULL); - - rc = fsfilt_set_sid(obd, inode, handle, &id->li_fid, - sizeof(id->li_fid)); - if (rc) { - CERROR("fsfilt_set_sid() failed, rc = %d\n", rc); - RETURN(rc); - } - - RETURN(rc); -} - -/* - * reads inode id on master MDS. This is usualy done by CMOBD to update requests - * to master MDS by correct store cookie, needed to find inode on master MDS - * quickly. - */ -int mds_read_inode_mid(struct obd_device *obd, struct inode *inode, - struct lustre_id *id) -{ - int rc; - ENTRY; - - LASSERT(id != NULL); - LASSERT(obd != NULL); - LASSERT(inode != NULL); - - rc = fsfilt_get_mid(obd, inode, id, sizeof(*id)); - if (rc < 0) { - CERROR("fsfilt_get_mid() failed, " - "rc = %d\n", rc); - RETURN(rc); - } else if (!rc) { - rc = -ENODATA; - RETURN(rc); - } else { - rc = 0; - } - - RETURN(rc); -} - -/* - * updates master inode id. Usualy this is done by CMOBD after an inode is - * created and relationship between cache MDS and master one should be - * established. - */ -int mds_update_inode_mid(struct obd_device *obd, struct inode *inode, - void *handle, struct lustre_id *id) -{ - int rc = 0; - ENTRY; - - LASSERT(id != NULL); - LASSERT(obd != NULL); - LASSERT(inode != NULL); - - rc = fsfilt_set_mid(obd, inode, handle, id, sizeof(*id)); - if (rc) { - CERROR("fsfilt_set_mid() failed, rc = %d\n", rc); - RETURN(rc); - } - - RETURN(rc); -} - /* mount the file system (secretly) */ static int mds_setup(struct obd_device *obd, obd_count len, void *buf) { @@ -2616,11 +2223,9 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf) options = (char *)page; memset(options, 0, PAGE_SIZE); - /* - * here we use "iopen_nopriv" hardcoded, because it affects MDS utility + /* here we use "iopen_nopriv" hardcoded, because it affects MDS utility * and the rest of options are passed by mount options. Probably this - * should be moved to somewhere else like startup scripts or lconf. - */ + * should be moved to somewhere else like startup scripts or lconf. */ sprintf(options, "iopen_nopriv"); if (lcfg->lcfg_inllen4 > 0 && lcfg->lcfg_inlbuf4) @@ -2654,18 +2259,22 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf) } } - mds->mds_obd_type = MDS_MASTER_OBD; - - if (lcfg->lcfg_inllen6 > 0 && lcfg->lcfg_inlbuf6 && + /* FIXME-WANGDI: this should be reworked when we will use lmv along + * with cobd, because correct mdsnum is set in mds_lmv_connect(). */ + if (lcfg->lcfg_inllen6 > 0 && lcfg->lcfg_inlbuf6 && !mds->mds_lmv_obd && strcmp(lcfg->lcfg_inlbuf6, "dumb")) { - if (!memcmp(lcfg->lcfg_inlbuf6, "master", strlen("master"))) { - mds->mds_obd_type = MDS_MASTER_OBD; - } else if (!memcmp(lcfg->lcfg_inlbuf6, "cache", strlen("cache"))) { - mds->mds_obd_type = MDS_CACHE_OBD; + if (!memcmp(lcfg->lcfg_inlbuf6, "master", strlen("master")) && + mds->mds_num == 0) { + mds->mds_num = REAL_MDS_NUMBER; + } else if (!memcmp(lcfg->lcfg_inlbuf6, "cache", strlen("cache")) && + mds->mds_num == 0) { + mds->mds_num = CACHE_MDS_NUMBER; } } - mnt = do_kern_mount(lcfg->lcfg_inlbuf2, 0, lcfg->lcfg_inlbuf1, options); + mnt = do_kern_mount(lcfg->lcfg_inlbuf2, 0, + lcfg->lcfg_inlbuf1, options); + free_page(page); if (IS_ERR(mnt)) { @@ -2676,12 +2285,11 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf) CDEBUG(D_SUPER, "%s: mnt = %p\n", lcfg->lcfg_inlbuf1, mnt); + sema_init(&mds->mds_orphan_recovery_sem, 1); sema_init(&mds->mds_epoch_sem, 1); - spin_lock_init(&mds->mds_fid_lock); - atomic_set(&mds->mds_real_clients, 0); spin_lock_init(&mds->mds_transno_lock); - sema_init(&mds->mds_orphan_recovery_sem, 1); mds->mds_max_cookiesize = sizeof(struct llog_cookie); + atomic_set(&mds->mds_real_clients, 0); sprintf(ns_name, "mds-%s", obd->obd_uuid.uuid); obd->obd_namespace = ldlm_namespace_new(ns_name, LDLM_NAMESPACE_SERVER); @@ -2698,15 +2306,13 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf) obd->obd_name, rc); GOTO(err_ns, rc); } - + rc = llog_start_commit_thread(); if (rc < 0) GOTO(err_fs, rc); - /* - * this check for @dumb string is needed to handle mounting MDS with - * smfs. Read lconf:MDSDEV.write_conf() for more details. - */ + /* this check for @dumb string is needed to handle mounting MDS with + * smfs. Read lconf:MDSDEV.write_conf() for more details. */ if (lcfg->lcfg_inllen3 > 0 && lcfg->lcfg_inlbuf3 && strcmp(lcfg->lcfg_inlbuf3, "dumb")) { class_uuid_t uuid; @@ -2720,20 +2326,6 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf) memcpy(mds->mds_profile, lcfg->lcfg_inlbuf3, lcfg->lcfg_inllen3); - - /* - * setup root id in the case this is not clients write - * setup. This is important, as in the case of LMV we need - * mds->mds_num to be already assigned to form correct root fid. - */ - rc = mds_fs_setup_rootid(obd); - if (rc) - GOTO(err_fs, rc); - - /* setup lustre id for ID directory. */ - rc = mds_fs_setup_virtid(obd); - if (rc) - GOTO(err_fs, rc); } ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL, @@ -2802,7 +2394,7 @@ static int mds_postsetup(struct obd_device *obd) CERROR("No profile found: %s\n", mds->mds_profile); GOTO(err_cleanup, rc = -ENOENT); } - rc = mds_lov_connect(obd, lprof->lp_lov); + rc = mds_lov_connect(obd, lprof->lp_osc); if (rc) GOTO(err_cleanup, rc); @@ -2848,7 +2440,7 @@ int mds_postrecov(struct obd_device *obd) group = FILTER_GROUP_FIRST_MDS + mds->mds_num; valsize = sizeof(group); - rc = obd_set_info(mds->mds_lov_exp, strlen("mds_conn"), "mds_conn", + rc = obd_set_info(mds->mds_osc_exp, strlen("mds_conn"), "mds_conn", valsize, &group); if (rc) GOTO(out, rc); @@ -2885,9 +2477,8 @@ int mds_lov_clean(struct obd_device *obd) if (mds->mds_profile) { char * cln_prof; - struct llog_ctxt *llctx; - struct lvfs_run_ctxt saved; struct config_llog_instance cfg; + struct lvfs_run_ctxt saved; int len = strlen(mds->mds_profile) + sizeof("-clean") + 1; OBD_ALLOC(cln_prof, len); @@ -2897,9 +2488,8 @@ int mds_lov_clean(struct obd_device *obd) cfg.cfg_uuid = mds->mds_lov_uuid; push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - llctx = llog_get_context(&obd->obd_llogs, - LLOG_CONFIG_ORIG_CTXT); - class_config_process_llog(llctx, cln_prof, &cfg); + class_config_process_llog(llog_get_context(&obd->obd_llogs, LLOG_CONFIG_ORIG_CTXT), + cln_prof, &cfg); pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); OBD_FREE(cln_prof, len); @@ -2940,27 +2530,23 @@ static int mds_cleanup(struct obd_device *obd, int flags) if (mds->mds_sb == NULL) RETURN(0); - mds_update_last_fid(obd, 1); mds_update_server_data(obd, 1); - if (mds->mds_lov_objids != NULL) { - int size = mds->mds_lov_desc.ld_tgt_count * - sizeof(obd_id); - OBD_FREE(mds->mds_lov_objids, size); + OBD_FREE(mds->mds_lov_objids, + mds->mds_lov_desc.ld_tgt_count * sizeof(obd_id)); } mds_fs_cleanup(obd, flags); unlock_kernel(); - /* - * 2 seems normal on mds, (may_umount() also expects 2 fwiw), but we - * only see 1 at this point in obdfilter. - */ + /* 2 seems normal on mds, (may_umount() also expects 2 + fwiw), but we only see 1 at this point in obdfilter. */ if (atomic_read(&obd->u.mds.mds_vfsmnt->mnt_count) > 2) CERROR("%s: mount busy, mnt_count %d != 2\n", obd->obd_name, atomic_read(&obd->u.mds.mds_vfsmnt->mnt_count)); mntput(mds->mds_vfsmnt); + mds->mds_sb = 0; ldlm_namespace_free(obd->obd_namespace, flags & OBD_OPT_FORCE); @@ -3090,11 +2676,10 @@ static int mds_intent_policy(struct ldlm_namespace *ns, if (rc) RETURN(req->rq_status = rc); - rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep)); - LASSERT(rep != NULL); - + rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*rep)); intent_set_disposition(rep, DISP_IT_EXECD); + /* execute policy */ switch ((long)it->opc) { case IT_OPEN: @@ -3169,6 +2754,7 @@ static int mds_intent_policy(struct ldlm_namespace *ns, LASSERTF(new_lock != NULL, "op "LPX64" lockh "LPX64"\n", it->opc, lockh[0].cookie); + /* If we've already given this lock to a client once, then we should * have no readers or writers. Otherwise, we should have one reader * _or_ writer ref (which will be zeroed below) before returning the @@ -3319,27 +2905,24 @@ static int mdt_cleanup(struct obd_device *obd, int flags) RETURN(0); } -static struct dentry *mds_lvfs_id2dentry(__u64 ino, __u32 gen, - __u64 gr, void *data) +static struct dentry *mds_lvfs_fid2dentry(__u64 id, __u32 gen, __u64 gr, + void *data) { - struct lustre_id id; struct obd_device *obd = data; - - id_ino(&id) = ino; - id_gen(&id) = gen; - return mds_id2dentry(obd, &id, NULL); + struct ll_fid fid; + fid.id = id; + fid.generation = gen; + return mds_fid2dentry(&obd->u.mds, &fid, NULL); } static int mds_get_info(struct obd_export *exp, __u32 keylen, - void *key, __u32 *valsize, void *val) + void *key, __u32 *vallen, void *val) { struct obd_device *obd; struct mds_obd *mds; ENTRY; obd = class_exp2obd(exp); - mds = &obd->u.mds; - if (obd == NULL) { CDEBUG(D_IOCTL, "invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); @@ -3347,47 +2930,34 @@ static int mds_get_info(struct obd_export *exp, __u32 keylen, } if (keylen >= strlen("reint_log") && memcmp(key, "reint_log", 9) == 0) { - /* get log_context handle. */ + /*Get log_context handle*/ unsigned long *llh_handle = val; - *valsize = sizeof(unsigned long); + *vallen = sizeof(unsigned long); *llh_handle = (unsigned long)obd->obd_llog_ctxt[LLOG_REINT_ORIG_CTXT]; RETURN(0); } if (keylen >= strlen("cache_sb") && memcmp(key, "cache_sb", 8) == 0) { - /* get log_context handle. */ + /*Get log_context handle*/ unsigned long *sb = val; - *valsize = sizeof(unsigned long); + *vallen = sizeof(unsigned long); *sb = (unsigned long)obd->u.mds.mds_sb; RETURN(0); } + mds = &obd->u.mds; if (keylen >= strlen("mdsize") && memcmp(key, "mdsize", keylen) == 0) { __u32 *mdsize = val; - *valsize = sizeof(*mdsize); + *vallen = sizeof(*mdsize); *mdsize = mds->mds_max_mdsize; RETURN(0); } - if (keylen >= strlen("mdsnum") && strcmp(key, "mdsnum") == 0) { - __u32 *mdsnum = val; - *valsize = sizeof(*mdsnum); - *mdsnum = mds->mds_num; - RETURN(0); - } - - if (keylen >= strlen("rootid") && strcmp(key, "rootid") == 0) { - struct lustre_id *rootid = val; - *valsize = sizeof(struct lustre_id); - *rootid = mds->mds_rootid; - RETURN(0); - } - CDEBUG(D_IOCTL, "invalid key\n"); RETURN(-EINVAL); } struct lvfs_callback_ops mds_lvfs_ops = { - l_id2dentry: mds_lvfs_id2dentry, + l_fid2dentry: mds_lvfs_fid2dentry, }; int mds_preprw(int cmd, struct obd_export *exp, struct obdo *oa, @@ -3395,7 +2965,6 @@ int mds_preprw(int cmd, struct obd_export *exp, struct obdo *oa, int niocount, struct niobuf_remote *nb, struct niobuf_local *res, struct obd_trans_info *oti); - int mds_commitrw(int cmd, struct obd_export *exp, struct obdo *oa, int objcount, struct obd_ioobj *obj, int niocount, struct niobuf_local *res, struct obd_trans_info *oti, @@ -3433,6 +3002,8 @@ static struct obd_ops mdt_obd_ops = { .o_detach = mdt_detach, .o_setup = mdt_setup, .o_cleanup = mdt_cleanup, + .o_attach = mdt_attach, + .o_detach = mdt_detach, }; static int __init mds_init(void) diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index 8c84f25..712b206 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -50,7 +50,6 @@ #define LAST_RCVD "last_rcvd" #define LOV_OBJID "lov_objid" -#define LAST_FID "last_fid" /* Add client data to the MDS. We use a bitmap to locate a free space * in the last_rcvd file if cl_off is -1 (i.e. a new client). @@ -190,46 +189,6 @@ static int mds_server_free_data(struct mds_obd *mds) return 0; } -static int mds_read_last_fid(struct obd_device *obd, struct file *file) -{ - int rc = 0; - loff_t off = 0; - struct mds_obd *mds = &obd->u.mds; - unsigned long last_fid_size = file->f_dentry->d_inode->i_size; - ENTRY; - - if (last_fid_size == 0) { - CWARN("%s: initializing new %s\n", obd->obd_name, - file->f_dentry->d_name.name); - - /* - * as fid is used for forming res_id for locking, it should not - * be zero. This will keep us out of lots possible problems, - * asserts, etc. - */ - mds->mds_last_fid = 1; - } else { - __u64 last_fid; - - rc = fsfilt_read_record(obd, file, &last_fid, - sizeof(last_fid), &off); - if (rc) { - CERROR("error reading MDS %s: rc = %d\n", - file->f_dentry->d_name.name, rc); - RETURN(rc); - } - - if (last_fid > mds->mds_last_fid) - mds->mds_last_fid = last_fid; - } - - CDEBUG(D_INODE, "%s: server last_fid: "LPU64"\n", - obd->obd_name, mds->mds_last_fid); - - rc = mds_update_last_fid(obd, 1); - RETURN(rc); -} - static int mds_read_last_rcvd(struct obd_device *obd, struct file *file) { struct mds_obd *mds = &obd->u.mds; @@ -261,8 +220,7 @@ static int mds_read_last_rcvd(struct obd_device *obd, struct file *file) mds->mds_server_data = msd; if (last_rcvd_size == 0) { - CWARN("%s: initializing new %s\n", obd->obd_name, - file->f_dentry->d_name.name); + CWARN("%s: initializing new %s\n", obd->obd_name, LAST_RCVD); memcpy(msd->msd_uuid, obd->obd_uuid.uuid,sizeof(msd->msd_uuid)); msd->msd_last_transno = 0; @@ -274,8 +232,7 @@ static int mds_read_last_rcvd(struct obd_device *obd, struct file *file) } else { rc = fsfilt_read_record(obd, file, msd, sizeof(*msd), &off); if (rc) { - CERROR("error reading MDS %s: rc = %d\n", - file->f_dentry->d_name.name, rc); + CERROR("error reading MDS %s: rc = %d\n", LAST_RCVD, rc); GOTO(err_msd, rc); } if (strcmp(msd->msd_uuid, obd->obd_uuid.uuid) != 0) { @@ -343,7 +300,7 @@ static int mds_read_last_rcvd(struct obd_device *obd, struct file *file) rc = fsfilt_read_record(obd, file, mcd, sizeof(*mcd), &off); if (rc) { CERROR("error reading MDS %s idx %d, off %llu: rc %d\n", - file->f_dentry->d_name.name, cl_idx, off, rc); + LAST_RCVD, cl_idx, off, rc); break; /* read error shouldn't cause startup to fail */ } @@ -417,143 +374,26 @@ err_msd: RETURN(rc); } -static int mds_fs_post_setup(struct obd_device *obd) +static int mds_fs_post_setup(struct obd_device *obd) { struct mds_obd *mds = &obd->u.mds; - struct dentry *dentry; - int rc = 0; + struct dentry *de = mds_fid2dentry(mds, &mds->mds_rootfid, NULL); + int rc = 0; - dentry = mds_id2dentry(obd, &mds->mds_rootid, NULL); - rc = fsfilt_post_setup(obd, dentry); + rc = fsfilt_post_setup(obd, de); if (rc) - GOTO(out_dentry, rc); + GOTO(out, rc); - fsfilt_set_fs_flags(obd, dentry->d_inode, - SM_DO_REC | SM_DO_COW); - + fsfilt_set_fs_flags(obd, de->d_inode, + SM_DO_REC | SM_DO_COW); fsfilt_set_fs_flags(obd, mds->mds_pending_dir->d_inode, - SM_DO_REC | SM_DO_COW); - + SM_DO_REC | SM_DO_COW); fsfilt_set_mds_flags(obd, mds->mds_sb); -out_dentry: - l_dput(dentry); +out: + l_dput(de); return rc; } -/* - * sets up root inode id. It tries to read it first from root inode and if it is - * not there, new rootid is allocated and saved there. - */ -int mds_fs_setup_rootid(struct obd_device *obd) -{ - int rc = 0; - void *handle; - struct inode *inode; - struct dentry *dentry; - struct lustre_id rootid; - struct mds_obd *mds = &obd->u.mds; - ENTRY; - - memcpy(&rootid, &mds->mds_rootid, sizeof(rootid)); - - /* getting root directory and setup its fid. */ - dentry = mds_id2dentry(obd, &rootid, NULL); - if (IS_ERR(dentry)) - RETURN(PTR_ERR(dentry)); - - inode = dentry->d_inode; - - rc = mds_pack_inode2id(obd, &rootid, inode, 1); - if (rc < 0) { - if (rc != -ENODATA) - GOTO(out_dentry, rc); - } else { - /* - * rootid is filled by mds_read_inode_sid(), so we do not need - * to allocate it and update. The only thing we need to check is - * mds_num. - */ - LASSERT(id_group(&rootid) == mds->mds_num); - GOTO(out_dentry, rc); - } - - /* allocating new one, as it is not found in root inode. */ - handle = fsfilt_start(obd, inode, - FSFILT_OP_SETATTR, NULL); - - if (IS_ERR(handle)) { - rc = PTR_ERR(handle); - CERROR("fsfilt_start() failed, rc = %d\n", rc); - GOTO(out_dentry, rc); - } - - down(&inode->i_sem); - rc = mds_alloc_inode_sid(obd, inode, handle, &rootid); - up(&inode->i_sem); - - if (rc) { - CERROR("mds_alloc_inode_sid() failed, rc = %d\n", - rc); - GOTO(out_dentry, rc); - } - - rc = fsfilt_commit(obd, mds->mds_sb, inode, handle, 0); - if (rc) - CERROR("fsfilt_commit() failed, rc = %d\n", rc); - -out_dentry: - l_dput(dentry); - - if (rc == 0) { - memcpy(&mds->mds_rootid, &rootid, sizeof(rootid)); - CWARN("%s: rootid: "DLID4"\n", obd->obd_name, - OLID4(&rootid)); - } - RETURN(rc); -} - -/* - * initializes lustre_id for virtual id directory, it is needed sometimes, as it - * is possible that it will be the parent for object an operations is going to - * be performed on. - */ -int mds_fs_setup_virtid(struct obd_device *obd) -{ - int rc = 0; - void *handle; - struct lustre_id id; - struct mds_obd *mds = &obd->u.mds; - struct inode *inode = mds->mds_id_dir->d_inode; - ENTRY; - - handle = fsfilt_start(obd, inode, - FSFILT_OP_SETATTR, NULL); - - if (IS_ERR(handle)) { - rc = PTR_ERR(handle); - CERROR("fsfilt_start() failed, rc = %d\n", rc); - RETURN(rc); - } - - down(&inode->i_sem); - rc = mds_alloc_inode_sid(obd, inode, handle, &id); - up(&inode->i_sem); - - if (rc) { - CERROR("mds_alloc_inode_sid() failed, rc = %d\n", - rc); - RETURN(rc); - } - - rc = fsfilt_commit(obd, mds->mds_sb, inode, handle, 0); - if (rc) { - CERROR("fsfilt_commit() failed, rc = %d\n", rc); - RETURN(rc); - } - - RETURN(rc); -} - int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt) { struct mds_obd *mds = &obd->u.mds; @@ -580,7 +420,6 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt) /* setup the directory tree */ push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - dentry = simple_mkdir(current->fs->pwd, "ROOT", 0755, 0); if (IS_ERR(dentry)) { rc = PTR_ERR(dentry); @@ -588,11 +427,12 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt) GOTO(err_pop, rc); } - mdc_pack_id(&mds->mds_rootid, dentry->d_inode->i_ino, - dentry->d_inode->i_generation, S_IFDIR, 0, 0); + mds->mds_rootfid.id = dentry->d_inode->i_ino; + mds->mds_rootfid.generation = dentry->d_inode->i_generation; + mds->mds_rootfid.f_type = S_IFDIR; dput(dentry); - + dentry = lookup_one_len("__iopen__", current->fs->pwd, strlen("__iopen__")); if (IS_ERR(dentry)) { @@ -600,19 +440,18 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt) CERROR("cannot lookup __iopen__ directory: rc = %d\n", rc); GOTO(err_pop, rc); } - mds->mds_id_de = dentry; - if (!dentry->d_inode) { rc = -ENOENT; CERROR("__iopen__ directory has no inode? rc = %d\n", rc); - GOTO(err_id_de, rc); + GOTO(err_fid, rc); } + mds->mds_fid_de = dentry; dentry = simple_mkdir(current->fs->pwd, "PENDING", 0777, 1); if (IS_ERR(dentry)) { rc = PTR_ERR(dentry); CERROR("cannot create PENDING directory: rc = %d\n", rc); - GOTO(err_id_de, rc); + GOTO(err_fid, rc); } mds->mds_pending_dir = dentry; @@ -636,9 +475,9 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt) if (IS_ERR(dentry)) { rc = PTR_ERR(dentry); CERROR("cannot create FIDS directory: rc = %d\n", rc); - GOTO(err_objects, rc); + GOTO(err_fids, rc); } - mds->mds_id_dir = dentry; + mds->mds_fids_dir = dentry; dentry = simple_mkdir(current->fs->pwd, "UNNAMED", 0777, 1); if (IS_ERR(dentry)) { @@ -653,10 +492,9 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt) if (IS_ERR(file)) { rc = PTR_ERR(file); CERROR("cannot open/create %s file: rc = %d\n", LAST_RCVD, rc); - GOTO(err_id_dir, rc = PTR_ERR(file)); + GOTO(err_objects, rc = PTR_ERR(file)); } mds->mds_rcvd_filp = file; - if (!S_ISREG(file->f_dentry->d_inode->i_mode)) { CERROR("%s is not a regular file!: mode = %o\n", LAST_RCVD, file->f_dentry->d_inode->i_mode); @@ -669,33 +507,12 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt) GOTO(err_last_rcvd, rc); } - /* open and test the last fid file */ - file = filp_open(LAST_FID, O_RDWR | O_CREAT, 0644); - if (IS_ERR(file)) { - rc = PTR_ERR(file); - CERROR("cannot open/create %s file: rc = %d\n", - LAST_FID, rc); - GOTO(err_client, rc = PTR_ERR(file)); - } - mds->mds_fid_filp = file; - if (!S_ISREG(file->f_dentry->d_inode->i_mode)) { - CERROR("%s is not a regular file!: mode = %o\n", - LAST_FID, file->f_dentry->d_inode->i_mode); - GOTO(err_last_fid, rc = -ENOENT); - } - - rc = mds_read_last_fid(obd, file); - if (rc) { - CERROR("cannot read %s: rc = %d\n", LAST_FID, rc); - GOTO(err_last_fid, rc); - } - - /* open and test the lov objid file */ + /* open and test the lov objd file */ file = filp_open(LOV_OBJID, O_RDWR | O_CREAT, 0644); if (IS_ERR(file)) { rc = PTR_ERR(file); CERROR("cannot open/create %s file: rc = %d\n", LOV_OBJID, rc); - GOTO(err_last_fid, rc = PTR_ERR(file)); + GOTO(err_client, rc = PTR_ERR(file)); } mds->mds_lov_objid_filp = file; if (!S_ISREG(file->f_dentry->d_inode->i_mode)) { @@ -715,9 +532,6 @@ err_pop: err_lov_objid: if (mds->mds_lov_objid_filp && filp_close(mds->mds_lov_objid_filp, 0)) CERROR("can't close %s after error\n", LOV_OBJID); -err_last_fid: - if (mds->mds_fid_filp && filp_close(mds->mds_fid_filp, 0)) - CERROR("can't close %s after error\n", LAST_FID); err_client: class_disconnect_exports(obd, 0); err_last_rcvd: @@ -725,16 +539,16 @@ err_last_rcvd: CERROR("can't close %s after error\n", LAST_RCVD); err_unnamed: dput(mds->mds_unnamed_dir); -err_id_dir: - dput(mds->mds_id_dir); +err_fids: + dput(mds->mds_fids_dir); err_objects: dput(mds->mds_objects_dir); err_logs: dput(mds->mds_logs_dir); err_pending: dput(mds->mds_pending_dir); -err_id_de: - dput(mds->mds_id_de); +err_fid: + dput(mds->mds_fid_de); goto err_pop; } @@ -760,17 +574,11 @@ int mds_fs_cleanup(struct obd_device *obd, int flags) mds_server_free_data(mds); push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - if (mds->mds_fid_filp) { - rc = filp_close(mds->mds_fid_filp, 0); - mds->mds_fid_filp = NULL; - if (rc) - CERROR("%s file won't close, rc = %d\n", LAST_FID, rc); - } if (mds->mds_rcvd_filp) { rc = filp_close(mds->mds_rcvd_filp, 0); mds->mds_rcvd_filp = NULL; if (rc) - CERROR("%s file won't close, rc = %d\n", LAST_RCVD, rc); + CERROR("%s file won't close, rc=%d\n", LAST_RCVD, rc); } if (mds->mds_lov_objid_filp) { rc = filp_close(mds->mds_lov_objid_filp, 0); @@ -782,9 +590,9 @@ int mds_fs_cleanup(struct obd_device *obd, int flags) l_dput(mds->mds_unnamed_dir); mds->mds_unnamed_dir = NULL; } - if (mds->mds_id_dir != NULL) { - l_dput(mds->mds_id_dir); - mds->mds_id_dir = NULL; + if (mds->mds_fids_dir != NULL) { + l_dput(mds->mds_fids_dir); + mds->mds_fids_dir = NULL; } if (mds->mds_objects_dir != NULL) { l_dput(mds->mds_objects_dir); @@ -801,15 +609,15 @@ int mds_fs_cleanup(struct obd_device *obd, int flags) rc = mds_fs_post_cleanup(obd); pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - shrink_dcache_parent(mds->mds_id_de); - dput(mds->mds_id_de); + shrink_dcache_parent(mds->mds_fid_de); + dput(mds->mds_fid_de); return rc; } -/* Creates an object with the same name as its id. Because this is not at all +/* Creates an object with the same name as its fid. Because this is not at all * performance sensitive, it is accomplished by creating a file, checking the - * id, and renaming it. */ + * fid, and renaming it. */ int mds_obd_create(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md **ea, struct obd_trans_info *oti) { @@ -818,16 +626,17 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa, struct file *filp; struct dentry *dchild; struct lvfs_run_ctxt saved; - char idname[LL_ID_NAMELEN]; - int rc = 0, err, idlen; + char fidname[LL_FID_NAMELEN]; void *handle; + int rc = 0, err, namelen; ENTRY; push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL); down(&parent_inode->i_sem); if (oa->o_id) { - idlen = ll_id2str(idname, oa->o_id, oa->o_generation); - dchild = lookup_one_len(idname, mds->mds_objects_dir, idlen); + namelen = ll_fid2str(fidname, oa->o_id, oa->o_generation); + + dchild = lookup_one_len(fidname, mds->mds_objects_dir, namelen); if (IS_ERR(dchild)) GOTO(out_pop, rc = PTR_ERR(dchild)); @@ -860,17 +669,16 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa, GOTO(out_pop, rc); } - sprintf(idname, "OBJECTS/%u.%u", ll_insecure_random_int(), current->pid); - filp = filp_open(idname, O_CREAT | O_EXCL, 0644); + sprintf(fidname, "OBJECTS/%u.%u",ll_insecure_random_int(),current->pid); + filp = filp_open(fidname, O_CREAT | O_EXCL, 0644); if (IS_ERR(filp)) { rc = PTR_ERR(filp); if (rc == -EEXIST) { CERROR("impossible object name collision %s\n", - idname); + fidname); LBUG(); } - CERROR("error creating tmp object %s: rc %d\n", - idname, rc); + CERROR("error creating tmp object %s: rc %d\n", fidname, rc); GOTO(out_pop, rc); } @@ -878,12 +686,11 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa, oa->o_id = filp->f_dentry->d_inode->i_ino; oa->o_generation = filp->f_dentry->d_inode->i_generation; - idlen = ll_id2str(idname, oa->o_id, oa->o_generation); - - CWARN("created log anonymous "LPU64"/%u\n", - oa->o_id, oa->o_generation); + namelen = ll_fid2str(fidname, oa->o_id, oa->o_generation); + CWARN("created log anonymous "LPU64"/%u\n", oa->o_id, oa->o_generation); + + dchild = lookup_one_len(fidname, mds->mds_objects_dir, namelen); - dchild = lookup_one_len(idname, mds->mds_objects_dir, idlen); if (IS_ERR(dchild)) { CERROR("getting neg dentry for obj rename: %d\n", rc); GOTO(out_close, rc = PTR_ERR(dchild)); @@ -919,7 +726,7 @@ out_dput: out_close: err = filp_close(filp, 0); if (err) { - CERROR("closing tmpfile %s: rc %d\n", idname, rc); + CERROR("closing tmpfile %s: rc %d\n", fidname, rc); if (!rc) rc = err; } @@ -936,22 +743,22 @@ int mds_obd_destroy(struct obd_export *exp, struct obdo *oa, struct inode *parent_inode = mds->mds_objects_dir->d_inode; struct obd_device *obd = exp->exp_obd; struct lvfs_run_ctxt saved; - char idname[LL_ID_NAMELEN]; + char fidname[LL_FID_NAMELEN]; struct dentry *de; void *handle; - int err, idlen, rc = 0; + int err, namelen, rc = 0; ENTRY; push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - idlen = ll_id2str(idname, oa->o_id, oa->o_generation); + namelen = ll_fid2str(fidname, oa->o_id, oa->o_generation); down(&parent_inode->i_sem); - de = lookup_one_len(idname, mds->mds_objects_dir, idlen); + de = lookup_one_len(fidname, mds->mds_objects_dir, namelen); if (IS_ERR(de) || de->d_inode == NULL) { rc = IS_ERR(de) ? PTR_ERR(de) : -ENOENT; CERROR("destroying non-existent object "LPU64" %s: rc %d\n", - oa->o_id, idname, rc); + oa->o_id, fidname, rc); GOTO(out_dput, rc); } /* Stripe count is 1 here since this is some MDS specific stuff diff --git a/lustre/mds/mds_groups.c b/lustre/mds/mds_groups.c index 33aba61..5231255 100644 --- a/lustre/mds/mds_groups.c +++ b/lustre/mds/mds_groups.c @@ -83,7 +83,7 @@ struct mds_grp_hash *__mds_get_global_group_hash() return &_group_hash; } -static struct mds_grp_hash_entry *alloc_entry(uid_t uid) +static struct mds_grp_hash_entry * alloc_entry(uid_t uid) { struct mds_grp_hash_entry *entry; @@ -172,17 +172,18 @@ static int refresh_entry(struct mds_grp_hash *hash, RETURN(rc); } -struct mds_grp_hash_entry *mds_get_group_entry(struct mds_obd *mds, uid_t uid) +struct mds_grp_hash_entry * mds_get_group_entry(struct mds_obd *mds, uid_t uid) { - struct mds_grp_hash_entry *entry = NULL, *new = NULL, *next; struct mds_grp_hash *hash = &_group_hash; + struct mds_grp_hash_entry *entry = NULL, *new = NULL, *next; struct list_head *head; wait_queue_t wait; int rc, found; ENTRY; + LASSERT(hash); + head = &hash->gh_table[MDSGRP_HASH_INDEX(uid)]; - find_again: found = 0; spin_lock(&hash->gh_lock); @@ -223,7 +224,7 @@ find_again: GRP_SET_ACQUIRING(entry); GRP_CLEAR_NEW(entry); entry->ge_acquire_expire = jiffies + - hash->gh_acquire_expire * HZ; + hash->gh_acquire_expire * HZ; spin_unlock(&hash->gh_lock); rc = refresh_entry(hash, entry); @@ -235,10 +236,8 @@ find_again: } /* fall through */ } - - /* - * someone (and only one) is doing upcall upon this item, just wait it - * complete + /* someone (and only one) is doing upcall upon + * this item, just wait it complete */ if (GRP_IS_ACQUIRING(entry)) { init_waitqueue_entry(&wait, current); @@ -268,15 +267,15 @@ find_again: RETURN(NULL); } - /* - * check expired. We can't refresh the existed one because some memory - * might be shared by multiple processes. + /* check expired + * We can't refresh the existed one because some + * memory might be shared by multiple processes. */ if (check_unlink_entry(entry)) { - /* - * if expired, try again. but if this entry is created by me but - * too quickly turn to expired without any error, should at - * least give a chance to use it once. + /* if expired, try again. but if this entry is + * created by me but too quickly turn to expired + * without any error, should at least give a + * chance to use it once. */ if (entry != new) { put_entry(entry); @@ -291,6 +290,7 @@ find_again: RETURN(entry); } + void mds_put_group_entry(struct mds_obd *mds, struct mds_grp_hash_entry *entry) { struct mds_grp_hash *hash = &_group_hash; diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h index 19fd8cd..3d4750e 100644 --- a/lustre/mds/mds_internal.h +++ b/lustre/mds/mds_internal.h @@ -103,13 +103,13 @@ int enqueue_ordered_locks(struct obd_device *obd, struct ldlm_res_id *p1_res_id, struct ldlm_res_id *p2_res_id, struct lustre_handle *p2_lockh, int p2_lock_mode, ldlm_policy_data_t *p2_policy); - +void mds_commit_cb(struct obd_device *, __u64 last_rcvd, void *data, int error); int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle, struct ptlrpc_request *req, int rc, __u32 op_data); void mds_reconstruct_generic(struct ptlrpc_request *req); void mds_req_from_mcd(struct ptlrpc_request *req, struct mds_client_data *mcd); int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds, - struct lustre_id *id, + struct ll_fid *fid, struct lustre_handle *parent_lockh, struct dentry **dparentp, int parent_mode, __u64 parent_lockpart, int *update_mode, @@ -187,59 +187,20 @@ void mds_squash_root(struct mds_obd *mds, struct mds_req_sec_desc *rsd, int mds_handle(struct ptlrpc_request *req); extern struct lvfs_callback_ops mds_lvfs_ops; int mds_lov_clean(struct obd_device *obd); +extern int mds_iocontrol(unsigned int cmd, struct obd_export *exp, + int len, void *karg, void *uarg); +extern int mds_lock_mode_for_dir(struct obd_device *, struct dentry *, int); int mds_postrecov(struct obd_device *obd); -extern struct lvfs_callback_ops mds_lvfs_ops; - -extern int mds_iocontrol(unsigned int cmd, - struct obd_export *exp, - int len, void *karg, - void *uarg); - -extern int mds_lock_mode_for_dir(struct obd_device *, - struct dentry *, int); - -int mds_fs_setup_rootid(struct obd_device *obd); -int mds_fs_setup_virtid(struct obd_device *obd); - -int mds_alloc_inode_sid(struct obd_device *, struct inode *, - void *, struct lustre_id *); - -int mds_update_inode_sid(struct obd_device *, struct inode *, - void *, struct lustre_id *); - -int mds_read_inode_sid(struct obd_device *, struct inode *, - struct lustre_id *); - -int mds_update_inode_mid(struct obd_device *, struct inode *, - void *, struct lustre_id *); - -int mds_read_inode_mid(struct obd_device *, struct inode *, - struct lustre_id *); - -void mds_commit_last_fid_cb(struct obd_device *, __u64 fid, - void *data, int error); - -void mds_commit_last_transno_cb(struct obd_device *, __u64 transno, - void *data, int error); #ifdef __KERNEL__ -int mds_get_md(struct obd_device *, struct inode *, void *md, - int *size, int lock); - +int mds_get_md(struct obd_device *, struct inode *, void *md, int *size, + int lock); int mds_pack_md(struct obd_device *, struct lustre_msg *, int offset, struct mds_body *, struct inode *, int lock); - -int mds_pack_inode2id(struct obd_device *, struct lustre_id *, - struct inode *, int); - -void mds_pack_inode2body(struct obd_device *, struct mds_body *, - struct inode *, int); - -void mds_pack_dentry2id(struct obd_device *, struct lustre_id *, - struct dentry *, int); - -void mds_pack_dentry2body(struct obd_device *, struct mds_body *b, - struct dentry *, int); +void mds_pack_dentry2fid(struct ll_fid *, struct dentry *); +void mds_pack_dentry2body(struct mds_body *b, struct dentry *dentry); +void mds_pack_inode2fid(struct obd_device *, struct ll_fid *, struct inode *); +void mds_pack_inode2body(struct obd_device *, struct mds_body *, struct inode *); #endif /* mds/mds_lmv.c */ diff --git a/lustre/mds/mds_lib.c b/lustre/mds/mds_lib.c index b4449eb..0e2f69d 100644 --- a/lustre/mds/mds_lib.c +++ b/lustre/mds/mds_lib.c @@ -49,6 +49,8 @@ #include #include "mds_internal.h" +#include "mds_internal.h" + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4) struct group_info *groups_alloc(int ngroups) { @@ -143,6 +145,7 @@ int groups_search(struct group_info *ginfo, gid_t grp) } return 0; } + #endif void groups_from_buffer(struct group_info *ginfo, __u32 *gids) @@ -158,74 +161,48 @@ void groups_from_buffer(struct group_info *ginfo, __u32 *gids) } } -void mds_pack_dentry2id(struct obd_device *obd, - struct lustre_id *id, - struct dentry *dentry, - int read_fid) +void mds_pack_dentry2fid(struct ll_fid *fid, struct dentry *dentry) { - id_ino(id) = dentry->d_inum; - id_gen(id) = dentry->d_generation; - - if (read_fid) { - id_fid(id) = dentry->d_fid; - id_group(id) = dentry->d_mdsnum; - } + fid->id = dentry->d_inum; + fid->generation = dentry->d_generation; + fid->mds = dentry->d_mdsnum; } -void mds_pack_dentry2body(struct obd_device *obd, - struct mds_body *b, - struct dentry *dentry, - int read_fid) +void mds_pack_dentry2body(struct mds_body *b, struct dentry *dentry) { - b->valid |= OBD_MD_FLID | OBD_MD_FLGENER | - OBD_MD_MDS; - - if (read_fid) - b->valid |= OBD_MD_FID; - - mds_pack_dentry2id(obd, &b->id1, dentry, - read_fid); + b->valid |= OBD_MD_FLID | OBD_MD_FLGENER; + b->ino = dentry->d_inum; + b->generation = dentry->d_generation; + b->mds = dentry->d_mdsnum; } -int mds_pack_inode2id(struct obd_device *obd, - struct lustre_id *id, - struct inode *inode, - int read_fid) +void mds_pack_inode2fid(struct obd_device *obd, struct ll_fid *fid, + struct inode *inode) { - int rc = 0; - ENTRY; - - if (read_fid) { - /* we have to avoid deadlock. */ - if (!down_trylock(&inode->i_sem)) { - rc = mds_read_inode_sid(obd, inode, id); - up(&inode->i_sem); - } else { - rc = mds_read_inode_sid(obd, inode, id); - } - } - if (rc == 0) { - id_ino(id) = inode->i_ino; - id_gen(id) = inode->i_generation; - id_type(id) = (S_IFMT & inode->i_mode); + if (!obd || !fid || !inode) { + printk("obd %p, fid %p, inode %p\n", obd, fid, inode); + LBUG(); } - RETURN(rc); + fid->id = inode->i_ino; + fid->generation = inode->i_generation; + fid->f_type = (S_IFMT & inode->i_mode); + fid->mds = obd->u.mds.mds_num; } /* Note that we can copy all of the fields, just some will not be "valid" */ void mds_pack_inode2body(struct obd_device *obd, struct mds_body *b, - struct inode *inode, int read_fid) + struct inode *inode) { b->valid |= OBD_MD_FLID | OBD_MD_FLCTIME | OBD_MD_FLUID | - OBD_MD_FLGID | OBD_MD_FLFLAGS | OBD_MD_FLTYPE | - OBD_MD_FLMODE | OBD_MD_FLNLINK | OBD_MD_FLGENER | - OBD_MD_FLATIME | OBD_MD_FLMTIME; /* bug 2020 */ - - if (!S_ISREG(inode->i_mode)) { - b->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | - OBD_MD_FLATIME | OBD_MD_FLMTIME | - OBD_MD_FLRDEV; - } + OBD_MD_FLGID | OBD_MD_FLFLAGS | OBD_MD_FLTYPE | + OBD_MD_FLMODE | OBD_MD_FLNLINK | OBD_MD_FLGENER | + OBD_MD_FLATIME | OBD_MD_FLMTIME; /* bug 2020 */ + + if (!S_ISREG(inode->i_mode)) + b->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLATIME | + OBD_MD_FLMTIME | OBD_MD_FLRDEV; + + b->ino = inode->i_ino; b->atime = LTIME_S(inode->i_atime); b->mtime = LTIME_S(inode->i_mtime); b->ctime = LTIME_S(inode->i_ctime); @@ -236,7 +213,6 @@ void mds_pack_inode2body(struct obd_device *obd, struct mds_body *b, b->gid = inode->i_gid; b->flags = inode->i_flags; b->rdev = inode->i_rdev; - /* Return the correct link count for orphan inodes */ if (mds_inode_is_orphan(inode)) { b->nlink = 0; @@ -245,9 +221,8 @@ void mds_pack_inode2body(struct obd_device *obd, struct mds_body *b, } else { b->nlink = inode->i_nlink; } - if (read_fid) - b->valid |= OBD_MD_FID; - mds_pack_inode2id(obd, &b->id1, inode, read_fid); + b->generation = inode->i_generation; + b->mds = obd->u.mds.mds_num; } /* unpacking */ @@ -263,7 +238,7 @@ static int mds_setattr_unpack(struct ptlrpc_request *req, int offset, if (rec == NULL) RETURN (-EFAULT); - r->ur_id1 = &rec->sa_id; + r->ur_fid1 = &rec->sa_fid; attr->ia_valid = rec->sa_valid; attr->ia_mode = rec->sa_mode; attr->ia_uid = rec->sa_uid; @@ -284,7 +259,7 @@ static int mds_setattr_unpack(struct ptlrpc_request *req, int offset, } if (req->rq_reqmsg->bufcount > offset + 2) { - r->ur_logcookies = lustre_msg_buf(req->rq_reqmsg, offset + 2, 0); + r->ur_logcookies = lustre_msg_buf(req->rq_reqmsg, offset + 2,0); if (r->ur_eadata == NULL) RETURN (-EFAULT); @@ -305,8 +280,8 @@ static int mds_create_unpack(struct ptlrpc_request *req, int offset, if (rec == NULL) RETURN (-EFAULT); - r->ur_id1 = &rec->cr_id; - r->ur_id2 = &rec->cr_replayid; + r->ur_fid1 = &rec->cr_fid; + r->ur_fid2 = &rec->cr_replayfid; r->ur_mode = rec->cr_mode; r->ur_rdev = rec->cr_rdev; r->ur_time = rec->cr_time; @@ -356,8 +331,8 @@ static int mds_link_unpack(struct ptlrpc_request *req, int offset, if (rec == NULL) RETURN (-EFAULT); - r->ur_id1 = &rec->lk_id1; - r->ur_id2 = &rec->lk_id2; + r->ur_fid1 = &rec->lk_fid1; + r->ur_fid2 = &rec->lk_fid2; r->ur_time = rec->lk_time; LASSERT_REQSWAB (req, offset + 1); @@ -380,8 +355,8 @@ static int mds_unlink_unpack(struct ptlrpc_request *req, int offset, RETURN(-EFAULT); r->ur_mode = rec->ul_mode; - r->ur_id1 = &rec->ul_id1; - r->ur_id2 = &rec->ul_id2; + r->ur_fid1 = &rec->ul_fid1; + r->ur_fid2 = &rec->ul_fid2; r->ur_time = rec->ul_time; LASSERT_REQSWAB (req, offset + 1); @@ -403,8 +378,8 @@ static int mds_rename_unpack(struct ptlrpc_request *req, int offset, if (rec == NULL) RETURN(-EFAULT); - r->ur_id1 = &rec->rn_id1; - r->ur_id2 = &rec->rn_id2; + r->ur_fid1 = &rec->rn_fid1; + r->ur_fid2 = &rec->rn_fid2; r->ur_time = rec->rn_time; LASSERT_REQSWAB (req, offset + 1); @@ -432,8 +407,8 @@ static int mds_open_unpack(struct ptlrpc_request *req, int offset, if (rec == NULL) RETURN (-EFAULT); - r->ur_id1 = &rec->cr_id; - r->ur_id2 = &rec->cr_replayid; + r->ur_fid1 = &rec->cr_fid; + r->ur_fid2 = &rec->cr_replayfid; r->ur_mode = rec->cr_mode; r->ur_rdev = rec->cr_rdev; r->ur_time = rec->cr_time; @@ -475,12 +450,10 @@ int mds_update_unpack(struct ptlrpc_request *req, int offset, int rc; ENTRY; - /* - * NB don't lustre_swab_reqbuf() here. We're just taking a peek and we - * want to leave it to the specific unpacker once we've identified the - * message type. - */ - opcodep = lustre_msg_buf (req->rq_reqmsg, offset, sizeof(*opcodep)); + /* NB don't lustre_swab_reqbuf() here. We're just taking a peek + * and we want to leave it to the specific unpacker once we've + * identified the message type */ + opcodep = lustre_msg_buf (req->rq_reqmsg, offset, sizeof (*opcodep)); if (opcodep == NULL) RETURN(-EFAULT); @@ -494,10 +467,7 @@ int mds_update_unpack(struct ptlrpc_request *req, int offset, RETURN(-EFAULT); } - rec->ur_id1 = NULL; - rec->ur_id2 = NULL; rec->ur_opcode = opcode; - rc = mds_unpackers[opcode](req, offset, rec); RETURN(rc); } diff --git a/lustre/mds/mds_lmv.c b/lustre/mds/mds_lmv.c index 34a6178..df80c75 100644 --- a/lustre/mds/mds_lmv.c +++ b/lustre/mds/mds_lmv.c @@ -44,7 +44,7 @@ * - error handling is totally missed */ -int mds_lmv_connect(struct obd_device *obd, char *lmv_name) +int mds_lmv_connect(struct obd_device *obd, char * lmv_name) { struct mds_obd *mds = &obd->u.mds; struct lustre_handle conn = {0}; @@ -71,8 +71,7 @@ int mds_lmv_connect(struct obd_device *obd, char *lmv_name) GOTO(err_last, rc = -ENOTCONN); } - rc = obd_connect(&conn, mds->mds_lmv_obd, - &obd->obd_uuid, OBD_OPT_MDS_CONNECTION); + rc = obd_connect(&conn, mds->mds_lmv_obd, &obd->obd_uuid, OBD_OPT_MDS_CONNECTION); if (rc) { CERROR("MDS cannot connect to LMV %s (%d)\n", lmv_name, rc); @@ -91,8 +90,8 @@ int mds_lmv_connect(struct obd_device *obd, char *lmv_name) } /* retrieve size of EA */ - rc = obd_get_info(mds->mds_lmv_exp, strlen("mdsize"), - "mdsize", &valsize, &value); + rc = obd_get_info(mds->mds_lmv_exp, strlen("mdsize"), "mdsize", + &valsize, &value); if (rc) GOTO(err_reg, rc); @@ -100,8 +99,8 @@ int mds_lmv_connect(struct obd_device *obd, char *lmv_name) mds->mds_max_mdsize = value; /* find our number in LMV cluster */ - rc = obd_get_info(mds->mds_lmv_exp, strlen("mdsnum"), - "mdsnum", &valsize, &value); + rc = obd_get_info(mds->mds_lmv_exp, strlen("mdsnum"), "mdsnum", + &valsize, &value); if (rc) GOTO(err_reg, rc); @@ -133,11 +132,9 @@ int mds_lmv_postsetup(struct obd_device *obd) int rc = 0; ENTRY; - if (mds->mds_lmv_exp) { - rc = obd_init_ea_size(mds->mds_lmv_exp, - mds->mds_max_mdsize, + if (mds->mds_lmv_exp) + rc = obd_init_ea_size(mds->mds_lmv_exp, mds->mds_max_mdsize, mds->mds_max_cookiesize); - } RETURN(rc); } @@ -148,52 +145,24 @@ int mds_lmv_disconnect(struct obd_device *obd, int flags) int rc = 0; ENTRY; - if (!mds->mds_lmv_connected) - RETURN(0); - down(&mds->mds_lmv_sem); if (!IS_ERR(mds->mds_lmv_obd) && mds->mds_lmv_exp != NULL) { - LASSERT(mds->mds_lmv_connected); - + LASSERT(mds->mds_lmv_connected != 0); + mds->mds_lmv_connected = 0; obd_register_observer(mds->mds_lmv_obd, NULL); - if (flags & OBD_OPT_FORCE) { - struct obd_device *lmv_obd; - struct obd_ioctl_data ioc_data = { 0 }; - - lmv_obd = class_exp2obd(mds->mds_lmv_exp); - if (lmv_obd == NULL) - GOTO(out, rc = 0); - - /* - * making disconnecting lmv stuff do not send anything - * to all remote MDSs from LMV. This is needed to - * prevent possible hanging with endless recovery, when - * MDS sends disconnect to already disconnected - * target. Probably this is wrong, but client does the - * same in --force mode and I do not see why can't we do - * it here. --umka. - */ - lmv_obd->obd_no_recov = 1; - obd_iocontrol(IOC_OSC_SET_ACTIVE, mds->mds_lmv_exp, - sizeof(ioc_data), &ioc_data, NULL); - } - - /* - * if obd_disconnect() fails (probably because the export was - * disconnected by class_disconnect_exports()) then we just need - * to drop our ref. - */ - mds->mds_lmv_connected = 0; + /* if obd_disconnect fails (probably because the export was + * disconnected by class_disconnect_exports) then we just need + * to drop our ref. */ rc = obd_disconnect(mds->mds_lmv_exp, flags); if (rc) class_export_put(mds->mds_lmv_exp); - - out: + mds->mds_lmv_exp = NULL; mds->mds_lmv_obd = NULL; } up(&mds->mds_lmv_sem); + RETURN(rc); } @@ -231,13 +200,12 @@ struct dir_entry { __u16 mds; __u32 ino; __u32 generation; - __u32 fid; char name[0]; }; #define DIR_PAD 4 #define DIR_ROUND (DIR_PAD - 1) -#define DIR_REC_LEN(name_len) (((name_len) + 16 + DIR_ROUND) & ~DIR_ROUND) +#define DIR_REC_LEN(name_len) (((name_len) + 12 + DIR_ROUND) & ~DIR_ROUND) /* this struct holds dir entries for particular MDS to be flushed */ struct dir_cache { @@ -281,43 +249,26 @@ static int retrieve_generation_numbers(struct dirsplit_control *dc, void *buf) struct mds_obd *mds = &dc->obd->u.mds; struct dir_entry *de; struct dentry *dentry; - char *end; + char * end; end = buf + PAGE_SIZE; de = (struct dir_entry *) buf; while ((char *) de < end && de->namelen) { /* lookup an inode */ LASSERT(de->namelen <= 255); - dentry = ll_lookup_one_len(de->name, dc->dentry, - de->namelen); + dentry = ll_lookup_one_len(de->name, dc->dentry, de->namelen); if (IS_ERR(dentry)) { CERROR("can't lookup %*s: %d\n", de->namelen, de->name, (int) PTR_ERR(dentry)); goto next; } if (dentry->d_inode != NULL) { - int rc; - struct lustre_id sid; - - down(&dentry->d_inode->i_sem); - rc = mds_read_inode_sid(dc->obd, - dentry->d_inode, &sid); - up(&dentry->d_inode->i_sem); - if (rc) { - CERROR("Can't read inode self id, " - "inode %lu, rc %d\n", - dentry->d_inode->i_ino, rc); - goto next; - } - - de->fid = id_fid(&sid); de->mds = mds->mds_num; de->ino = dentry->d_inode->i_ino; de->generation = dentry->d_inode->i_generation; } else if (dentry->d_flags & DCACHE_CROSS_REF) { - de->fid = dentry->d_fid; - de->ino = dentry->d_inum; de->mds = dentry->d_mdsnum; + de->ino = dentry->d_inum; de->generation = dentry->d_generation; } else { CERROR("can't lookup %*s\n", de->namelen, de->name); @@ -392,11 +343,11 @@ static int remove_entries_from_orig_dir(struct dirsplit_control *dc, int mdsnum) /* lookup an inode */ LASSERT(de->namelen <= 255); - dentry = ll_lookup_one_len(de->name, dc->dentry, + dentry = ll_lookup_one_len(de->name, dc->dentry, de->namelen); if (IS_ERR(dentry)) { CERROR("can't lookup %*s: %d\n", de->namelen, - de->name, (int) PTR_ERR(dentry)); + de->name, (int) PTR_ERR(dentry)); goto next; } rc = fsfilt_del_dir_entry(dc->obd, dentry); @@ -409,8 +360,8 @@ next: RETURN(0); } -static int filldir(void * __buf, const char * name, int namlen, - loff_t offset, ino_t ino, unsigned int d_type) +static int filldir(void * __buf, const char * name, int namlen, loff_t offset, + ino_t ino, unsigned int d_type) { struct dirsplit_control *dc = __buf; struct mds_obd *mds = &dc->obd->u.mds; @@ -420,8 +371,8 @@ static int filldir(void * __buf, const char * name, int namlen, char *n; ENTRY; - if (name[0] == '.' && - (namlen == 1 || (namlen == 2 && name[1] == '.'))) { + if (name[0] == '.' && (namlen == 1 || + (namlen == 2 && name[1] == '.'))) { /* skip special entries */ RETURN(0); } @@ -464,7 +415,7 @@ static int filldir(void * __buf, const char * name, int namlen, } int scan_and_distribute(struct obd_device *obd, struct dentry *dentry, - struct mea *mea) + struct mea *mea) { struct inode *dir = dentry->d_inode; struct dirsplit_control dc; @@ -476,9 +427,7 @@ int scan_and_distribute(struct obd_device *obd, struct dentry *dentry, OBD_ALLOC(file_name, nlen); if (!file_name) RETURN(-ENOMEM); - - i = sprintf(file_name, "__iopen__/0x%lx", - dentry->d_inode->i_ino); + i = sprintf(file_name, "__iopen__/0x%lx", dentry->d_inode->i_ino); file = filp_open(file_name, O_RDONLY, 0); if (IS_ERR(file)) { @@ -540,8 +489,9 @@ cleanup: RETURN(err); } -#define MAX_DIR_SIZE (64 * 1024) -#define I_NON_SPLITTABLE (256) +#define MAX_DIR_SIZE (64 * 1024) + +#define I_NON_SPLITTABLE 256 int mds_splitting_expected(struct obd_device *obd, struct dentry *dentry) { @@ -551,7 +501,7 @@ int mds_splitting_expected(struct obd_device *obd, struct dentry *dentry) /* clustered MD ? */ if (!mds->mds_lmv_obd) - return MDS_NO_SPLITTABLE; + RETURN(MDS_NO_SPLITTABLE); /* inode exist? */ if (dentry->d_inode == NULL) @@ -566,7 +516,7 @@ int mds_splitting_expected(struct obd_device *obd, struct dentry *dentry) return MDS_NO_SPLITTABLE; /* don't split root directory */ - if (dentry->d_inode->i_ino == id_ino(&mds->mds_rootid)) + if (dentry->d_inode->i_ino == mds->mds_rootfid.id) return MDS_NO_SPLITTABLE; /* large enough to be splitted? */ @@ -579,13 +529,14 @@ int mds_splitting_expected(struct obd_device *obd, struct dentry *dentry) rc = MDS_NO_SPLITTABLE; /* mark to skip subsequent checks */ dentry->d_inode->i_flags |= I_NON_SPLITTABLE; - OBD_FREE(mea, size); } else { /* may be splitted */ rc = MDS_EXPECT_SPLIT; } - return rc; + if (mea) + OBD_FREE(mea, size); + RETURN(rc); } /* @@ -599,13 +550,11 @@ int mds_try_to_split_dir(struct obd_device *obd, struct dentry *dentry, struct mea *tmea = NULL; struct obdo *oa = NULL; int rc, mea_size = 0; - struct lustre_id id; void *handle; ENTRY; if (update_mode != LCK_EX) return 0; - /* TODO: optimization possible - we already may have mea here */ rc = mds_splitting_expected(obd, dentry); if (rc == MDS_NO_SPLITTABLE) @@ -635,7 +584,7 @@ int mds_try_to_split_dir(struct obd_device *obd, struct dentry *dentry, RETURN(rc); } if (*mea == NULL) - RETURN(-ENOMEM); + RETURN(-EINVAL); (*mea)->mea_count = nstripes; @@ -656,27 +605,14 @@ int mds_try_to_split_dir(struct obd_device *obd, struct dentry *dentry, oa->o_valid |= OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP; oa->o_mode = dir->i_mode; - down(&dir->i_sem); - rc = mds_read_inode_sid(obd, dir, &id); - up(&dir->i_sem); - if (rc) { - CERROR("Can't read inode self id, inode %lu, " - "rc %d.\n", dir->i_ino, rc); - GOTO(err_oa, rc); - } - oa->o_fid = id_fid(&id); - CDEBUG(D_OTHER, "%s: create subdirs with mode %o, uid %u, gid %u\n", - obd->obd_name, dir->i_mode, dir->i_uid, dir->i_gid); + obd->obd_name, dir->i_mode, dir->i_uid, dir->i_gid); rc = obd_create(mds->mds_lmv_exp, oa, (struct lov_stripe_md **)mea, NULL); - if (rc) { - CERROR("Can't create remote inode, rc = %d\n", rc); + if (rc) GOTO(err_oa, rc); - } - LASSERT(id_fid(&(*mea)->mea_ids[0])); CDEBUG(D_OTHER, "%d dirobjects created\n", (int)(*mea)->mea_count); /* 2) update dir attribute */ @@ -688,7 +624,7 @@ int mds_try_to_split_dir(struct obd_device *obd, struct dentry *dentry, CERROR("fsfilt_start() failed: %d\n", (int) PTR_ERR(handle)); GOTO(err_oa, rc = PTR_ERR(handle)); } - + rc = fsfilt_set_md(obd, dir, handle, *mea, mea_size); if (rc) { up(&dir->i_sem); @@ -737,9 +673,9 @@ static int filter_start_page_write(struct inode *inode, return 0; } -struct dentry *filter_id2dentry(struct obd_device *obd, - struct dentry *dir_dentry, - obd_gr group, obd_id id); +struct dentry *filter_fid2dentry(struct obd_device *obd, + struct dentry *dir_dentry, + obd_gr group, obd_id id); int mds_preprw(int cmd, struct obd_export *exp, struct obdo *oa, int objcount, struct obd_ioobj *obj, @@ -747,28 +683,25 @@ int mds_preprw(int cmd, struct obd_export *exp, struct obdo *oa, struct niobuf_local *res, struct obd_trans_info *oti) { + struct mds_obd *mds = &exp->exp_obd->u.mds; struct niobuf_remote *rnb; struct niobuf_local *lnb = NULL; int rc = 0, i, tot_bytes = 0; unsigned long now = jiffies; struct dentry *dentry; - struct lustre_id id; + struct ll_fid fid; ENTRY; LASSERT(objcount == 1); LASSERT(obj->ioo_bufcnt > 0); memset(res, 0, niocount * sizeof(*res)); - id_fid(&id) = 0; - id_group(&id) = 0; - id_ino(&id) = obj->ioo_id; - id_gen(&id) = obj->ioo_gr; - - dentry = mds_id2dentry(exp->exp_obd, &id, NULL); + fid.id = obj->ioo_id; + fid.generation = obj->ioo_gr; + dentry = mds_fid2dentry(mds, &fid, NULL); if (IS_ERR(dentry)) { CERROR("can't get dentry for "LPU64"/%u: %d\n", - id.li_stc.u.e3s.l3s_ino, id.li_stc.u.e3s.l3s_gen, - (int)PTR_ERR(dentry)); + fid.id, fid.generation, (int) PTR_ERR(dentry)); GOTO(cleanup, rc = (int) PTR_ERR(dentry)); } @@ -844,12 +777,12 @@ int mds_commitrw(int cmd, struct obd_export *exp, struct obdo *oa, while ((char *) de < end && de->namelen) { err = fsfilt_add_dir_entry(obd, res->dentry, de->name, de->namelen, de->ino, - de->generation, de->mds, - de->fid); + de->generation, de->mds); if (err) { CERROR("can't add dir entry %*s->%u/%u/%u" - " to %lu/%u: %d\n", de->namelen, - de->name, de->mds, (unsigned)de->ino, + " to %lu/%u: %d\n", + de->namelen, de->name, + de->mds, (unsigned) de->ino, (unsigned) de->generation, res->dentry->d_inode->i_ino, res->dentry->d_inode->i_generation, @@ -895,8 +828,6 @@ int mds_lock_slave_objs(struct obd_device *obd, struct dentry *dentry, struct lookup_intent it; struct mea *mea = NULL; int mea_size, rc; - int handle_size; - ENTRY; LASSERT(rlockh != NULL); LASSERT(dentry != NULL); @@ -904,44 +835,38 @@ int mds_lock_slave_objs(struct obd_device *obd, struct dentry *dentry, /* clustered MD ? */ if (!mds->mds_lmv_obd) - RETURN(0); + return 0; /* a dir can be splitted only */ if (!S_ISDIR(dentry->d_inode->i_mode)) - RETURN(0); + return 0; - rc = mds_get_lmv_attr(obd, dentry->d_inode, - &mea, &mea_size); + rc = mds_get_lmv_attr(obd, dentry->d_inode, &mea, &mea_size); if (rc) - RETURN(rc); + return rc; if (mea == NULL) - RETURN(0); - - if (mea->mea_count == 0) + return 0; + if (mea->mea_count == 0) { /* this is slave object */ GOTO(cleanup, rc = 0); + } - CDEBUG(D_OTHER, "%s: lock slaves for %lu/%lu\n", - obd->obd_name, (unsigned long)dentry->d_inode->i_ino, - (unsigned long)dentry->d_inode->i_generation); + CDEBUG(D_OTHER, "%s: lock slaves for %lu/%lu\n", obd->obd_name, + (unsigned long) dentry->d_inode->i_ino, + (unsigned long) dentry->d_inode->i_generation); - handle_size = sizeof(struct lustre_handle) * - mea->mea_count; - - OBD_ALLOC(*rlockh, handle_size); + OBD_ALLOC(*rlockh, sizeof(struct lustre_handle) * mea->mea_count); if (*rlockh == NULL) GOTO(cleanup, rc = -ENOMEM); + memset(*rlockh, 0, sizeof(struct lustre_handle) * mea->mea_count); - memset(*rlockh, 0, handle_size); memset(&op_data, 0, sizeof(op_data)); - op_data.mea1 = mea; it.it_op = IT_UNLINK; - - rc = md_enqueue(mds->mds_lmv_exp, LDLM_IBITS, &it, LCK_EX, - &op_data, *rlockh, NULL, 0, ldlm_completion_ast, - mds_blocking_ast, NULL); + rc = md_enqueue(mds->mds_lmv_exp, LDLM_IBITS, &it, LCK_EX, &op_data, + *rlockh, NULL, 0, ldlm_completion_ast, mds_blocking_ast, + NULL); cleanup: OBD_FREE(mea, mea_size); RETURN(rc); @@ -1110,12 +1035,12 @@ int mds_lock_and_check_slave(int offset, struct ptlrpc_request *req, CERROR("Can't swab mds_body\n"); GOTO(cleanup, rc = -EFAULT); } - CDEBUG(D_OTHER, "%s: check slave "DLID4"\n", obd->obd_name, - OLID4(&body->id1)); - - dentry = mds_id2locked_dentry(obd, &body->id1, NULL, LCK_EX, - lockh, &update_mode, NULL, 0, - MDS_INODELOCK_UPDATE); + CDEBUG(D_OTHER, "%s: check slave %lu/%lu\n", obd->obd_name, + (unsigned long) body->fid1.id, + (unsigned long) body->fid1.generation); + dentry = mds_fid2locked_dentry(obd, &body->fid1, NULL, LCK_EX, lockh, + &update_mode, NULL, 0, + MDS_INODELOCK_UPDATE); if (IS_ERR(dentry)) { CERROR("can't find inode: %d\n", (int) PTR_ERR(dentry)); GOTO(cleanup, rc = PTR_ERR(dentry)); @@ -1166,10 +1091,7 @@ int mds_convert_mea_ea(struct obd_device *obd, struct inode *inode, RETURN(0); old = (struct mea_old *) lmm; - - rc = sizeof(struct lustre_id) * old->mea_count + - sizeof(struct mea_old); - + rc = sizeof(struct ll_fid) * old->mea_count + sizeof(struct mea_old); if (old->mea_count > 256 || old->mea_master > 256 || lmmsize < rc || old->mea_master > old->mea_count) { CWARN("unknown MEA format, dont convert it\n"); @@ -1179,12 +1101,9 @@ int mds_convert_mea_ea(struct obd_device *obd, struct inode *inode, } CWARN("converting MEA EA on %lu/%u from V0 to V1 (%u/%u)\n", - inode->i_ino, inode->i_generation, old->mea_count, - old->mea_master); + inode->i_ino, inode->i_generation, old->mea_count, old->mea_master); - size = sizeof(struct lustre_id) * old->mea_count + - sizeof(struct mea); - + size = sizeof(struct ll_fid) * old->mea_count + sizeof(struct mea); OBD_ALLOC(new, size); if (new == NULL) RETURN(-ENOMEM); @@ -1193,7 +1112,7 @@ int mds_convert_mea_ea(struct obd_device *obd, struct inode *inode, new->mea_count = old->mea_count; new->mea_master = old->mea_master; for (i = 0; i < new->mea_count; i++) - new->mea_ids[i] = old->mea_ids[i]; + new->mea_fids[i] = old->mea_fids[i]; handle = fsfilt_start(obd, inode, FSFILT_OP_SETATTR, NULL); if (IS_ERR(handle)) { diff --git a/lustre/mds/mds_log.c b/lustre/mds/mds_log.c index 8b95969..e2f4a96 100644 --- a/lustre/mds/mds_log.c +++ b/lustre/mds/mds_log.c @@ -43,7 +43,7 @@ static int mds_llog_origin_add(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec, struct rw_semaphore **lock, int *lock_count) { struct obd_device *obd = ctxt->loc_obd; - struct obd_device *lov_obd = obd->u.mds.mds_lov_obd; + struct obd_device *lov_obd = obd->u.mds.mds_osc_obd; struct llog_ctxt *lctxt; int rc; ENTRY; @@ -59,7 +59,7 @@ static int mds_llog_origin_connect(struct llog_ctxt *ctxt, int count, struct llog_gen *gen, struct obd_uuid *uuid) { struct obd_device *obd = ctxt->loc_obd; - struct obd_device *lov_obd = obd->u.mds.mds_lov_obd; + struct obd_device *lov_obd = obd->u.mds.mds_osc_obd; struct llog_ctxt *lctxt; int rc; ENTRY; @@ -74,7 +74,7 @@ static int mds_llog_repl_cancel(struct llog_ctxt *ctxt, int count, void *data) { struct obd_device *obd = ctxt->loc_obd; - struct obd_device *lov_obd = obd->u.mds.mds_lov_obd; + struct obd_device *lov_obd = obd->u.mds.mds_osc_obd; struct llog_ctxt *lctxt; int rc; ENTRY; @@ -97,12 +97,13 @@ int mds_log_op_unlink(struct obd_device *obd, struct inode *inode, int lock_count = 0; ENTRY; - if (IS_ERR(mds->mds_lov_obd)) - RETURN(PTR_ERR(mds->mds_lov_obd)); + if (IS_ERR(mds->mds_osc_obd)) + RETURN(PTR_ERR(mds->mds_osc_obd)); RETURN(0); - rc = obd_unpackmd(mds->mds_lov_exp, &lsm, lmm, lmm_size); + rc = obd_unpackmd(mds->mds_osc_exp, &lsm, + lmm, lmm_size); if (rc < 0) RETURN(rc); @@ -122,7 +123,7 @@ int mds_log_op_unlink(struct obd_device *obd, struct inode *inode, cookies_size / sizeof(struct llog_cookie), NULL, res ? &lcl->lcl_locks[0] : NULL, &lock_count); - obd_free_memmd(mds->mds_lov_exp, &lsm); + obd_free_memmd(mds->mds_osc_exp, &lsm); if (res && (rc <= 0 || lock_count == 0)) { OBD_FREE(lcl, size); @@ -144,7 +145,7 @@ static struct llog_operations mds_size_repl_logops = { int mds_llog_init(struct obd_device *obd, struct obd_llogs *llogs, struct obd_device *tgt, int count, struct llog_catid *logid) { - struct obd_device *lov_obd = obd->u.mds.mds_lov_obd; + struct obd_device *lov_obd = obd->u.mds.mds_osc_obd; int rc; ENTRY; @@ -167,7 +168,7 @@ int mds_llog_init(struct obd_device *obd, struct obd_llogs *llogs, int mds_llog_finish(struct obd_device *obd, struct obd_llogs *llogs, int count) { - struct obd_device *lov_obd = obd->u.mds.mds_lov_obd; + struct obd_device *lov_obd = obd->u.mds.mds_osc_obd; int rc; ENTRY; diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index e616677..322109d 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -139,7 +139,7 @@ int mds_lov_clearorphans(struct mds_obd *mds, struct obd_uuid *ost_uuid) memcpy(&oa.o_inline, ost_uuid, sizeof(*ost_uuid)); oa.o_valid |= OBD_MD_FLINLINE; } - rc = obd_create(mds->mds_lov_exp, &oa, &empty_ea, &oti); + rc = obd_create(mds->mds_osc_exp, &oa, &empty_ea, &oti); RETURN(rc); } @@ -155,7 +155,7 @@ int mds_lov_set_nextid(struct obd_device *obd) LASSERT(mds->mds_lov_objids != NULL); - rc = obd_set_info(mds->mds_lov_exp, strlen("next_id"), "next_id", + rc = obd_set_info(mds->mds_osc_exp, strlen("next_id"), "next_id", mds->mds_lov_desc.ld_tgt_count, mds->mds_lov_objids); RETURN(rc); } @@ -166,7 +166,7 @@ int mds_lov_set_growth(struct mds_obd *mds, int count) int rc; ENTRY; - rc = obd_set_info(mds->mds_lov_exp, strlen("growth_count"), + rc = obd_set_info(mds->mds_osc_exp, strlen("growth_count"), "growth_count", sizeof(count), &count); RETURN(rc); @@ -221,40 +221,40 @@ int mds_lov_connect(struct obd_device *obd, char * lov_name) int rc, i; ENTRY; - if (IS_ERR(mds->mds_lov_obd)) - RETURN(PTR_ERR(mds->mds_lov_obd)); + if (IS_ERR(mds->mds_osc_obd)) + RETURN(PTR_ERR(mds->mds_osc_obd)); - if (mds->mds_lov_obd) + if (mds->mds_osc_obd) RETURN(0); spin_lock_init(&mds->mds_lov_lock); - mds->mds_lov_obd = class_name2obd(lov_name); - if (!mds->mds_lov_obd) { + mds->mds_osc_obd = class_name2obd(lov_name); + if (!mds->mds_osc_obd) { CERROR("MDS cannot locate LOV %s\n", lov_name); - mds->mds_lov_obd = ERR_PTR(-ENOTCONN); + mds->mds_osc_obd = ERR_PTR(-ENOTCONN); RETURN(-ENOTCONN); } CDEBUG(D_HA, "obd: %s osc: %s lov_name: %s\n", - obd->obd_name, mds->mds_lov_obd->obd_name, lov_name); + obd->obd_name, mds->mds_osc_obd->obd_name, lov_name); - rc = obd_connect(&conn, mds->mds_lov_obd, &obd->obd_uuid, + rc = obd_connect(&conn, mds->mds_osc_obd, &obd->obd_uuid, mds->mds_num + FILTER_GROUP_FIRST_MDS); if (rc) { CERROR("MDS cannot connect to LOV %s (%d)\n", lov_name, rc); - mds->mds_lov_obd = ERR_PTR(rc); + mds->mds_osc_obd = ERR_PTR(rc); RETURN(rc); } - mds->mds_lov_exp = class_conn2export(&conn); + mds->mds_osc_exp = class_conn2export(&conn); - rc = obd_register_observer(mds->mds_lov_obd, obd); + rc = obd_register_observer(mds->mds_osc_obd, obd); if (rc) { CERROR("MDS cannot register as observer of LOV %s (%d)\n", lov_name, rc); GOTO(err_discon, rc); } - rc = mds_lov_update_desc(obd, mds->mds_lov_exp); + rc = mds_lov_update_desc(obd, mds->mds_osc_exp); if (rc) GOTO(err_reg, rc); @@ -275,7 +275,7 @@ int mds_lov_connect(struct obd_device *obd, char * lov_name) * we need to populate the objids array from the real OST values */ if (!mds->mds_lov_objids_valid) { int size = sizeof(obd_id) * mds->mds_lov_desc.ld_tgt_count; - rc = obd_get_info(mds->mds_lov_exp, strlen("last_id"), + rc = obd_get_info(mds->mds_osc_exp, strlen("last_id"), "last_id", &size, mds->mds_lov_objids); if (!rc) { for (i = 0; i < mds->mds_lov_desc.ld_tgt_count; i++) @@ -299,11 +299,11 @@ int mds_lov_connect(struct obd_device *obd, char * lov_name) RETURN(rc); err_reg: - obd_register_observer(mds->mds_lov_obd, NULL); + obd_register_observer(mds->mds_osc_obd, NULL); err_discon: - obd_disconnect(mds->mds_lov_exp, 0); - mds->mds_lov_exp = NULL; - mds->mds_lov_obd = ERR_PTR(rc); + obd_disconnect(mds->mds_osc_exp, 0); + mds->mds_osc_exp = NULL; + mds->mds_osc_obd = ERR_PTR(rc); RETURN(rc); } @@ -313,23 +313,23 @@ int mds_lov_disconnect(struct obd_device *obd, int flags) int rc = 0; ENTRY; - if (!IS_ERR(mds->mds_lov_obd) && mds->mds_lov_exp != NULL) { + if (!IS_ERR(mds->mds_osc_obd) && mds->mds_osc_exp != NULL) { /* cleanup all llogging subsystems */ rc = obd_llog_finish(obd, &obd->obd_llogs, mds->mds_lov_desc.ld_tgt_count); if (rc) CERROR("failed to cleanup llogging subsystems\n"); - obd_register_observer(mds->mds_lov_obd, NULL); + obd_register_observer(mds->mds_osc_obd, NULL); - rc = obd_disconnect(mds->mds_lov_exp, flags); + rc = obd_disconnect(mds->mds_osc_exp, flags); /* if obd_disconnect fails (probably because the * export was disconnected by class_disconnect_exports) * then we just need to drop our ref. */ if (rc != 0) - class_export_put(mds->mds_lov_exp); - mds->mds_lov_exp = NULL; - mds->mds_lov_obd = NULL; + class_export_put(mds->mds_osc_exp); + mds->mds_osc_exp = NULL; + mds->mds_osc_obd = NULL; } RETURN(rc); @@ -497,7 +497,7 @@ int mds_iocontrol(unsigned int cmd, struct obd_export *exp, int len, CATLIST); group = FILTER_GROUP_FIRST_MDS + mds->mds_num; valsize = sizeof(group); - rc2 = obd_set_info(mds->mds_lov_exp, strlen("mds_conn"), + rc2 = obd_set_info(mds->mds_osc_exp, strlen("mds_conn"), "mds_conn", valsize, &group); if (!rc) rc = rc2; @@ -603,7 +603,7 @@ int mds_lov_synchronize(void *data) old_count = mds->mds_lov_desc.ld_tgt_count; - rc = mds_lov_update_desc(obd, mds->mds_lov_exp); + rc = mds_lov_update_desc(obd, mds->mds_osc_exp); if (rc) RETURN(rc); @@ -776,8 +776,9 @@ int mds_lov_update_config(struct obd_device *obd, int clean) ctxt = llog_get_context(&obd->obd_llogs, LLOG_CONFIG_ORIG_CTXT); rc = class_config_process_llog(ctxt, name, &cfg); pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - if (rc == 0) + if (rc == 0) { mds->mds_config_version = version; + } CWARN("Finished applying configuration log %s: %d\n", name, rc); OBD_FREE(name, namelen); @@ -809,11 +810,11 @@ int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode, CDEBUG(D_INODE, "converting LOV EA on %lu/%u from V0 to V1\n", inode->i_ino, inode->i_generation); - rc = obd_unpackmd(obd->u.mds.mds_lov_exp, &lsm, lmm, lmm_size); + rc = obd_unpackmd(obd->u.mds.mds_osc_exp, &lsm, lmm, lmm_size); if (rc < 0) GOTO(conv_end, rc); - rc = obd_packmd(obd->u.mds.mds_lov_exp, &lmm, lsm); + rc = obd_packmd(obd->u.mds.mds_osc_exp, &lmm, lsm); if (rc < 0) GOTO(conv_free, rc); lmm_size = rc; @@ -831,7 +832,7 @@ int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode, rc = err ? err : lmm_size; GOTO(conv_free, rc); conv_free: - obd_free_memmd(obd->u.mds.mds_lov_exp, &lsm); + obd_free_memmd(obd->u.mds.mds_osc_exp, &lsm); conv_end: return rc; } @@ -841,7 +842,7 @@ int mds_revalidate_lov_ea(struct obd_device *obd, struct inode *inode, struct lustre_msg *msg, int offset) { struct mds_obd *mds = &obd->u.mds; - struct obd_export *osc_exp = mds->mds_lov_exp; + struct obd_export *osc_exp = mds->mds_osc_exp; struct lov_mds_md *lmm= NULL; struct lov_stripe_md *lsm = NULL; struct obdo *oa; diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index e9edf4a..eb0abeb 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -337,7 +337,7 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, /* replay case */ if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) { - LASSERT(id_ino(rec->ur_id2)); + LASSERT (rec->ur_fid2->id); body->valid |= OBD_MD_FLBLKSZ | OBD_MD_FLEASIZE; lmm_size = rec->ur_eadatalen; lmm = rec->ur_eadata; @@ -387,7 +387,7 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, /* check if things like lfs setstripe are sending us the ea */ if (rec->ur_flags & MDS_OPEN_HAS_EA) { rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, - mds->mds_lov_exp, + mds->mds_osc_exp, 0, &lsm, rec->ur_eadata); if (rc) GOTO(out_oa, rc); @@ -397,7 +397,7 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, * striping for CMD. -p */ } LASSERT(oa->o_gr >= FILTER_GROUP_FIRST_MDS); - rc = obd_create(mds->mds_lov_exp, oa, &lsm, &oti); + rc = obd_create(mds->mds_osc_exp, oa, &lsm, &oti); if (rc) { int level = D_ERROR; if (rc == -ENOSPC) @@ -413,7 +413,7 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, GOTO(out_oa, rc); } } else { - rc = obd_iocontrol(OBD_IOC_LOV_SETEA, mds->mds_lov_exp, + rc = obd_iocontrol(OBD_IOC_LOV_SETEA, mds->mds_osc_exp, 0, &lsm, rec->ur_eadata); if (rc) { GOTO(out_oa, rc); @@ -425,7 +425,7 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, oa->o_size = inode->i_size; obdo_from_inode(oa, inode, OBD_MD_FLTYPE|OBD_MD_FLATIME| OBD_MD_FLMTIME| OBD_MD_FLCTIME| OBD_MD_FLSIZE); - rc = obd_setattr(mds->mds_lov_exp, oa, lsm, &oti); + rc = obd_setattr(mds->mds_osc_exp, oa, lsm, &oti); if (rc) { CERROR("error setting attrs for inode %lu: rc %d\n", inode->i_ino, rc); @@ -442,9 +442,9 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, LASSERT(lsm && lsm->lsm_object_id); lmm = NULL; - rc = obd_packmd(mds->mds_lov_exp, &lmm, lsm); - if (!id_ino(rec->ur_id2)) - obd_free_memmd(mds->mds_lov_exp, &lsm); + rc = obd_packmd(mds->mds_osc_exp, &lmm, lsm); + if (!rec->ur_fid2->id) + obd_free_memmd(mds->mds_osc_exp, &lsm); LASSERT(rc >= 0); lmm_size = rc; body->eadatasize = rc; @@ -464,7 +464,7 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset, LASSERT(lmm_bufsize >= lmm_size); memcpy(lmm_buf, lmm, lmm_size); - obd_free_diskmd(mds->mds_lov_exp, &lmm); + obd_free_diskmd(mds->mds_osc_exp, &lmm); out_oa: oti_free_cookies(&oti); obdo_free(oa); @@ -488,9 +488,9 @@ static void reconstruct_open(struct mds_update_record *rec, int offset, struct dentry *parent, *dchild; struct ldlm_reply *rep; struct mds_body *body; + int rc; struct list_head *t; int put_child = 1; - int rc; ENTRY; LASSERT(offset == 3); /* only called via intent */ @@ -507,14 +507,14 @@ static void reconstruct_open(struct mds_update_record *rec, int offset, return; /* error looking up parent or child */ } - parent = mds_id2dentry(obd, rec->ur_id1, NULL); - LASSERTF(!IS_ERR(parent), "lid "DLID4" rc %ld\n", - OLID4(rec->ur_id1), PTR_ERR(parent)); + parent = mds_fid2dentry(mds, rec->ur_fid1, NULL); + LASSERTF(!IS_ERR(parent), "fid "LPU64"/%u rc %ld\n", rec->ur_fid1->id, + rec->ur_fid1->generation, PTR_ERR(parent)); - dchild = ll_lookup_one_len(rec->ur_name, parent, - rec->ur_namelen - 1); - LASSERTF(!IS_ERR(dchild), "parent "DLID4" child %s rc %ld\n", - OLID4(rec->ur_id1), rec->ur_name, PTR_ERR(dchild)); + dchild = ll_lookup_one_len(rec->ur_name, parent, rec->ur_namelen - 1); + LASSERTF(!IS_ERR(dchild), "parent "LPU64"/%u child %s rc %ld\n", + rec->ur_fid1->id, rec->ur_fid1->generation, rec->ur_name, + PTR_ERR(dchild)); if (!dchild->d_inode) GOTO(out_dput, 0); /* child not present to open */ @@ -526,8 +526,8 @@ static void reconstruct_open(struct mds_update_record *rec, int offset, req->rq_status) GOTO(out_dput, 0); - /* get lock (write for O_CREAT, read otherwise) */ - mds_pack_inode2body(obd, body, dchild->d_inode, 0); + mds_pack_inode2fid(obd, &body->fid1, dchild->d_inode); + mds_pack_inode2body(obd, body, dchild->d_inode); if (S_ISREG(dchild->d_inode->i_mode)) { rc = mds_pack_md(obd, req->rq_repmsg, 2, body, dchild->d_inode, 1); @@ -690,56 +690,50 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild, RETURN(rc); } -static int mds_open_by_id(struct ptlrpc_request *req, - struct lustre_id *id, - struct mds_body *body, int flags, - struct mds_update_record *rec, - struct ldlm_reply *rep) +static int mds_open_by_fid(struct ptlrpc_request *req, struct ll_fid *fid, + struct mds_body *body, int flags, + struct mds_update_record *rec,struct ldlm_reply *rep) { struct mds_obd *mds = mds_req2mds(req); struct inode *pending_dir = mds->mds_pending_dir->d_inode; struct dentry *dchild; - char idname[LL_ID_NAMELEN]; - int idlen = 0, rc; + char fidname[LL_FID_NAMELEN]; + int fidlen = 0, rc; void *handle = NULL; ENTRY; down(&pending_dir->i_sem); - - idlen = ll_id2str(idname, id_ino(id), id_gen(id)); - - dchild = lookup_one_len(idname, mds->mds_pending_dir, - idlen); + fidlen = ll_fid2str(fidname, fid->id, fid->generation); + dchild = lookup_one_len(fidname, mds->mds_pending_dir, fidlen); if (IS_ERR(dchild)) { up(&pending_dir->i_sem); rc = PTR_ERR(dchild); - CERROR("error looking up %s in PENDING: rc = %d\n", - idname, rc); + CERROR("error looking up %s in PENDING: rc = %d\n",fidname, rc); RETURN(rc); } if (dchild->d_inode != NULL) { up(&pending_dir->i_sem); mds_inode_set_orphan(dchild->d_inode); - mds_pack_inode2body(req2obd(req), body, dchild->d_inode, 0); + mds_pack_inode2fid(req2obd(req), &body->fid1, dchild->d_inode); + mds_pack_inode2body(req2obd(req), body, dchild->d_inode); intent_set_disposition(rep, DISP_LOOKUP_EXECD); intent_set_disposition(rep, DISP_LOOKUP_POS); CWARN("Orphan %s found and opened in PENDING directory\n", - idname); + fidname); goto open; } dput(dchild); up(&pending_dir->i_sem); - /* - * we didn't find it in PENDING so it isn't an orphan. See if it was a - * regular inode that was previously created. - */ - dchild = mds_id2dentry(req2obd(req), id, NULL); + /* We didn't find it in PENDING so it isn't an orphan. See + * if it was a regular inode that was previously created. */ + dchild = mds_fid2dentry(mds, fid, NULL); if (IS_ERR(dchild)) RETURN(PTR_ERR(dchild)); - mds_pack_inode2body(req2obd(req), body, dchild->d_inode, 0); + mds_pack_inode2fid(req2obd(req), &body->fid1, dchild->d_inode); + mds_pack_inode2body(req2obd(req), body, dchild->d_inode); intent_set_disposition(rep, DISP_LOOKUP_EXECD); intent_set_disposition(rep, DISP_LOOKUP_POS); @@ -770,14 +764,13 @@ int mds_pin(struct ptlrpc_request *req, int offset) reply_body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*reply_body)); push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - rc = mds_open_by_id(req, &request_body->id1, reply_body, - request_body->flags, NULL, NULL); + rc = mds_open_by_fid(req, &request_body->fid1, reply_body, + request_body->flags, NULL, NULL); pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); RETURN(rc); } -#if 0 /* Get a lock on the ino to sync with creation WRT inode reuse (bug 2029). * If child_lockh is NULL we just get the lock as a barrier to wait for * other holders of this lock, and drop it right away again. */ @@ -803,7 +796,6 @@ int mds_lock_new_child(struct obd_device *obd, struct inode *inode, RETURN(rc); } -#endif static int is_mount_object(struct dentry *dparent) { @@ -839,9 +831,9 @@ int mds_open(struct mds_update_record *rec, int offset, int mea_size, update_mode; ENTRY; - DEBUG_REQ(D_INODE, req, "parent "DLID4" name %*s mode %o", - OLID4(rec->ur_id1), rec->ur_namelen - 1, rec->ur_name, - rec->ur_mode); + DEBUG_REQ(D_INODE, req, "parent "LPU64"/%u name %*s mode %o", + rec->ur_fid1->id, rec->ur_fid1->generation, + rec->ur_namelen - 1, rec->ur_name, rec->ur_mode); parent_lockh[0].cookie = 0; parent_lockh[1].cookie = 0; @@ -857,30 +849,28 @@ int mds_open(struct mds_update_record *rec, int offset, } MDS_CHECK_RESENT(req, reconstruct_open(rec, offset, req, child_lockh)); + MDS_UPDATE_COUNTER(mds, MDS_OPEN_COUNT); - /* - * Step 0: If we are passed a id, then we assume the client already - * opened this file and is only replaying the RPC, so we open the inode - * by fid (at some large expense in security). - */ + /* Step 0: If we are passed a fid, then we assume the client already + * opened this file and is only replaying the RPC, so we open the + * inode by fid (at some large expense in security). */ if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) { - CDEBUG(D_HA, "open obj "DLID4" name %*s mode %o\n", - OLID4(rec->ur_id2), rec->ur_namelen - 1, - rec->ur_name, rec->ur_mode); + CDEBUG(D_HA, "open fid "LPU64"/%u name %*s mode %o\n", + rec->ur_fid2->id, rec->ur_fid2->generation, + rec->ur_namelen - 1, rec->ur_name, rec->ur_mode); - LASSERT(id_ino(rec->ur_id2)); + LASSERT(rec->ur_fid2->id); - rc = mds_open_by_id(req, rec->ur_id2, body, rec->ur_flags, - rec, rep); + rc = mds_open_by_fid(req, rec->ur_fid2, body, rec->ur_flags, + rec, rep); if (rc != -ENOENT) RETURN(rc); - /* We didn't find the correct inode on disk either, so we * need to re-create it via a regular replay. */ LASSERT(rec->ur_flags & MDS_OPEN_CREAT); } else { - LASSERT(!id_ino(rec->ur_id2)); + LASSERT(!rec->ur_fid2->id); } LASSERT(offset == 3); /* If we got here, we must be called via intent */ @@ -902,20 +892,24 @@ int mds_open(struct mds_update_record *rec, int offset, } if (rec->ur_namelen == 1) { - /* client (LMV) wants to open the file by id */ - CDEBUG(D_OTHER, "OPEN by id "DLID4"\n", OLID4(rec->ur_id1)); - dchild = mds_id2dentry(obd, rec->ur_id1, NULL); + /* client (LMV) wants to open the file by fid */ + CDEBUG(D_OTHER, "OPEN by fid %u/%u/%u\n", + (unsigned) rec->ur_fid1->mds, + (unsigned) rec->ur_fid1->id, + (unsigned) rec->ur_fid1->generation); + dchild = mds_fid2dentry(mds, rec->ur_fid1, NULL); if (IS_ERR(dchild)) { rc = PTR_ERR(dparent); - CERROR("child lookup by an id error %d\n", rc); + CERROR("child lookup by a fid error %d\n", rc); GOTO(cleanup, rc); } goto got_child; } - dparent = mds_id2locked_dentry(obd, rec->ur_id1, NULL, parent_mode, - parent_lockh, &update_mode, rec->ur_name, - rec->ur_namelen - 1, MDS_INODELOCK_UPDATE); + dparent = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, parent_mode, + parent_lockh, &update_mode, rec->ur_name, + rec->ur_namelen - 1, + MDS_INODELOCK_UPDATE); if (IS_ERR(dparent)) { rc = PTR_ERR(dparent); if (rc != -ENOENT) @@ -932,19 +926,17 @@ int mds_open(struct mds_update_record *rec, int offset, GOTO(cleanup, rc); if (mea != NULL) { - /* - * dir is already splitted, check is requested filename should * - * live at this MDS or at another one. - */ + /* dir is already splitted, check is requested filename + * should live at this MDS or at another one */ int i; i = mea_name2idx(mea, rec->ur_name, rec->ur_namelen - 1); - if (mea->mea_master != id_group(&mea->mea_ids[i])) { + if (mea->mea_master != mea->mea_fids[i].mds) { CDEBUG(D_OTHER, "%s: inapropriate MDS(%d) for %lu/%u:%s." - " should be %lu(%d)\n", obd->obd_name, + " should be %d(%d)\n", obd->obd_name, mea->mea_master, dparent->d_inode->i_ino, dparent->d_inode->i_generation, rec->ur_name, - (unsigned long)id_group(&mea->mea_ids[i]), i); + mea->mea_fids[i].mds, i); GOTO(cleanup, rc = -ERESTART); } } @@ -966,20 +958,22 @@ got_child: struct ldlm_res_id res_id = { . name = {0} }; ldlm_policy_data_t policy; int flags = 0; - - mds_pack_dentry2body(obd, body, dchild, 1); + CDEBUG(D_OTHER, "cross reference: %lu/%lu/%lu\n", + (unsigned long) dchild->d_mdsnum, + (unsigned long) dchild->d_inum, + (unsigned long) dchild->d_generation); + body->valid |= OBD_MD_FLID | OBD_MD_MDS; + body->fid1.id = dchild->d_inum; + body->fid1.mds = dchild->d_mdsnum; + body->fid1.generation = dchild->d_generation; intent_set_disposition(rep, DISP_LOOKUP_POS); - - CDEBUG(D_OTHER, "cross reference: "DLID4"\n", - OLID4(&body->id1)); - - res_id.name[0] = dchild->d_fid; - res_id.name[1] = dchild->d_mdsnum; - + res_id.name[0] = dchild->d_inum; + res_id.name[1] = dchild->d_generation; policy.l_inodebits.bits = MDS_INODELOCK_LOOKUP; rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, res_id, LDLM_IBITS, &policy, - LCK_PR, &flags, mds_blocking_ast, + LCK_PR, &flags, + mds_blocking_ast, ldlm_completion_ast, NULL, NULL, NULL, 0, NULL, child_lockh); #ifdef S_PDIROPS @@ -999,21 +993,15 @@ got_child: else intent_set_disposition(rep, DISP_LOOKUP_NEG); - /* Step 3: If the child was negative, and we're supposed to, create it.*/ + /*Step 3: If the child was negative, and we're supposed to, create it.*/ if (dchild->d_inode == NULL) { - unsigned long ino; + unsigned long ino = rec->ur_fid2->id; struct iattr iattr; struct inode *inode; - - ino = (unsigned long)id_ino(rec->ur_id2); - - rc = mds_try_to_split_dir(obd, dparent, &mea, 0, - update_mode); - + rc = mds_try_to_split_dir(obd, dparent, &mea, 0, update_mode); CDEBUG(D_OTHER, "%s: splitted %lu/%u - %d\n", obd->obd_name, dparent->d_inode->i_ino, dparent->d_inode->i_generation, rc); - if (rc > 0) { /* dir got splitted */ GOTO(cleanup, rc = -ERESTART); @@ -1023,10 +1011,7 @@ got_child: } if (!(rec->ur_flags & MDS_OPEN_CREAT)) { - /* - * dentry is negative and we weren't supposed to create - * object, get out of here. - */ + /* It's negative and we weren't supposed to create it */ GOTO(cleanup, rc = -ENOENT); } @@ -1042,7 +1027,7 @@ got_child: dp.p_ptr = req; dp.p_inum = ino; - rc = ll_vfs_create(dparent->d_inode, dchild, rec->ur_mode, NULL); + rc = ll_vfs_create(dparent->d_inode, dchild, rec->ur_mode,NULL); if (dchild->d_fsdata == (void *)(unsigned long)ino) dchild->d_fsdata = NULL; @@ -1053,23 +1038,22 @@ got_child: inode = dchild->d_inode; if (ino) { LASSERT(ino == inode->i_ino); - - /* written as part of setattr */ - inode->i_generation = id_gen(rec->ur_id2); + /* Written as part of setattr */ + inode->i_generation = rec->ur_fid2->generation; CDEBUG(D_HA, "recreated ino %lu with gen %u\n", inode->i_ino, inode->i_generation); } created = 1; - LTIME_S(iattr.ia_atime) = LTIME_S(rec->ur_time); - LTIME_S(iattr.ia_ctime) = LTIME_S(rec->ur_time); - LTIME_S(iattr.ia_mtime) = LTIME_S(rec->ur_time); + LTIME_S(iattr.ia_atime) = rec->ur_time; + LTIME_S(iattr.ia_ctime) = rec->ur_time; + LTIME_S(iattr.ia_mtime) = rec->ur_time; - iattr.ia_uid = rec->ur_fsuid; + iattr.ia_uid = rec->_ur_fsuid; if (dparent->d_inode->i_mode & S_ISGID) iattr.ia_gid = dparent->d_inode->i_gid; else - iattr.ia_gid = rec->ur_fsgid; + iattr.ia_gid = rec->_ur_fsgid; iattr.ia_valid = ATTR_UID | ATTR_GID | ATTR_ATIME | ATTR_MTIME | ATTR_CTIME; @@ -1086,30 +1070,6 @@ got_child: else MDS_UPDATE_COUNTER(mds, MDS_CREATE_COUNT); - down(&dchild->d_inode->i_sem); - if (ino) { - rc = mds_update_inode_sid(obd, dchild->d_inode, - handle, rec->ur_id2); - if (rc) { - CERROR("mds_update_inode_sid() failed, " - "rc = %d\n", rc); - } - spin_lock(&mds->mds_fid_lock); - if (id_fid(rec->ur_id2) > mds->mds_last_fid) - mds->mds_last_fid = id_fid(rec->ur_id2); - spin_unlock(&mds->mds_fid_lock); - - id_assign_fid(&body->id1, rec->ur_id2); - } else { - rc = mds_alloc_inode_sid(obd, dchild->d_inode, - handle, &body->id1); - if (rc) { - CERROR("mds_alloc_inode_sid() failed, " - "rc = %d\n", rc); - } - } - up(&dchild->d_inode->i_sem); - if (!(rec->ur_flags & O_EXCL)) { /* bug 3313 */ rc = fsfilt_commit(obd, dchild->d_inode->i_sb, dchild->d_inode, handle, 0); @@ -1117,20 +1077,14 @@ got_child: } acc_mode = 0; /* Don't check for permissions */ - - /* - * we do not read fid from EA here, because itis already updated - * and thus we avoid not needed possible IO, locking, etc. - */ - body->valid |= OBD_MD_FID; - mds_pack_inode2body(obd, body, dchild->d_inode, 0); - } else { - mds_pack_inode2body(obd, body, dchild->d_inode, 1); } LASSERTF(!mds_inode_is_orphan(dchild->d_inode), "dchild %*s (%p) inode %p\n", dchild->d_name.len, dchild->d_name.name, dchild, dchild->d_inode); + mds_pack_inode2fid(obd, &body->fid1, dchild->d_inode); + mds_pack_inode2body(obd, body, dchild->d_inode); + if (S_ISREG(dchild->d_inode->i_mode)) { /* Check permissions etc */ rc = ll_permission(dchild->d_inode, acc_mode, NULL); @@ -1182,8 +1136,8 @@ got_child: } /* Step 5: mds_open it */ - rc = mds_finish_open(req, dchild, body, rec->ur_flags, &handle, - rec, rep); + rc = mds_finish_open(req, dchild, body, rec->ur_flags, &handle, rec, + rep); GOTO(cleanup, rc); cleanup: @@ -1238,8 +1192,8 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset, int unlink_orphan) { struct inode *inode = mfd->mfd_dentry->d_inode; - char idname[LL_ID_NAMELEN]; - int last_orphan, idlen, rc = 0, cleanup_phase = 0; + char fidname[LL_FID_NAMELEN]; + int last_orphan, fidlen, rc = 0, cleanup_phase = 0; struct dentry *pending_child = NULL; struct mds_obd *mds = &obd->u.mds; struct inode *pending_dir = mds->mds_pending_dir->d_inode; @@ -1257,12 +1211,11 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset, reply_body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*reply_body)); - idlen = ll_id2str(idname, inode->i_ino, inode->i_generation); - CDEBUG(D_INODE, "inode %p ino %s nlink %d orphan %d\n", inode, - idname, inode->i_nlink, mds_orphan_open_count(inode)); - + fidlen = ll_fid2str(fidname, inode->i_ino, inode->i_generation); + CDEBUG(D_INODE, "inode %p ino %s nlink %d orphan %d\n", inode, fidname, + inode->i_nlink, mds_orphan_open_count(inode)); last_orphan = mds_orphan_open_dec_test(inode) && - mds_inode_is_orphan(inode); + mds_inode_is_orphan(inode); UP_WRITE_I_ALLOC_SEM(inode); /* this is half of the actual "close" */ @@ -1280,26 +1233,24 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset, if (obd->obd_recovering) { CDEBUG(D_HA, "not remove orphan %s until recovery" - " is over\n", idname); + " is over\n", fidname); GOTO(out, rc); } - CDEBUG(D_HA, "destroying orphan object %s\n", idname); + CDEBUG(D_HA, "destroying orphan object %s\n", fidname); if ((S_ISREG(inode->i_mode) && inode->i_nlink != 1) || (S_ISDIR(inode->i_mode) && inode->i_nlink != 2)) CERROR("found \"orphan\" %s %s with link count %d\n", S_ISREG(inode->i_mode) ? "file" : "dir", - idname, inode->i_nlink); - /* - * sadly, there is no easy way to save pending_child from - * mds_reint_unlink() into mfd, so we need to re-lookup, but - * normally it will still be in the dcache. - */ + fidname, inode->i_nlink); + /* Sadly, there is no easy way to save pending_child from + * mds_reint_unlink() into mfd, so we need to re-lookup, + * but normally it will still be in the dcache. */ down(&pending_dir->i_sem); - cleanup_phase = 1; /* up(i_sem) when finished */ - pending_child = lookup_one_len(idname, mds->mds_pending_dir, - idlen); + cleanup_phase = 1; /* up(&pending_dir->i_sem) when finished */ + pending_child = lookup_one_len(fidname, mds->mds_pending_dir, + fidlen); if (IS_ERR(pending_child)) GOTO(cleanup, rc = PTR_ERR(pending_child)); LASSERT(pending_child->d_inode != NULL); @@ -1326,8 +1277,7 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset, else rc = vfs_unlink(pending_dir, pending_child); if (rc) - CERROR("error unlinking orphan %s: rc %d\n", - idname, rc); + CERROR("error unlinking orphan %s: rc %d\n",fidname,rc); if (req != NULL && req->rq_repmsg != NULL && (reply_body->valid & OBD_MD_FLEASIZE) && @@ -1392,7 +1342,7 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset, GOTO(cleanup, rc = PTR_ERR(handle)); rc = fsfilt_setattr(obd, mfd->mfd_dentry, handle, &iattr, 0); if (rc) - CERROR("error in setattr(%s): rc %d\n", idname, rc); + CERROR("error in setattr(%s): rc %d\n", fidname, rc); } out: /* If other clients have this file open for write, rc will be > 0 */ @@ -1469,8 +1419,7 @@ int mds_close(struct ptlrpc_request *req, int offset) mfd = mds_handle2mfd(&body->handle); if (mfd == NULL) { DEBUG_REQ(D_ERROR, req, "no handle for file close ino "LPD64 - ": cookie "LPX64, body->id1.li_stc.u.e3s.l3s_ino, - body->handle.cookie); + ": cookie "LPX64, body->fid1.id, body->handle.cookie); req->rq_status = -ESTALE; RETURN(-ESTALE); } @@ -1482,7 +1431,8 @@ int mds_close(struct ptlrpc_request *req, int offset) body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); LASSERT(body != NULL); - mds_pack_inode2body(obd, body, inode, 0); + mds_pack_inode2fid(obd, &body->fid1, inode); + mds_pack_inode2body(obd, body, inode); mds_pack_md(obd, req->rq_repmsg, 1, body, inode, MDS_PACK_MD_LOCK); } spin_lock(&med->med_open_lock); diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index 13e807a..1de982c 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -44,6 +44,12 @@ #include #include "mds_internal.h" +void mds_commit_cb(struct obd_device *obd, __u64 transno, void *data, + int error) +{ + obd_transno_commit_cb(obd, transno, error); +} + struct mds_logcancel_data { struct lov_mds_md *mlcd_lmm; int mlcd_size; @@ -52,6 +58,7 @@ struct mds_logcancel_data { struct llog_cookie mlcd_cookies[0]; }; + static void mds_cancel_cookies_cb(struct obd_device *obd, __u64 transno, void *cb_data, int error) { @@ -65,7 +72,7 @@ static void mds_cancel_cookies_cb(struct obd_device *obd, __u64 transno, CDEBUG(D_HA, "cancelling %d cookies\n", (int)(mlcd->mlcd_cookielen / sizeof(*mlcd->mlcd_cookies))); - rc = obd_unpackmd(obd->u.mds.mds_lov_exp, &lsm, mlcd->mlcd_lmm, + rc = obd_unpackmd(obd->u.mds.mds_osc_exp, &lsm, mlcd->mlcd_lmm, mlcd->mlcd_eadatalen); if (rc < 0) { CERROR("bad LSM cancelling %d log cookies: rc %d\n", @@ -94,16 +101,17 @@ int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle, struct mds_export_data *med = &req->rq_export->exp_mds_data; struct mds_client_data *mcd = med->med_mcd; struct obd_device *obd = req->rq_export->exp_obd; + int err; __u64 transno; loff_t off; - int err, log_pri = D_HA; + int log_pri = D_HA; ENTRY; /* if the export has already been failed, we have no last_rcvd slot */ if (req->rq_export->exp_failed) { CERROR("committing transaction for disconnected client\n"); if (handle) - GOTO(out_commit, rc); + GOTO(commit, rc); RETURN(rc); } @@ -141,8 +149,9 @@ int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle, mcd->mcd_last_result = cpu_to_le32(rc); mcd->mcd_last_data = cpu_to_le32(op_data); + fsfilt_add_journal_cb(req->rq_export->exp_obd, mds->mds_sb, - transno, handle, mds_commit_last_transno_cb, NULL); + transno, handle, mds_commit_cb, NULL); err = fsfilt_write_record(obd, mds->mds_rcvd_filp, mcd, sizeof(*mcd), &off, 0); @@ -157,25 +166,6 @@ int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle, "wrote trans #"LPU64" client %s at idx %u: err = %d", transno, mcd->mcd_uuid, med->med_idx, err); - /* writing last fid. */ - off = 0; - - fsfilt_add_journal_cb(req->rq_export->exp_obd, mds->mds_sb, - mds->mds_last_fid, handle, mds_commit_last_fid_cb, - NULL); - - err = fsfilt_write_record(obd, mds->mds_fid_filp, &mds->mds_last_fid, - sizeof(mds->mds_last_fid), &off, 0); - if (err) { - log_pri = D_ERROR; - if (rc == 0) - rc = err; - } - - DEBUG_REQ(log_pri, req, - "wrote fid #"LPU64" client %s at idx %llu: err = %d", - mds->mds_last_fid, mcd->mcd_uuid, off, err); - err = mds_lov_write_objids(obd); if (err) { log_pri = D_ERROR; @@ -184,7 +174,7 @@ int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle, } CDEBUG(log_pri, "wrote objids: err = %d\n", err); -out_commit: +commit: err = fsfilt_commit(obd, mds->mds_sb, inode, handle, 0); if (err) { CERROR("error committing transaction: %d\n", err); @@ -224,7 +214,7 @@ int mds_fix_attr(struct inode *inode, struct mds_update_record *rec) /* times */ if ((ia_valid & (ATTR_MTIME|ATTR_ATIME)) == (ATTR_MTIME|ATTR_ATIME)) { - if (rec->ur_fsuid != inode->i_uid && + if (rec->_ur_fsuid != inode->i_uid && (error = ll_permission(inode, MAY_WRITE, NULL)) != 0) RETURN(error); } @@ -356,19 +346,21 @@ static void reconstruct_reint_setattr(struct mds_update_record *rec, int offset, struct ptlrpc_request *req) { struct mds_export_data *med = &req->rq_export->exp_mds_data; - struct mds_body *body; + struct mds_obd *obd = &req->rq_export->exp_obd->u.mds; struct dentry *de; + struct mds_body *body; mds_req_from_mcd(req, med->med_mcd); - de = mds_id2dentry(req2obd(req), rec->ur_id1, NULL); + de = mds_fid2dentry(obd, rec->ur_fid1, NULL); if (IS_ERR(de)) { LASSERT(PTR_ERR(de) == req->rq_status); return; } - body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - mds_pack_inode2body(req2obd(req), body, de->d_inode, 0); + body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); + mds_pack_inode2fid(req2obd(req), &body->fid1, de->d_inode); + mds_pack_inode2body(req2obd(req), body, de->d_inode); /* Don't return OST-specific attributes if we didn't just set them */ if (rec->ur_iattr.ia_valid & ATTR_SIZE) @@ -387,7 +379,8 @@ static void reconstruct_reint_setattr(struct mds_update_record *rec, * * We use the ATTR_FROM_OPEN flag to tell these cases apart. */ static int mds_reint_setattr(struct mds_update_record *rec, int offset, - struct ptlrpc_request *req, struct lustre_handle *lh) + struct ptlrpc_request *req, + struct lustre_handle *lh) { struct mds_obd *mds = mds_req2mds(req); struct obd_device *obd = req->rq_export->exp_obd; @@ -398,30 +391,28 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset, int parent_mode; void *handle = NULL; struct mds_logcancel_data *mlcd = NULL; - int rc = 0, cleanup_phase = 0, err; - int locked = 0; + int rc = 0, cleanup_phase = 0, err, locked = 0; ENTRY; LASSERT(offset == 1); - DEBUG_REQ(D_INODE, req, "setattr "LPU64"/%u %x", - id_ino(rec->ur_id1), id_gen(rec->ur_id1), - rec->ur_iattr.ia_valid); + DEBUG_REQ(D_INODE, req, "setattr "LPU64"/%u %x", rec->ur_fid1->id, + rec->ur_fid1->generation, rec->ur_iattr.ia_valid); MDS_CHECK_RESENT(req, reconstruct_reint_setattr(rec, offset, req)); MDS_UPDATE_COUNTER(mds, MDS_SETATTR_COUNT); if (rec->ur_iattr.ia_valid & ATTR_FROM_OPEN) { - de = mds_id2dentry(obd, rec->ur_id1, NULL); + de = mds_fid2dentry(mds, rec->ur_fid1, NULL); if (IS_ERR(de)) GOTO(cleanup, rc = PTR_ERR(de)); } else { __u64 lockpart = MDS_INODELOCK_UPDATE; - if (rec->ur_iattr.ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID)) + if (rec->ur_iattr.ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID) ) lockpart |= MDS_INODELOCK_LOOKUP; - de = mds_id2locked_dentry(obd, rec->ur_id1, NULL, LCK_PW, - lockh, &parent_mode, NULL, 0, lockpart); + de = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, LCK_PW, + lockh, &parent_mode, NULL, 0, lockpart); if (IS_ERR(de)) GOTO(cleanup, rc = PTR_ERR(de)); locked = 1; @@ -463,12 +454,12 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset, if (rc < 0) GOTO(cleanup, rc); - rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, mds->mds_lov_exp, - 0, &lsm, rec->ur_eadata); + rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, + mds->mds_osc_exp, 0, &lsm, rec->ur_eadata); if (rc) GOTO(cleanup, rc); - obd_free_memmd(mds->mds_lov_exp, &lsm); + obd_free_memmd(mds->mds_osc_exp, &lsm); rc = fsfilt_set_md(obd, inode, handle, rec->ur_eadata, rec->ur_eadatalen); @@ -477,7 +468,8 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset, } body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); - mds_pack_inode2body(obd, body, inode, 0); + mds_pack_inode2fid(obd, &body->fid1, inode); + mds_pack_inode2body(obd, body, inode); /* Don't return OST-specific attributes if we didn't just set them */ if (rec->ur_iattr.ia_valid & ATTR_SIZE) @@ -487,7 +479,7 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset, if (rec->ur_iattr.ia_valid & (ATTR_ATIME | ATTR_ATIME_SET)) body->valid |= OBD_MD_FLATIME; - if (rc == 0 && rec->ur_cookielen && !IS_ERR(mds->mds_lov_obd)) { + if (rc == 0 && rec->ur_cookielen && !IS_ERR(mds->mds_osc_obd)) { OBD_ALLOC(mlcd, sizeof(*mlcd) + rec->ur_cookielen + rec->ur_eadatalen); if (mlcd) { @@ -544,6 +536,7 @@ static void reconstruct_reint_create(struct mds_update_record *rec, int offset, struct ptlrpc_request *req) { struct mds_export_data *med = &req->rq_export->exp_mds_data; + struct mds_obd *obd = &req->rq_export->exp_obd->u.mds; struct dentry *parent, *child; struct mds_body *body; ENTRY; @@ -555,22 +548,25 @@ static void reconstruct_reint_create(struct mds_update_record *rec, int offset, return; } - parent = mds_id2dentry(req2obd(req), rec->ur_id1, NULL); + parent = mds_fid2dentry(obd, rec->ur_fid1, NULL); LASSERT(!IS_ERR(parent)); - child = ll_lookup_one_len(rec->ur_name, parent, - rec->ur_namelen - 1); + child = ll_lookup_one_len(rec->ur_name, parent, rec->ur_namelen - 1); LASSERT(!IS_ERR(child)); if ((child->d_flags & DCACHE_CROSS_REF)) { LASSERTF(child->d_inode == NULL, "BUG 3869\n"); - body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - mds_pack_dentry2body(req2obd(req), body, child, 1); + body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); + mds_pack_dentry2fid(&body->fid1, child); + mds_pack_dentry2body(body, child); + body->valid |= OBD_MD_MDS; } else if (child->d_inode == NULL) { - DEBUG_REQ(D_ERROR, req, "parent "DLID4" name %s mode %o", - OLID4(rec->ur_id1), rec->ur_name, rec->ur_mode); + DEBUG_REQ(D_ERROR, req, "parent "LPU64"/%u name %s mode %o", + rec->ur_fid1->id, rec->ur_fid1->generation, + rec->ur_name, rec->ur_mode); LASSERTF(child->d_inode != NULL, "BUG 3869\n"); } else { - body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - mds_pack_inode2body(req2obd(req), body, child->d_inode, 1); + body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); + mds_pack_inode2fid(req2obd(req), &body->fid1, child->d_inode); + mds_pack_inode2body(req2obd(req), body, child->d_inode); } l_dput(parent); l_dput(child); @@ -597,22 +593,21 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, ENTRY; LASSERT(offset == 1); - - LASSERT(!strcmp(req->rq_export->exp_obd->obd_type->typ_name, - LUSTRE_MDS_NAME)); + LASSERT(!strcmp(req->rq_export->exp_obd->obd_type->typ_name, LUSTRE_MDS_NAME)); DEBUG_REQ(D_INODE, req, "parent "LPU64"/%u name %s mode %o", - id_ino(rec->ur_id1), id_gen(rec->ur_id1), + rec->ur_fid1->id, rec->ur_fid1->generation, rec->ur_name, rec->ur_mode); MDS_CHECK_RESENT(req, reconstruct_reint_create(rec, offset, req)); + if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE)) GOTO(cleanup, rc = -ESTALE); - dparent = mds_id2locked_dentry(obd, rec->ur_id1, NULL, LCK_PW, - lockh, &parent_mode, rec->ur_name, - rec->ur_namelen - 1, MDS_INODELOCK_UPDATE); + dparent = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, LCK_PW, lockh, + &parent_mode, rec->ur_name, + rec->ur_namelen - 1, MDS_INODELOCK_UPDATE); if (IS_ERR(dparent)) { rc = PTR_ERR(dparent); CERROR("parent lookup error %d\n", rc); @@ -630,27 +625,24 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, GOTO(cleanup, rc); if (mea != NULL) { - /* - * dir is already splitted, check is requested filename should - * live at this MDS or at another one. - */ - int i = mea_name2idx(mea, rec->ur_name, rec->ur_namelen - 1); - if (mea->mea_master != id_group(&mea->mea_ids[i])) { + /* dir is already splitted, check is requested filename + * should live at this MDS or at another one */ + int i; + i = mea_name2idx(mea, rec->ur_name, rec->ur_namelen - 1); + if (mea->mea_master != mea->mea_fids[i].mds) { CDEBUG(D_OTHER, "inapropriate MDS(%d) for %lu/%u:%s." - " should be %lu(%d)\n", + " should be %d(%d)\n", mea->mea_master, dparent->d_inode->i_ino, dparent->d_inode->i_generation, rec->ur_name, - (unsigned long)id_group(&mea->mea_ids[i]), i); + mea->mea_fids[i].mds, i); GOTO(cleanup, rc = -ERESTART); } } - dchild = ll_lookup_one_len(rec->ur_name, dparent, - rec->ur_namelen - 1); + dchild = ll_lookup_one_len(rec->ur_name, dparent, rec->ur_namelen - 1); if (IS_ERR(dchild)) { rc = PTR_ERR(dchild); - CERROR("Can't find "DLID4"/%s, error %d\n", - OLID4(rec->ur_id1), rec->ur_name, rc); + CERROR("child lookup error %d\n", rc); GOTO(cleanup, rc); } @@ -677,13 +669,8 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, rec->ur_mode |= S_ISGID; } - /* - * here inode number should be used only in the case of replaying. It is - * needed to check if object already created in the case of creating - * remote inode. - */ dchild->d_fsdata = (void *)&dp; - dp.p_inum = (unsigned long)id_ino(rec->ur_id2); + dp.p_inum = (unsigned long)rec->ur_fid2->id; dp.p_ptr = req; switch (type) { @@ -696,15 +683,13 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, break; } case S_IFDIR:{ - int i, nstripes = 0; - struct lustre_id sid; + int nstripes = 0; + int i; - /* - * as Peter asked, mkdir() should distribute new directories + /* as Peter asked, mkdir() should distribute new directories * over the whole cluster in order to distribute namespace * processing load. first, we calculate which MDS to use to put - * new directory's inode in. - */ + * new directory's inode in. */ i = mds_choose_mdsnum(obd, rec->ur_name, rec->ur_namelen - 1, rec->ur_flags); if (i == mds->mds_num) { @@ -714,50 +699,15 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, GOTO(cleanup, rc = PTR_ERR(handle)); rc = vfs_mkdir(dir, dchild, rec->ur_mode); - if (rc) { - CERROR("Can't create dir %s, rc = %d\n", - dchild->d_name.name, rc); - GOTO(cleanup, rc); - } - - down(&dchild->d_inode->i_sem); - if (dp.p_inum) { - rc = mds_update_inode_sid(obd, dchild->d_inode, - handle, rec->ur_id2); - if (rc) { - CERROR("mds_update_inode_sid() failed, inode %lu, " - "rc %d\n", dchild->d_inode->i_ino, rc); - } - /* - * check if fid from client is bigger than local - * last used value. - */ - spin_lock(&mds->mds_fid_lock); - if (id_fid(rec->ur_id2) > mds->mds_last_fid) - mds->mds_last_fid = id_fid(rec->ur_id2); - spin_unlock(&mds->mds_fid_lock); - } else { - rc = mds_alloc_inode_sid(obd, dchild->d_inode, - handle, &sid); - if (rc) { - CERROR("mds_alloc_inode_sid() failed, inode %lu, " - "rc %d\n", dchild->d_inode->i_ino, rc); - } - } - up(&dchild->d_inode->i_sem); - - if (rc) - GOTO(cleanup, rc); - if (rec->ur_eadata) nstripes = *(u16 *)rec->ur_eadata; if (rc == 0 && nstripes) { - /* we pass LCK_EX to split routine to signal, - * that we have exclusive access to the - * directory. Simple because nobody knows it - * already exists -bzzz */ + /* we pass LCK_EX to split routine to + * signalthat we have exclusive access + * to the directory. simple because + * nobody knows it already exists -bzzz */ rc = mds_try_to_split_dir(obd, dchild, NULL, nstripes, LCK_EX); @@ -777,12 +727,9 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, /* first, create that inode */ oa = obdo_alloc(); - if (!oa) - GOTO(cleanup, rc = -ENOMEM); - + LASSERT(oa != NULL); oa->o_mds = i; oa->o_easize = 0; - if (rec->ur_eadata) { /* user asks for creating splitted dir */ oa->o_easize = *((u16 *) rec->ur_eadata); @@ -791,35 +738,24 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, obdo_from_inode(oa, dir, OBD_MD_FLTYPE | OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLUID | OBD_MD_FLGID); - oa->o_mode = dir->i_mode; - CDEBUG(D_OTHER, "%s: create dir on MDS %u\n", - obd->obd_name, i); - + obd->obd_name, i); if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) { - /* - * here inode number and generation are - * important, as this is replay request and we - * need them to check if such an object is - * already created. - */ CDEBUG(D_HA, "%s: replay dir creation %*s -> %u/%u\n", obd->obd_name, rec->ur_namelen - 1, - rec->ur_name, (unsigned)id_ino(rec->ur_id2), - (unsigned)id_gen(rec->ur_id2)); - oa->o_id = id_ino(rec->ur_id2); - oa->o_fid = id_fid(rec->ur_id2); - oa->o_generation = id_gen(rec->ur_id2); + rec->ur_name, (unsigned) rec->ur_fid2->id, + (unsigned) rec->ur_fid2->generation); + oa->o_id = rec->ur_fid2->id; + oa->o_generation = rec->ur_fid2->generation; oa->o_flags |= OBD_FL_RECREATE_OBJS; } - /* before obd_create() is called, o_fid is not known. */ rc = obd_create(mds->mds_lmv_exp, oa, NULL, NULL); if (rc) { CERROR("can't create remote inode: %d\n", rc); DEBUG_REQ(D_ERROR, req, "parent "LPU64"/%u name %s mode %o", - id_ino(rec->ur_id1), id_gen(rec->ur_id1), + rec->ur_fid1->id, rec->ur_fid1->generation, rec->ur_name, rec->ur_mode); obdo_free(oa); GOTO(cleanup, rc); @@ -831,29 +767,19 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, obdo_free(oa); GOTO(cleanup, rc = PTR_ERR(handle)); } - - /* creating local dentry for remote inode. */ rc = fsfilt_add_dir_entry(obd, dparent, rec->ur_name, - rec->ur_namelen - 1, oa->o_id, - oa->o_generation, i, oa->o_fid); - - if (rc) { - CERROR("Can't create local entry %*s for " - "remote inode.\n", rec->ur_namelen - 1, - rec->ur_name); - GOTO(cleanup, rc); - } + rec->ur_namelen - 1, + oa->o_id, oa->o_generation, + i); + LASSERT(rc == 0); /* fill reply */ - body = lustre_msg_buf(req->rq_repmsg, - 0, sizeof(*body)); - body->valid |= OBD_MD_FLID | OBD_MD_MDS | - OBD_MD_FID; - - id_group(&body->id1) = i; - id_ino(&body->id1) = oa->o_id; - id_fid(&body->id1) = oa->o_fid; - id_gen(&body->id1) = oa->o_generation; + body = lustre_msg_buf(req->rq_repmsg, 0, + sizeof (*body)); + body->valid |= OBD_MD_FLID | OBD_MD_MDS; + body->fid1.id = oa->o_id; + body->fid1.mds = i; + body->fid1.generation = oa->o_generation; obdo_free(oa); } else { /* requested name exists in the directory */ @@ -892,7 +818,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, } /* In case we stored the desired inum in here, we want to clean up. */ - if (dchild->d_fsdata == (void *)(unsigned long)id_ino(rec->ur_id2)) + if (dchild->d_fsdata == (void *)(unsigned long)rec->ur_fid2->id) dchild->d_fsdata = NULL; if (rc) { @@ -900,48 +826,25 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, GOTO(cleanup, rc); } else if (dchild->d_inode) { struct iattr iattr; - struct mds_body *body; struct inode *inode = dchild->d_inode; + struct mds_body *body; created = 1; - iattr.ia_uid = rec->ur_fsuid; - LTIME_S(iattr.ia_atime) = LTIME_S(rec->ur_time); - LTIME_S(iattr.ia_ctime) = LTIME_S(rec->ur_time); - LTIME_S(iattr.ia_mtime) = LTIME_S(rec->ur_time); - + LTIME_S(iattr.ia_atime) = rec->ur_time; + LTIME_S(iattr.ia_ctime) = rec->ur_time; + LTIME_S(iattr.ia_mtime) = rec->ur_time; + iattr.ia_uid = rec->_ur_fsuid; if (dir->i_mode & S_ISGID) iattr.ia_gid = dir->i_gid; else - iattr.ia_gid = rec->ur_fsgid; - + iattr.ia_gid = rec->_ur_fsgid; iattr.ia_valid = ATTR_UID | ATTR_GID | ATTR_ATIME | ATTR_MTIME | ATTR_CTIME; - if (id_ino(rec->ur_id2)) { - LASSERT(id_ino(rec->ur_id2) == inode->i_ino); - inode->i_generation = id_gen(rec->ur_id2); - - if (type != S_IFDIR) { - /* - * updating inode self id, as inode already - * exists and we should make sure, its sid will - * be the same as we reveived. - */ - down(&inode->i_sem); - rc = mds_update_inode_sid(obd, inode, - handle, rec->ur_id2); - up(&inode->i_sem); - if (rc) { - CERROR("Can't update inode self id, " - "rc = %d.\n", rc); - } - spin_lock(&mds->mds_fid_lock); - if (id_fid(rec->ur_id2) > mds->mds_last_fid) - mds->mds_last_fid = id_fid(rec->ur_id2); - spin_unlock(&mds->mds_fid_lock); - } - - /* dirtied and committed by the upcoming setattr. */ + if (rec->ur_fid2->id) { + LASSERT(rec->ur_fid2->id == inode->i_ino); + inode->i_generation = rec->ur_fid2->generation; + /* Dirtied and committed by the upcoming setattr. */ CDEBUG(D_INODE, "recreated ino %lu with gen %u\n", inode->i_ino, inode->i_generation); } else { @@ -953,14 +856,12 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, inode->i_ino, inode->i_generation); #if 0 - /* - * the inode we were allocated may have just been freed + /* The inode we were allocated may have just been freed * by an unlink operation. We take this lock to * synchronize against the matching reply-ack-lock taken * in unlink, to avoid replay problems if this reply * makes it out to the client but the unlink's does not. - * See bug 2029 for more detail. - */ + * See bug 2029 for more detail.*/ rc = mds_lock_new_child(obd, inode, &child_ino_lockh); if (rc != ELDLM_OK) { CERROR("error locking for unlink/create sync: " @@ -969,24 +870,6 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, ldlm_lock_decref(&child_ino_lockh, LCK_EX); } #endif - if (type != S_IFDIR) { - struct lustre_id sid; - - /* - * allocate new id for @inode if it is not dir, - * because for dir it was already done. - */ - down(&inode->i_sem); - rc = mds_alloc_inode_sid(obd, inode, - handle, &sid); - up(&inode->i_sem); - if (rc) { - CERROR("mds_alloc_inode_sid() failed, " - "inode %lu, rc %d\n", inode->i_ino, - rc); - } - } - } rc = fsfilt_setattr(obd, dchild, handle, &iattr, 0); @@ -1000,8 +883,9 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, else MDS_UPDATE_COUNTER(mds, MDS_CREATE_COUNT); - body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); - mds_pack_inode2body(obd, body, inode, 1); + body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); + mds_pack_inode2fid(obd, &body->fid1, inode); + mds_pack_inode2body(obd, body, inode); } EXIT; @@ -1054,13 +938,19 @@ cleanup: return 0; } -static inline int -res_gt(struct ldlm_res_id *res1, struct ldlm_res_id *res2, - ldlm_policy_data_t *p1, ldlm_policy_data_t *p2) +static int res_gt(struct ldlm_res_id *res1, struct ldlm_res_id *res2, + ldlm_policy_data_t *p1, ldlm_policy_data_t *p2) { int i; for (i = 0; i < RES_NAME_SIZE; i++) { + /* return 1 here, because enqueue_ordered will skip resources + * of all zeroes if they're sorted to the end of the list. */ + if (res1->name[i] == 0 && res2->name[i] != 0) + return 1; + if (res2->name[i] == 0 && res1->name[i] != 0) + return 0; + if (res1->name[i] > res2->name[i]) return 1; if (res1->name[i] < res2->name[i]) @@ -1089,20 +979,19 @@ int enqueue_ordered_locks(struct obd_device *obd, struct ldlm_res_id *p1_res_id, struct lustre_handle *p2_lockh, int p2_lock_mode, ldlm_policy_data_t *p2_policy) { - int lock_modes[2] = { p1_lock_mode, p2_lock_mode }; struct ldlm_res_id *res_id[2] = { p1_res_id, p2_res_id }; struct lustre_handle *handles[2] = { p1_lockh, p2_lockh }; + int lock_modes[2] = { p1_lock_mode, p2_lock_mode }; ldlm_policy_data_t *policies[2] = { p1_policy, p2_policy }; int rc, flags; ENTRY; LASSERT(p1_res_id != NULL && p2_res_id != NULL); - CDEBUG(D_INFO, "locks before: "LPU64"/"LPU64"\n", - res_id[0]->name[0], res_id[1]->name[0]); + CDEBUG(D_INFO, "locks before: "LPU64"/"LPU64"\n", res_id[0]->name[0], + res_id[1]->name[0]); - if (p2_res_id->name[0] != 0 && - res_gt(p1_res_id, p2_res_id, p1_policy, p2_policy)) { + if (res_gt(p1_res_id, p2_res_id, p1_policy, p2_policy)) { handles[1] = p1_lockh; handles[0] = p2_lockh; res_id[1] = p1_res_id; @@ -1261,11 +1150,8 @@ static int mds_verify_child(struct obd_device *obd, struct dentry **dchildp, int child_mode, ldlm_policy_data_t *child_policy, const char *name, int namelen, - struct ldlm_res_id *maxres, - unsigned long child_ino, - __u32 child_gen) + struct ldlm_res_id *maxres) { - struct lustre_id sid; struct dentry *vchild, *dchild = *dchildp; int rc = 0, cleanup_phase = 2; /* parent, child locks */ ENTRY; @@ -1275,9 +1161,9 @@ static int mds_verify_child(struct obd_device *obd, GOTO(cleanup, rc = PTR_ERR(vchild)); if ((vchild->d_flags & DCACHE_CROSS_REF)) { - if (child_gen == vchild->d_generation && - child_ino == vchild->d_inum) { - if (dchild) + if (child_res_id->name[0] == vchild->d_inum && + child_res_id->name[1] == vchild->d_generation) { + if (dchild != NULL) l_dput(dchild); *dchildp = vchild; RETURN(0); @@ -1287,11 +1173,12 @@ static int mds_verify_child(struct obd_device *obd, if (likely((vchild->d_inode == NULL && child_res_id->name[0] == 0) || (vchild->d_inode != NULL && - child_gen == vchild->d_inode->i_generation && - child_ino == vchild->d_inode->i_ino))) { - if (dchild) + child_res_id->name[0] == vchild->d_inode->i_ino && + child_res_id->name[1] == vchild->d_inode->i_generation))) { + if (dchild != NULL) l_dput(dchild); *dchildp = vchild; + RETURN(0); } @@ -1300,7 +1187,6 @@ changed: vchild->d_inode, dchild ? dchild->d_inode : 0, vchild->d_inode ? vchild->d_inode->i_ino : 0, child_res_id->name[0]); - if (child_res_id->name[0] != 0) ldlm_lock_decref(child_lockh, child_mode); if (dchild) @@ -1311,21 +1197,12 @@ changed: if (dchild->d_inode || (dchild->d_flags & DCACHE_CROSS_REF)) { int flags = 0; - if (dchild->d_inode) { - down(&dchild->d_inode->i_sem); - rc = mds_read_inode_sid(obd, dchild->d_inode, &sid); - up(&dchild->d_inode->i_sem); - if (rc) { - CERROR("Can't read inode self id, inode %lu," - " rc %d\n", dchild->d_inode->i_ino, rc); - GOTO(cleanup, rc); - } - child_res_id->name[0] = id_fid(&sid); - child_res_id->name[1] = id_group(&sid); + child_res_id->name[0] = dchild->d_inode->i_ino; + child_res_id->name[1] = dchild->d_inode->i_generation; } else { - child_res_id->name[0] = dchild->d_fid; - child_res_id->name[1] = dchild->d_mdsnum; + child_res_id->name[0] = dchild->d_inum; + child_res_id->name[1] = dchild->d_generation; } if (res_gt(parent_res_id, child_res_id, NULL, NULL) || @@ -1348,6 +1225,7 @@ changed: memset(child_res_id, 0, sizeof(*child_res_id)); } + EXIT; cleanup: if (rc) { switch(cleanup_phase) { @@ -1358,11 +1236,11 @@ cleanup: ldlm_lock_decref(parent_lockh, parent_mode); } } - RETURN(rc); + return rc; } int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds, - struct lustre_id *id, + struct ll_fid *fid, struct lustre_handle *parent_lockh, struct dentry **dparentp, int parent_mode, __u64 parent_lockpart, int *update_mode, @@ -1371,19 +1249,16 @@ int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds, struct dentry **dchildp, int child_mode, __u64 child_lockpart) { + struct ldlm_res_id child_res_id = { .name = {0} }; + struct ldlm_res_id parent_res_id = { .name = {0} }; ldlm_policy_data_t parent_policy = {.l_inodebits = { parent_lockpart }}; ldlm_policy_data_t child_policy = {.l_inodebits = { child_lockpart }}; - struct ldlm_res_id parent_res_id = { .name = {0} }; - struct ldlm_res_id child_res_id = { .name = {0} }; - int rc = 0, cleanup_phase = 0; - unsigned long child_ino; - struct lustre_id sid; - __u32 child_gen = 0; struct inode *inode; + int rc = 0, cleanup_phase = 0; ENTRY; /* Step 1: Lookup parent */ - *dparentp = mds_id2dentry(obd, id, NULL); + *dparentp = mds_fid2dentry(mds, fid, NULL); if (IS_ERR(*dparentp)) { rc = PTR_ERR(*dparentp); *dparentp = NULL; @@ -1393,22 +1268,19 @@ int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds, CDEBUG(D_INODE, "parent ino %lu, name %s\n", (*dparentp)->d_inode->i_ino, name); - parent_res_id.name[0] = id_fid(id); - parent_res_id.name[1] = id_group(id); - + parent_res_id.name[0] = (*dparentp)->d_inode->i_ino; + parent_res_id.name[1] = (*dparentp)->d_inode->i_generation; #ifdef S_PDIROPS parent_lockh[1].cookie = 0; if (name && IS_PDIROPS((*dparentp)->d_inode)) { struct ldlm_res_id res_id = { .name = {0} }; ldlm_policy_data_t policy; int flags = 0; - *update_mode = mds_lock_mode_for_dir(obd, *dparentp, parent_mode); if (*update_mode) { - res_id.name[0] = id_fid(id); - res_id.name[1] = id_group(id); + res_id.name[0] = (*dparentp)->d_inode->i_ino; + res_id.name[1] = (*dparentp)->d_inode->i_generation; policy.l_inodebits.bits = MDS_INODELOCK_UPDATE; - rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, res_id, LDLM_IBITS, &policy, *update_mode, &flags, @@ -1421,9 +1293,9 @@ int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds, } parent_res_id.name[2] = full_name_hash(name, namelen - 1); - - CDEBUG(D_INFO, "take lock on %lu:%lu:"LPX64"\n", - (unsigned long)id_fid(id), (unsigned long)id_group(id), + CDEBUG(D_INFO, "take lock on %lu:%u:"LPX64"\n", + (*dparentp)->d_inode->i_ino, + (*dparentp)->d_inode->i_generation, parent_res_id.name[2]); } #endif @@ -1439,17 +1311,12 @@ int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds, } if ((*dchildp)->d_flags & DCACHE_CROSS_REF) { - /* - * inode lives on another MDS: return * fid/mdsnum and LOOKUP - * lock. Drop possible UPDATE lock! - */ + /* inode lives on another MDS: return * mds/ino/gen + * and LOOKUP lock. drop possible UPDATE lock! */ child_policy.l_inodebits.bits &= ~MDS_INODELOCK_UPDATE; child_policy.l_inodebits.bits |= MDS_INODELOCK_LOOKUP; - - child_res_id.name[0] = (*dchildp)->d_fid; - child_res_id.name[1] = (*dchildp)->d_mdsnum; - child_gen = (*dchildp)->d_generation; - child_ino = (*dchildp)->d_inum; + child_res_id.name[0] = (*dchildp)->d_inum; + child_res_id.name[1] = (*dchildp)->d_generation; goto retry_locks; } @@ -1459,27 +1326,17 @@ int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds, if (inode == NULL) goto retry_locks; - down(&inode->i_sem); - rc = mds_read_inode_sid(obd, inode, &sid); - up(&inode->i_sem); - if (rc) { - CERROR("Can't read inode self id, inode %lu, " - "rc %d\n", inode->i_ino, rc); - GOTO(cleanup, rc); - } - - child_res_id.name[0] = id_fid(&sid); - child_res_id.name[1] = id_group(&sid); - child_gen = inode->i_generation; - child_ino = inode->i_ino; + child_res_id.name[0] = inode->i_ino; + child_res_id.name[1] = inode->i_generation; + iput(inode); retry_locks: cleanup_phase = 2; /* child dentry */ /* Step 3: Lock parent and child in resource order. If child doesn't - * exist, we still have to lock the parent and re-lookup. */ - rc = enqueue_ordered_locks(obd, &parent_res_id, parent_lockh, parent_mode, + * exist, we still have to lock the parent and re-lookup. */ + rc = enqueue_ordered_locks(obd,&parent_res_id,parent_lockh,parent_mode, &parent_policy, &child_res_id, child_lockh, child_mode, &child_policy); if (rc) @@ -1494,8 +1351,7 @@ retry_locks: rc = mds_verify_child(obd, &parent_res_id, parent_lockh, *dparentp, parent_mode, &child_res_id, child_lockh, dchildp, child_mode, &child_policy, - name, namelen, &parent_res_id, - child_ino, child_gen); + name, namelen, &parent_res_id); if (rc > 0) goto retry_locks; if (rc < 0) { @@ -1518,9 +1374,10 @@ cleanup: ldlm_lock_decref(parent_lockh + 1, *update_mode); #endif l_dput(*dparentp); + default: ; } } - RETURN(rc); + return rc; } void mds_reconstruct_generic(struct ptlrpc_request *req) @@ -1549,8 +1406,8 @@ static int mds_orphan_add_link(struct mds_update_record *rec, struct inode *pending_dir = mds->mds_pending_dir->d_inode; struct inode *inode = dentry->d_inode; struct dentry *pending_child; - char idname[LL_ID_NAMELEN]; - int idlen = 0, rc, mode; + char fidname[LL_FID_NAMELEN]; + int fidlen = 0, rc, mode; ENTRY; LASSERT(inode != NULL); @@ -1560,18 +1417,17 @@ static int mds_orphan_add_link(struct mds_update_record *rec, #endif LASSERT(down_trylock(&pending_dir->i_sem) != 0); - idlen = ll_id2str(idname, inode->i_ino, inode->i_generation); + fidlen = ll_fid2str(fidname, inode->i_ino, inode->i_generation); CDEBUG(D_INODE, "pending destroy of %dx open %d linked %s %s = %s\n", mds_orphan_open_count(inode), inode->i_nlink, S_ISDIR(inode->i_mode) ? "dir" : - S_ISREG(inode->i_mode) ? "file" : "other", - rec->ur_name, idname); + S_ISREG(inode->i_mode) ? "file" : "other",rec->ur_name,fidname); if (mds_orphan_open_count(inode) == 0 || inode->i_nlink != 0) RETURN(0); - pending_child = lookup_one_len(idname, mds->mds_pending_dir, idlen); + pending_child = lookup_one_len(fidname, mds->mds_pending_dir, fidlen); if (IS_ERR(pending_child)) RETURN(PTR_ERR(pending_child)); @@ -1611,58 +1467,41 @@ out_dput: } int mds_create_local_dentry(struct mds_update_record *rec, - struct obd_device *obd) + struct obd_device *obd) { struct mds_obd *mds = &obd->u.mds; - struct inode *id_dir = mds->mds_id_dir->d_inode; - int idlen = 0, rc, cleanup_phase = 0; + struct inode *fids_dir = mds->mds_fids_dir->d_inode; + int fidlen = 0, rc, cleanup_phase = 0; struct dentry *new_child = NULL; - char *idname = rec->ur_name; + char *fidname = rec->ur_name; struct dentry *child = NULL; struct lustre_handle lockh[2] = {{0}, {0}}; - struct lustre_id sid; void *handle; ENTRY; - down(&id_dir->i_sem); - idlen = ll_id2str(idname, id_ino(rec->ur_id1), - id_gen(rec->ur_id1)); - - CDEBUG(D_OTHER, "look for local dentry '%s' for "DLID4"\n", - idname, OLID4(rec->ur_id1)); + down(&fids_dir->i_sem); + fidlen = ll_fid2str(fidname, rec->ur_fid1->id, rec->ur_fid1->generation); + CDEBUG(D_OTHER, "look for local dentry '%s' for %u/%u\n", + fidname, (unsigned) rec->ur_fid1->id, + (unsigned) rec->ur_fid1->generation); - new_child = ll_lookup_one_len(idname, mds->mds_id_dir, - idlen); - up(&id_dir->i_sem); + new_child = lookup_one_len(fidname, mds->mds_fids_dir, fidlen); + up(&fids_dir->i_sem); if (IS_ERR(new_child)) { - CERROR("can't lookup %s: %d\n", idname, - (int) PTR_ERR(new_child)); + CERROR("can't lookup %s: %d\n", fidname, + (int) PTR_ERR(new_child)); GOTO(cleanup, rc = PTR_ERR(new_child)); } cleanup_phase = 1; - down(&id_dir->i_sem); - rc = mds_read_inode_sid(obd, id_dir, &sid); - up(&id_dir->i_sem); - if (rc) { - CERROR("Can't read inode self id, inode %lu, " - "rc %d\n", id_dir->i_ino, rc); - GOTO(cleanup, rc); - } - if (new_child->d_inode != NULL) { /* nice. we've already have local dentry! */ CDEBUG(D_OTHER, "found dentry in FIDS/: %u/%u\n", - (unsigned)new_child->d_inode->i_ino, - (unsigned)new_child->d_inode->i_generation); - - id_ino(rec->ur_id1) = id_dir->i_ino; - id_gen(rec->ur_id1) = id_dir->i_generation; - rec->ur_namelen = idlen + 1; - - id_fid(rec->ur_id1) = id_fid(&sid); - id_group(rec->ur_id1) = id_group(&sid); - + (unsigned) new_child->d_inode->i_ino, + (unsigned) new_child->d_inode->i_generation); + rec->ur_fid1->id = fids_dir->i_ino; + rec->ur_fid1->generation = fids_dir->i_generation; + rec->ur_namelen = fidlen + 1; GOTO(cleanup, rc = 0); } @@ -1670,11 +1509,11 @@ int mds_create_local_dentry(struct mds_update_record *rec, d_drop(new_child); if (rec->ur_mode & MDS_MODE_DONT_LOCK) { - child = mds_id2dentry(obd, rec->ur_id1, NULL); + child = mds_fid2dentry(mds, rec->ur_fid1, NULL); } else { - child = mds_id2locked_dentry(obd, rec->ur_id1, NULL, - LCK_EX, lockh, NULL, NULL, 0, - MDS_INODELOCK_UPDATE); + child = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, + LCK_EX, lockh, NULL, NULL, 0, + MDS_INODELOCK_UPDATE); } if (IS_ERR(child)) { @@ -1685,33 +1524,30 @@ int mds_create_local_dentry(struct mds_update_record *rec, } cleanup_phase = 2; - handle = fsfilt_start(obd, id_dir, FSFILT_OP_LINK, NULL); + handle = fsfilt_start(obd, fids_dir, FSFILT_OP_LINK, NULL); if (IS_ERR(handle)) GOTO(cleanup, rc = PTR_ERR(handle)); - rc = fsfilt_add_dir_entry(obd, mds->mds_id_dir, idname, - idlen, id_ino(rec->ur_id1), - id_gen(rec->ur_id1), mds->mds_num, - id_fid(rec->ur_id1)); + rc = fsfilt_add_dir_entry(obd, mds->mds_fids_dir, fidname, fidlen, + rec->ur_fid1->id, rec->ur_fid1->generation, + mds->mds_num); if (rc) CERROR("error linking orphan %lu/%lu to FIDS: rc = %d\n", - (unsigned long)child->d_inode->i_ino, - (unsigned long)child->d_inode->i_generation, rc); + (unsigned long) child->d_inode->i_ino, + (unsigned long) child->d_inode->i_generation, rc); else { if (S_ISDIR(child->d_inode->i_mode)) { - id_dir->i_nlink++; - mark_inode_dirty(id_dir); + fids_dir->i_nlink++; + mark_inode_dirty(fids_dir); } mark_inode_dirty(child->d_inode); } - fsfilt_commit(obd, mds->mds_sb, id_dir, handle, 0); + fsfilt_commit(obd, mds->mds_sb, fids_dir, handle, 0); - id_ino(rec->ur_id1) = id_dir->i_ino; - id_gen(rec->ur_id1) = id_dir->i_generation; - rec->ur_namelen = idlen + 1; + rec->ur_fid1->id = fids_dir->i_ino; + rec->ur_fid1->generation = fids_dir->i_generation; + rec->ur_namelen = fidlen + 1; - id_fid(rec->ur_id1) = id_fid(&sid); - id_group(rec->ur_id1) = id_group(&sid); cleanup: switch(cleanup_phase) { case 2: @@ -1727,7 +1563,7 @@ cleanup: } static int mds_copy_unlink_reply(struct ptlrpc_request *master, - struct ptlrpc_request *slave) + struct ptlrpc_request *slave) { void *cookie, *cookie2; struct mds_body *body2; @@ -1741,8 +1577,9 @@ static int mds_copy_unlink_reply(struct ptlrpc_request *master, body2 = lustre_msg_buf(master->rq_repmsg, 0, sizeof (*body)); LASSERT(body2 != NULL); - if (!(body->valid & (OBD_MD_FLID | OBD_MD_FLGENER))) + if (!(body->valid & (OBD_MD_FLID | OBD_MD_FLGENER))) { RETURN(0); + } memcpy(body2, body, sizeof(*body)); body2->valid &= ~OBD_MD_FLCOOKIE; @@ -1782,10 +1619,11 @@ static int mds_copy_unlink_reply(struct ptlrpc_request *master, RETURN(0); } -static int mds_reint_unlink_remote(struct mds_update_record *rec, - int offset, struct ptlrpc_request *req, +static int mds_reint_unlink_remote(struct mds_update_record *rec, int offset, + struct ptlrpc_request *req, struct lustre_handle *parent_lockh, - int update_mode, struct dentry *dparent, + int update_mode, + struct dentry *dparent, struct lustre_handle *child_lockh, struct dentry *dchild) { @@ -1799,27 +1637,21 @@ static int mds_reint_unlink_remote(struct mds_update_record *rec, LASSERT(offset == 1 || offset == 3); - DEBUG_REQ(D_INODE, req, "unlink %*s (remote inode %u/%u/%u/%u)", - rec->ur_namelen - 1, rec->ur_name, - (unsigned)dchild->d_mdsnum, - (unsigned)dchild->d_fid, - (unsigned)dchild->d_inum, - (unsigned)dchild->d_generation); - + DEBUG_REQ(D_INODE, req, "unlink %*s (remote inode %u/%u/%u)", + rec->ur_namelen - 1, rec->ur_name, (unsigned)dchild->d_mdsnum, + (unsigned) dchild->d_inum, (unsigned) dchild->d_generation); if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) - DEBUG_REQ(D_HA, req, "unlink %*s (remote inode %u/%u/%u/%u)", + DEBUG_REQ(D_HA, req, "unlink %*s (remote inode %u/%u/%u)", rec->ur_namelen - 1, rec->ur_name, (unsigned)dchild->d_mdsnum, - (unsigned)dchild->d_fid, - (unsigned)dchild->d_inum, - (unsigned)dchild->d_generation); + (unsigned) dchild->d_inum, + (unsigned) dchild->d_generation); /* time to drop i_nlink on remote MDS */ memset(&op_data, 0, sizeof(op_data)); - id_ino(&op_data.id1) = dchild->d_inum; - id_fid(&op_data.id1) = dchild->d_fid; - id_group(&op_data.id1) = dchild->d_mdsnum; - id_gen(&op_data.id1) = dchild->d_generation; + op_data.fid1.mds = dchild->d_mdsnum; + op_data.fid1.id = dchild->d_inum; + op_data.fid1.generation = dchild->d_generation; op_data.create_mode = rec->ur_mode; if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) op_data.create_mode |= MDS_MODE_REPLAY; @@ -1871,20 +1703,19 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset, #if 0 struct lustre_handle child_reuse_lockh = {0}; #endif - struct lustre_handle *slave_lockh = NULL; - char idname[LL_ID_NAMELEN]; + struct lustre_handle * slave_lockh = NULL; struct llog_create_locks *lcl = NULL; + char fidname[LL_FID_NAMELEN]; void *handle = NULL; int rc = 0, cleanup_phase = 0; - int unlink_by_id = 0; + int unlink_by_fid = 0; int update_mode; ENTRY; LASSERT(offset == 1 || offset == 3); DEBUG_REQ(D_INODE, req, "parent ino "LPU64"/%u, child %s", - id_ino(rec->ur_id1), id_gen(rec->ur_id1), - rec->ur_name); + rec->ur_fid1->id, rec->ur_fid1->generation, rec->ur_name); MDS_CHECK_RESENT(req, mds_reconstruct_generic(req)); @@ -1903,29 +1734,31 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset, if (rec->ur_namelen == 1) { /* this is request to drop i_nlink on local inode */ - unlink_by_id = 1; - rec->ur_name = idname; + unlink_by_fid = 1; + rec->ur_name = fidname; rc = mds_create_local_dentry(rec, obd); if (rc == -ENOENT || (rec->ur_mode & MDS_MODE_REPLAY)) { DEBUG_REQ(D_HA, req, - "drop nlink on inode "DLID4" (replay)", - OLID4(rec->ur_id1)); + "drop nlink on inode %u/%u/%u (replay)", + (unsigned) rec->ur_fid1->mds, + (unsigned) rec->ur_fid1->id, + (unsigned) rec->ur_fid1->generation); req->rq_status = 0; RETURN(0); } } if (rec->ur_mode & MDS_MODE_DONT_LOCK) { - /* master mds for directory asks slave removing inode is already - * locked */ - dparent = mds_id2locked_dentry(obd, rec->ur_id1, NULL, + /* master mds for directory asks slave removing + * inode is already locked */ + dparent = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, LCK_PW, parent_lockh, &update_mode, rec->ur_name, rec->ur_namelen, MDS_INODELOCK_UPDATE); if (IS_ERR(dparent)) GOTO(cleanup, rc = PTR_ERR(dparent)); - dchild = ll_lookup_one_len(rec->ur_name, dparent, + dchild = ll_lookup_one_len(rec->ur_name, dparent, rec->ur_namelen - 1); if (IS_ERR(dchild)) GOTO(cleanup, rc = PTR_ERR(dchild)); @@ -1934,7 +1767,7 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset, LASSERT(dchild->d_inode != NULL); LASSERT(S_ISDIR(dchild->d_inode->i_mode)); } else { - rc = mds_get_parent_child_locked(obd, mds, rec->ur_id1, + rc = mds_get_parent_child_locked(obd, mds, rec->ur_fid1, parent_lockh, &dparent, LCK_PW, MDS_INODELOCK_UPDATE, &update_mode, rec->ur_name, @@ -1948,7 +1781,7 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset, if (dchild->d_flags & DCACHE_CROSS_REF) { /* we should have parent lock only here */ - LASSERT(unlink_by_id == 0); + LASSERT(unlink_by_fid == 0); LASSERT(dchild->d_mdsnum != mds->mds_num); mds_reint_unlink_remote(rec, offset, req, parent_lockh, update_mode, dparent, &child_lockh, dchild); @@ -2020,9 +1853,10 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset, down(&mds->mds_pending_dir->d_inode->i_sem); cleanup_phase = 5; /* up(&pending_dir->i_sem) */ } else if (S_ISREG(child_inode->i_mode)) { - mds_pack_inode2body(obd, body, child_inode, 0); - mds_pack_md(obd, req->rq_repmsg, offset + 1, - body, child_inode, MDS_PACK_MD_LOCK); + mds_pack_inode2fid(obd, &body->fid1, child_inode); + mds_pack_inode2body(obd, body, child_inode); + mds_pack_md(obd, req->rq_repmsg, offset + 1, body, + child_inode, MDS_PACK_MD_LOCK); } } @@ -2110,7 +1944,7 @@ cleanup: rc = mds_finish_transno(mds, dparent ? dparent->d_inode : NULL, handle, req, rc, 0); if (!rc) - (void)obd_set_info(mds->mds_lov_exp, strlen("unlinked"), + (void)obd_set_info(mds->mds_osc_exp, strlen("unlinked"), "unlinked", 0, NULL); switch(cleanup_phase) { case 5: /* pending_dir semaphore */ @@ -2165,8 +1999,8 @@ cleanup: * to service requests from remote MDS to increment i_nlink */ static int mds_reint_link_acquire(struct mds_update_record *rec, - int offset, struct ptlrpc_request *req, - struct lustre_handle *lh) + int offset, struct ptlrpc_request *req, + struct lustre_handle *lh) { struct obd_device *obd = req->rq_export->exp_obd; struct ldlm_res_id src_res_id = { .name = {0} }; @@ -2178,24 +2012,26 @@ static int mds_reint_link_acquire(struct mds_update_record *rec, int flags = 0; ENTRY; - DEBUG_REQ(D_INODE, req, "%s: request to acquire i_nlinks "DLID4"\n", - obd->obd_name, OLID4(rec->ur_id1)); + DEBUG_REQ(D_INODE, req, "%s: request to acquire i_nlinks %u/%u/%u\n", + obd->obd_name, (unsigned) rec->ur_fid1->mds, + (unsigned) rec->ur_fid1->id, + (unsigned) rec->ur_fid1->generation); - /* Step 1: Lookup the source inode and target directory by ID */ - de_src = mds_id2dentry(obd, rec->ur_id1, NULL); + /* Step 1: Lookup the source inode and target directory by FID */ + de_src = mds_fid2dentry(mds, rec->ur_fid1, NULL); if (IS_ERR(de_src)) GOTO(cleanup, rc = PTR_ERR(de_src)); cleanup_phase = 1; /* source dentry */ - src_res_id.name[0] = id_fid(rec->ur_id1); - src_res_id.name[1] = id_group(rec->ur_id1); + src_res_id.name[0] = de_src->d_inode->i_ino; + src_res_id.name[1] = de_src->d_inode->i_generation; policy.l_inodebits.bits = MDS_INODELOCK_UPDATE; rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, - src_res_id, LDLM_IBITS, &policy, - LCK_EX, &flags, mds_blocking_ast, - ldlm_completion_ast, NULL, NULL, - NULL, 0, NULL, &src_lockh); + src_res_id, LDLM_IBITS, &policy, + LCK_EX, &flags, mds_blocking_ast, + ldlm_completion_ast, NULL, NULL, + NULL, 0, NULL, &src_lockh); if (rc != ELDLM_OK) GOTO(cleanup, rc = -ENOLCK); cleanup_phase = 2; /* lock */ @@ -2251,20 +2087,25 @@ static int mds_reint_link_to_remote(struct mds_update_record *rec, int update_mode; ENTRY; - DEBUG_REQ(D_INODE, req, "%s: request to link "DLID4 - ":%*s to foreign inode "DLID4"\n", obd->obd_name, - OLID4(rec->ur_id2), rec->ur_namelen - 1, rec->ur_name, - OLID4(rec->ur_id1)); - - de_tgt_dir = mds_id2locked_dentry(obd, rec->ur_id2, NULL, LCK_EX, - tgt_dir_lockh, &update_mode, - rec->ur_name, rec->ur_namelen - 1, - MDS_INODELOCK_UPDATE); +#define fmt "%s: request to link %u/%u/%u:%*s to foreign inode %u/%u/%u\n" + DEBUG_REQ(D_INODE, req, fmt, obd->obd_name, + (unsigned) rec->ur_fid2->mds, + (unsigned) rec->ur_fid2->id, + (unsigned) rec->ur_fid2->generation, + rec->ur_namelen - 1, rec->ur_name, + (unsigned) rec->ur_fid1->mds, + (unsigned) rec->ur_fid1->id, + (unsigned)rec->ur_fid1->generation); + + de_tgt_dir = mds_fid2locked_dentry(obd, rec->ur_fid2, NULL, LCK_EX, + tgt_dir_lockh, &update_mode, + rec->ur_name, rec->ur_namelen - 1, + MDS_INODELOCK_UPDATE); if (IS_ERR(de_tgt_dir)) GOTO(cleanup, rc = PTR_ERR(de_tgt_dir)); cleanup_phase = 1; - op_data.id1 = *(rec->ur_id1); + op_data.fid1 = *(rec->ur_fid1); op_data.namelen = 0; op_data.name = NULL; rc = md_link(mds->mds_lmv_exp, &op_data, &request); @@ -2284,9 +2125,8 @@ static int mds_reint_link_to_remote(struct mds_update_record *rec, } rc = fsfilt_add_dir_entry(obd, de_tgt_dir, rec->ur_name, - rec->ur_namelen - 1, id_ino(rec->ur_id1), - id_gen(rec->ur_id1), id_group(rec->ur_id1), - id_fid(rec->ur_id1)); + rec->ur_namelen - 1, rec->ur_fid1->id, + rec->ur_fid1->generation, rec->ur_fid1->mds); cleanup_phase = 3; cleanup: @@ -2348,18 +2188,18 @@ static int mds_reint_link(struct mds_update_record *rec, int offset, LASSERT(offset == 1); DEBUG_REQ(D_INODE, req, "original "LPU64"/%u to "LPU64"/%u %s", - id_ino(rec->ur_id1), id_gen(rec->ur_id1), - id_ino(rec->ur_id2), id_gen(rec->ur_id2), - rec->ur_name); + rec->ur_fid1->id, rec->ur_fid1->generation, + rec->ur_fid2->id, rec->ur_fid2->generation, rec->ur_name); MDS_CHECK_RESENT(req, mds_reconstruct_generic(req)); + MDS_UPDATE_COUNTER(mds, MDS_LINK_COUNT); // memset(tgt_dir_lockh, 0, 2*sizeof(tgt_dir_lockh[0])); if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_LINK)) GOTO(cleanup, rc = -ENOENT); - if (id_group(rec->ur_id1) != mds->mds_num) { + if (rec->ur_fid1->mds != mds->mds_num) { rc = mds_reint_link_to_remote(rec, offset, req, lh); RETURN(rc); } @@ -2369,14 +2209,14 @@ static int mds_reint_link(struct mds_update_record *rec, int offset, RETURN(rc); } - /* Step 1: Lookup the source inode and target directory by ID */ - de_src = mds_id2dentry(obd, rec->ur_id1, NULL); + /* Step 1: Lookup the source inode and target directory by FID */ + de_src = mds_fid2dentry(mds, rec->ur_fid1, NULL); if (IS_ERR(de_src)) GOTO(cleanup, rc = PTR_ERR(de_src)); cleanup_phase = 1; /* source dentry */ - de_tgt_dir = mds_id2dentry(obd, rec->ur_id2, NULL); + de_tgt_dir = mds_fid2dentry(mds, rec->ur_fid2, NULL); if (IS_ERR(de_tgt_dir)) { rc = PTR_ERR(de_tgt_dir); de_tgt_dir = NULL; @@ -2386,15 +2226,14 @@ static int mds_reint_link(struct mds_update_record *rec, int offset, cleanup_phase = 2; /* target directory dentry */ CDEBUG(D_INODE, "linking %*s/%s to inode %lu\n", - de_tgt_dir->d_name.len, de_tgt_dir->d_name.name, - rec->ur_name, de_src->d_inode->i_ino); + de_tgt_dir->d_name.len, de_tgt_dir->d_name.name, rec->ur_name, + de_src->d_inode->i_ino); /* Step 2: Take the two locks */ - src_res_id.name[0] = id_fid(rec->ur_id1); - src_res_id.name[1] = id_group(rec->ur_id1); - tgt_dir_res_id.name[0] = id_fid(rec->ur_id2); - tgt_dir_res_id.name[1] = id_group(rec->ur_id2); - + src_res_id.name[0] = de_src->d_inode->i_ino; + src_res_id.name[1] = de_src->d_inode->i_generation; + tgt_dir_res_id.name[0] = de_tgt_dir->d_inode->i_ino; + tgt_dir_res_id.name[1] = de_tgt_dir->d_inode->i_generation; #ifdef S_PDIROPS if (IS_PDIROPS(de_tgt_dir->d_inode)) { int flags = 0; @@ -2412,23 +2251,23 @@ static int mds_reint_link(struct mds_update_record *rec, int offset, tgt_dir_res_id.name[2] = full_name_hash(rec->ur_name, rec->ur_namelen - 1); - CDEBUG(D_INFO, "take lock on %lu:%lu:"LPX64"\n", - (unsigned long)id_fid(rec->ur_id2), - (unsigned long)id_group(rec->ur_id2), + CDEBUG(D_INFO, "take lock on %lu:%u:"LPX64"\n", + de_tgt_dir->d_inode->i_ino, + de_tgt_dir->d_inode->i_generation, tgt_dir_res_id.name[2]); } #endif rc = enqueue_ordered_locks(obd, &src_res_id, &src_lockh, LCK_EX, - &src_policy, &tgt_dir_res_id, tgt_dir_lockh, - LCK_EX, &tgt_dir_policy); + &src_policy, + &tgt_dir_res_id, tgt_dir_lockh, LCK_EX, + &tgt_dir_policy); if (rc) GOTO(cleanup, rc); cleanup_phase = 3; /* locks */ /* Step 3: Lookup the child */ - dchild = ll_lookup_one_len(rec->ur_name, de_tgt_dir, - rec->ur_namelen - 1); + dchild = ll_lookup_one_len(rec->ur_name, de_tgt_dir, rec->ur_namelen-1); if (IS_ERR(dchild)) { rc = PTR_ERR(dchild); if (rc != -EPERM && rc != -EACCES) @@ -2516,9 +2355,9 @@ cleanup: */ static int mds_get_parents_children_locked(struct obd_device *obd, struct mds_obd *mds, - struct lustre_id *p1_id, + struct ll_fid *p1_fid, struct dentry **de_srcdirp, - struct lustre_id *p2_id, + struct ll_fid *p2_fid, struct dentry **de_tgtdirp, int parent_mode, const char *old_name, int old_len, @@ -2542,28 +2381,24 @@ static int mds_get_parents_children_locked(struct obd_device *obd, MDS_INODELOCK_UPDATE}}; struct ldlm_res_id *maxres_src, *maxres_tgt; struct inode *inode; - __u32 child1_gen = 0; - __u32 child2_gen = 0; - unsigned long child1_ino; - unsigned long child2_ino; int rc = 0, cleanup_phase = 0; ENTRY; /* Step 1: Lookup the source directory */ - *de_srcdirp = mds_id2dentry(obd, p1_id, NULL); + *de_srcdirp = mds_fid2dentry(mds, p1_fid, NULL); if (IS_ERR(*de_srcdirp)) GOTO(cleanup, rc = PTR_ERR(*de_srcdirp)); cleanup_phase = 1; /* source directory dentry */ - p1_res_id.name[0] = id_fid(p1_id); - p1_res_id.name[1] = id_group(p1_id); + p1_res_id.name[0] = (*de_srcdirp)->d_inode->i_ino; + p1_res_id.name[1] = (*de_srcdirp)->d_inode->i_generation; /* Step 2: Lookup the target directory */ - if (id_equal(p1_id, p2_id)) { + if (memcmp(p1_fid, p2_fid, sizeof(*p1_fid)) == 0) { *de_tgtdirp = dget(*de_srcdirp); } else { - *de_tgtdirp = mds_id2dentry(obd, p2_id, NULL); + *de_tgtdirp = mds_fid2dentry(mds, p2_fid, NULL); if (IS_ERR(*de_tgtdirp)) { rc = PTR_ERR(*de_tgtdirp); *de_tgtdirp = NULL; @@ -2573,26 +2408,22 @@ static int mds_get_parents_children_locked(struct obd_device *obd, cleanup_phase = 2; /* target directory dentry */ - p2_res_id.name[0] = id_fid(p2_id); - p2_res_id.name[1] = id_group(p2_id); + p2_res_id.name[0] = (*de_tgtdirp)->d_inode->i_ino; + p2_res_id.name[1] = (*de_tgtdirp)->d_inode->i_generation; #ifdef S_PDIROPS dlm_handles[5].cookie = 0; dlm_handles[6].cookie = 0; if (IS_PDIROPS((*de_srcdirp)->d_inode)) { - /* - * get a temp lock on just fid, group to flush client cache and - * to protect dirs from concurrent splitting. - */ - rc = enqueue_ordered_locks(obd, &p1_res_id, &dlm_handles[5], + /* Get a temp lock on just ino, gen to flush client cache and + * to protect dirs from concurrent splitting */ + rc = enqueue_ordered_locks(obd, &p1_res_id, &(dlm_handles[5]), LCK_PW, &p_policy, &p2_res_id, - &dlm_handles[6], LCK_PW, &p_policy); + &(dlm_handles[6]),LCK_PW,&p_policy); if (rc != ELDLM_OK) GOTO(cleanup, rc); - p1_res_id.name[2] = full_name_hash(old_name, old_len - 1); p2_res_id.name[2] = full_name_hash(new_name, new_len - 1); - CDEBUG(D_INFO, "take locks on %lu:%u:"LPX64", %lu:%u:"LPX64"\n", (*de_srcdirp)->d_inode->i_ino, (*de_srcdirp)->d_inode->i_generation, p1_res_id.name[2], @@ -2603,8 +2434,7 @@ static int mds_get_parents_children_locked(struct obd_device *obd, #endif /* Step 3: Lookup the source child entry */ - *de_oldp = ll_lookup_one_len(old_name, *de_srcdirp, - old_len - 1); + *de_oldp = ll_lookup_one_len(old_name, *de_srcdirp, old_len - 1); if (IS_ERR(*de_oldp)) { rc = PTR_ERR(*de_oldp); CERROR("old child lookup error (%*s): %d\n", @@ -2617,39 +2447,20 @@ static int mds_get_parents_children_locked(struct obd_device *obd, inode = (*de_oldp)->d_inode; if (inode != NULL) { - struct lustre_id sid; - inode = igrab(inode); if (inode == NULL) GOTO(cleanup, rc = -ENOENT); - down(&inode->i_sem); - rc = mds_read_inode_sid(obd, inode, &sid); - up(&inode->i_sem); - if (rc) { - CERROR("Can't read inode self id, inode %lu, " - "rc %d\n", inode->i_ino, rc); - GOTO(cleanup, rc); - } - - c1_res_id.name[0] = id_fid(&sid); - c1_res_id.name[1] = id_group(&sid); - child1_gen = inode->i_generation; - child1_ino = inode->i_ino; + c1_res_id.name[0] = inode->i_ino; + c1_res_id.name[1] = inode->i_generation; iput(inode); } else if ((*de_oldp)->d_flags & DCACHE_CROSS_REF) { - c1_res_id.name[0] = (*de_oldp)->d_fid; - c1_res_id.name[1] = (*de_oldp)->d_mdsnum; - child1_gen = (*de_oldp)->d_generation; - child1_ino = (*de_oldp)->d_inum; - } else { - /* src entry is not found. */ - GOTO(cleanup, rc = -ENOENT); + c1_res_id.name[0] = (*de_oldp)->d_inum; + c1_res_id.name[1] = (*de_oldp)->d_generation; } /* Step 4: Lookup the target child entry */ - *de_newp = ll_lookup_one_len(new_name, *de_tgtdirp, - new_len - 1); + *de_newp = ll_lookup_one_len(new_name, *de_tgtdirp, new_len - 1); if (IS_ERR(*de_newp)) { rc = PTR_ERR(*de_newp); CERROR("new child lookup error (%*s): %d\n", @@ -2665,31 +2476,16 @@ static int mds_get_parents_children_locked(struct obd_device *obd, goto retry_locks; if (inode != NULL) { - struct lustre_id sid; - inode = igrab(inode); if (inode == NULL) goto retry_locks; - down(&inode->i_sem); - rc = mds_read_inode_sid(obd, inode, &sid); - up(&inode->i_sem); - if (rc) { - CERROR("Can't read inode self id, inode %lu, " - "rc %d\n", inode->i_ino, rc); - GOTO(cleanup, rc); - } - - c2_res_id.name[0] = id_fid(&sid); - c2_res_id.name[1] = id_group(&sid); - child2_gen = inode->i_generation; - child2_ino = inode->i_ino; + c2_res_id.name[0] = inode->i_ino; + c2_res_id.name[1] = inode->i_generation; iput(inode); } else if ((*de_newp)->d_flags & DCACHE_CROSS_REF) { - c2_res_id.name[0] = (*de_newp)->d_fid; - c2_res_id.name[1] = (*de_newp)->d_mdsnum; - child2_gen = (*de_newp)->d_generation; - child2_ino = (*de_newp)->d_inum; + c2_res_id.name[0] = (*de_newp)->d_inum; + c2_res_id.name[1] = (*de_newp)->d_generation; } retry_locks: @@ -2698,12 +2494,12 @@ retry_locks: maxres_tgt = &p2_res_id; cleanup_phase = 5; /* target dentry */ - if (c1_res_id.name[0] != 0 && res_gt(&c1_res_id, &p1_res_id, NULL, NULL)) + if (c1_res_id.name[0] != 0 && res_gt(&c1_res_id, &p1_res_id, NULL,NULL)) maxres_src = &c1_res_id; - if (c2_res_id.name[0] != 0 && res_gt(&c2_res_id, &p2_res_id, NULL, NULL)) + if (c2_res_id.name[0] != 0 && res_gt(&c2_res_id, &p2_res_id, NULL,NULL)) maxres_tgt = &c2_res_id; - rc = enqueue_4ordered_locks(obd, &p1_res_id, &dlm_handles[0], parent_mode, + rc = enqueue_4ordered_locks(obd, &p1_res_id,&dlm_handles[0],parent_mode, &p_policy, &p2_res_id, &dlm_handles[1], parent_mode, &p_policy, @@ -2720,7 +2516,7 @@ retry_locks: rc = mds_verify_child(obd, &p1_res_id, &dlm_handles[0], *de_srcdirp, parent_mode, &c1_res_id, &dlm_handles[2], de_oldp, child_mode, &c1_policy, old_name,old_len, - maxres_tgt, child1_ino, child1_gen); + maxres_tgt); if (rc) { if (c2_res_id.name[0] != 0) ldlm_lock_decref(&dlm_handles[3], child_mode); @@ -2738,7 +2534,7 @@ retry_locks: rc = mds_verify_child(obd, &p2_res_id, &dlm_handles[1], *de_tgtdirp, parent_mode, &c2_res_id, &dlm_handles[3], de_newp, child_mode, &c2_policy, new_name, - new_len, maxres_src, child2_ino, child2_gen); + new_len, maxres_src); if (rc) { ldlm_lock_decref(&dlm_handles[2], child_mode); ldlm_lock_decref(&dlm_handles[0], parent_mode); @@ -2757,10 +2553,8 @@ cleanup: ldlm_lock_decref(&dlm_handles[3], child_mode); if (c1_res_id.name[0] != 0) ldlm_lock_decref(&dlm_handles[2], child_mode); - if (dlm_handles[1].cookie != 0) - ldlm_lock_decref(&dlm_handles[1], parent_mode); - if (dlm_handles[0].cookie != 0) - ldlm_lock_decref(&dlm_handles[0], parent_mode); + ldlm_lock_decref(&dlm_handles[1], parent_mode); + ldlm_lock_decref(&dlm_handles[0], parent_mode); case 5: /* target dentry */ l_dput(*de_newp); case 4: /* source dentry */ @@ -2784,7 +2578,8 @@ cleanup: static int mds_add_local_dentry(struct mds_update_record *rec, int offset, struct ptlrpc_request *req, struct dentry *dentry, - struct dentry *de_dir, struct dentry *de) + struct dentry *de_dir, + struct dentry *de) { struct obd_device *obd = req->rq_export->exp_obd; struct mds_obd *mds = mds_req2mds(req); @@ -2798,7 +2593,8 @@ static int mds_add_local_dentry(struct mds_update_record *rec, int offset, * and create new one. */ CDEBUG(D_OTHER, "%s: %s points to local inode %lu/%lu\n", - obd->obd_name, rec->ur_tgt, (unsigned long)de->d_inode->i_ino, + obd->obd_name, rec->ur_tgt, + (unsigned long)de->d_inode->i_ino, (unsigned long)de->d_inode->i_generation); handle = fsfilt_start(obd, de_dir->d_inode, FSFILT_OP_RENAME, NULL); @@ -2811,7 +2607,8 @@ static int mds_add_local_dentry(struct mds_update_record *rec, int offset, /* name exists and points to remove inode */ CDEBUG(D_OTHER, "%s: %s points to remote inode %lu/%lu/%lu\n", obd->obd_name, rec->ur_tgt, (unsigned long)de->d_mdsnum, - (unsigned long)de->d_inum, (unsigned long)de->d_generation); + (unsigned long)de->d_inum, + (unsigned long)de->d_generation); handle = fsfilt_start(obd, de_dir->d_inode, FSFILT_OP_RENAME, NULL); if (IS_ERR(handle)) @@ -2826,21 +2623,20 @@ static int mds_add_local_dentry(struct mds_update_record *rec, int offset, if (IS_ERR(handle)) GOTO(cleanup, rc = PTR_ERR(handle)); } - + rc = fsfilt_add_dir_entry(obd, de_dir, rec->ur_tgt, rec->ur_tgtlen - 1, dentry->d_inum, - dentry->d_generation, dentry->d_mdsnum, - dentry->d_fid); + dentry->d_generation, dentry->d_mdsnum); if (rc) { CERROR("add_dir_entry() returned error %d\n", rc); GOTO(cleanup, rc); } - + cleanup: EXIT; rc = mds_finish_transno(mds, de_dir ? de_dir->d_inode : NULL, handle, req, rc, 0); - + RETURN(rc); } @@ -2854,13 +2650,13 @@ static int mds_del_local_dentry(struct mds_update_record *rec, int offset, void *handle = NULL; int rc = 0; ENTRY; - + handle = fsfilt_start(obd, de_dir->d_inode, FSFILT_OP_UNLINK, NULL); if (IS_ERR(handle)) GOTO(cleanup, rc = PTR_ERR(handle)); rc = fsfilt_del_dir_entry(obd, de); d_drop(de); - + cleanup: EXIT; rc = mds_finish_transno(mds, de_dir ? de_dir->d_inode : NULL, @@ -2868,31 +2664,34 @@ cleanup: RETURN(0); } + static int mds_reint_rename_create_name(struct mds_update_record *rec, int offset, struct ptlrpc_request *req) { - struct lustre_handle parent_lockh[2] = {{0}, {0}}; struct obd_device *obd = req->rq_export->exp_obd; - struct mds_obd *mds = mds_req2mds(req); - struct lustre_handle child_lockh = {0}; struct dentry *de_srcdir = NULL; struct dentry *de_new = NULL; + struct mds_obd *mds = mds_req2mds(req); + struct lustre_handle parent_lockh[2] = {{0}, {0}}; + struct lustre_handle child_lockh = {0}; int cleanup_phase = 0; void *handle = NULL; int update_mode, rc = 0; ENTRY; - /* - * another MDS executing rename operation has asked us to create target - * name. such a creation should destroy existing target name. - */ + /* another MDS executing rename operation has asked us + * to create target name. such a creation should destroy + * existing target name */ - CDEBUG(D_OTHER, "%s: request to create name %s for "DLID4"\n", - obd->obd_name, rec->ur_tgt, OLID4(rec->ur_id1)); + CDEBUG(D_OTHER, "%s: request to create name %s for %lu/%lu/%lu\n", + obd->obd_name, rec->ur_tgt, + (unsigned long) rec->ur_fid1->mds, + (unsigned long) rec->ur_fid1->id, + (unsigned long) rec->ur_fid1->generation); /* first, lookup the target */ child_lockh.cookie = 0; - rc = mds_get_parent_child_locked(obd, mds, rec->ur_id2, parent_lockh, + rc = mds_get_parent_child_locked(obd, mds, rec->ur_fid2, parent_lockh, &de_srcdir,LCK_PW,MDS_INODELOCK_UPDATE, &update_mode, rec->ur_tgt, rec->ur_tgtlen, &child_lockh, &de_new, LCK_EX, @@ -2907,14 +2706,12 @@ static int mds_reint_rename_create_name(struct mds_update_record *rec, LASSERT(de_new); if (de_new->d_inode) { - /* - * name exists and points to local inode try to unlink this name - * and create new one. - */ + /* name exists and points to local inode + * try to unlink this name and create new one */ CERROR("%s: %s points to local inode %lu/%lu\n", obd->obd_name, rec->ur_tgt, - (unsigned long)de_new->d_inode->i_ino, - (unsigned long)de_new->d_inode->i_generation); + (unsigned long) de_new->d_inode->i_ino, + (unsigned long) de_new->d_inode->i_generation); handle = fsfilt_start(obd, de_srcdir->d_inode, FSFILT_OP_RENAME, NULL); if (IS_ERR(handle)) @@ -2926,9 +2723,9 @@ static int mds_reint_rename_create_name(struct mds_update_record *rec, /* name exists adn points to remove inode */ CERROR("%s: %s points to remote inode %lu/%lu/%lu\n", obd->obd_name, rec->ur_tgt, - (unsigned long)de_new->d_mdsnum, - (unsigned long)de_new->d_inum, - (unsigned long)de_new->d_generation); + (unsigned long) de_new->d_mdsnum, + (unsigned long) de_new->d_inum, + (unsigned long) de_new->d_generation); } else { /* name doesn't exist. the simplest case */ handle = fsfilt_start(obd, de_srcdir->d_inode, @@ -2936,12 +2733,11 @@ static int mds_reint_rename_create_name(struct mds_update_record *rec, if (IS_ERR(handle)) GOTO(cleanup, rc = PTR_ERR(handle)); } - + cleanup_phase = 2; rc = fsfilt_add_dir_entry(obd, de_srcdir, rec->ur_tgt, - rec->ur_tgtlen - 1, id_ino(rec->ur_id1), - id_gen(rec->ur_id1), id_group(rec->ur_id1), - id_fid(rec->ur_id1)); + rec->ur_tgtlen - 1, rec->ur_fid1->id, + rec->ur_fid1->generation, rec->ur_fid1->mds); if (rc) CERROR("add_dir_entry() returned error %d\n", rc); cleanup: @@ -2966,6 +2762,7 @@ cleanup: } req->rq_status = rc; + RETURN(0); } @@ -2983,13 +2780,13 @@ static int mds_reint_rename_to_remote(struct mds_update_record *rec, int offset, int update_mode, rc = 0; ENTRY; - CDEBUG(D_OTHER, "%s: move name %s onto another mds #%lu\n", - obd->obd_name, rec->ur_name, (unsigned long)id_group(rec->ur_id2)); + CDEBUG(D_OTHER, "%s: move name %s onto another mds%u\n", + obd->obd_name, rec->ur_name, rec->ur_fid2->mds + 1); memset(&opdata, 0, sizeof(opdata)); child_lockh.cookie = 0; - rc = mds_get_parent_child_locked(obd, mds, rec->ur_id1, parent_lockh, - &de_srcdir, LCK_PW, MDS_INODELOCK_UPDATE, + rc = mds_get_parent_child_locked(obd, mds, rec->ur_fid1, parent_lockh, + &de_srcdir,LCK_PW,MDS_INODELOCK_UPDATE, &update_mode, rec->ur_name, rec->ur_namelen, &child_lockh, &de_old, LCK_EX, MDS_INODELOCK_LOOKUP); @@ -2998,53 +2795,38 @@ static int mds_reint_rename_to_remote(struct mds_update_record *rec, int offset, LASSERT(de_srcdir->d_inode); LASSERT(de_old); - /* - * we already know the target should be created on another MDS so, we - * have to request that MDS to do it. - */ + /* we already know the target should be created on another MDS + * so, we have to request that MDS to do it */ - /* prepare source id */ + /* prepare source fid */ if (de_old->d_flags & DCACHE_CROSS_REF) { LASSERT(de_old->d_inode == NULL); CDEBUG(D_OTHER, "request to move remote name\n"); - mds_pack_dentry2id(obd, &opdata.id1, de_old, 1); + opdata.fid1.mds = de_old->d_mdsnum; + opdata.fid1.id = de_old->d_inum; + opdata.fid1.generation = de_old->d_generation; } else if (de_old->d_inode == NULL) { /* oh, source doesn't exist */ GOTO(cleanup, rc = -ENOENT); } else { - struct lustre_id sid; - struct inode *inode = de_old->d_inode; - - LASSERT(inode != NULL); + LASSERT(de_old->d_inode != NULL); CDEBUG(D_OTHER, "request to move local name\n"); - id_group(&opdata.id1) = mds->mds_num; - id_ino(&opdata.id1) = inode->i_ino; - id_gen(&opdata.id1) = inode->i_generation; - - down(&inode->i_sem); - rc = mds_read_inode_sid(obd, inode, &sid); - up(&inode->i_sem); - if (rc) { - CERROR("Can't read inode self id, " - "inode %lu, rc = %d\n", - inode->i_ino, rc); - GOTO(cleanup, rc); - } - - id_fid(&opdata.id1) = id_fid(&sid); + opdata.fid1.mds = mds->mds_num; + opdata.fid1.id = de_old->d_inode->i_ino; + opdata.fid1.generation = de_old->d_inode->i_generation; } - opdata.id2 = *(rec->ur_id2); - rc = md_rename(mds->mds_lmv_exp, &opdata, NULL, 0, - rec->ur_tgt, rec->ur_tgtlen - 1, &req2); + opdata.fid2 = *(rec->ur_fid2); + rc = md_rename(mds->mds_lmv_exp, &opdata, NULL, 0, rec->ur_tgt, + rec->ur_tgtlen - 1, &req2); if (rc) GOTO(cleanup, rc); - rc = mds_del_local_dentry(rec, offset, req, NULL, - de_srcdir, de_old); + rc = mds_del_local_dentry(rec, offset, req, NULL, de_srcdir, de_old); cleanup: EXIT; + if (req2) ptlrpc_req_finished(req2); @@ -3061,6 +2843,7 @@ cleanup: req->rq_status = rc; RETURN(0); + } static int mds_reint_rename(struct mds_update_record *rec, int offset, @@ -3078,14 +2861,15 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, struct llog_create_locks *lcl = NULL; struct lov_mds_md *lmm = NULL; int rc = 0, cleanup_phase = 0; + void *handle = NULL; ENTRY; LASSERT(offset == 1); - DEBUG_REQ(D_INODE, req, "parent "DLID4" %s to "DLID4" %s", - OLID4(rec->ur_id1), rec->ur_name, OLID4(rec->ur_id2), - rec->ur_tgt); + DEBUG_REQ(D_INODE, req, "parent "LPU64"/%u %s to "LPU64"/%u %s", + rec->ur_fid1->id, rec->ur_fid1->generation, rec->ur_name, + rec->ur_fid2->id, rec->ur_fid2->generation, rec->ur_tgt); MDS_CHECK_RESENT(req, mds_reconstruct_generic(req)); @@ -3103,14 +2887,13 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, RETURN(rc); } - /* check if new name should be located on remote target. */ - if (id_group(rec->ur_id2) != mds->mds_num) { + if (rec->ur_fid2->mds != mds->mds_num) { rc = mds_reint_rename_to_remote(rec, offset, req); RETURN(rc); } - rc = mds_get_parents_children_locked(obd, mds, rec->ur_id1, &de_srcdir, - rec->ur_id2, &de_tgtdir, LCK_PW, + rc = mds_get_parents_children_locked(obd, mds, rec->ur_fid1, &de_srcdir, + rec->ur_fid2, &de_tgtdir, LCK_PW, rec->ur_name, rec->ur_namelen, &de_old, rec->ur_tgt, rec->ur_tgtlen, &de_new, @@ -3154,7 +2937,7 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, de_new->d_inum == de_tgtdir->d_inode->i_ino) GOTO(cleanup, rc = -EINVAL); } - + /* * regular files usualy do not have ->rename() implemented. But * we handle only this case when @de_new is cross-ref entry, @@ -3176,10 +2959,8 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, old_inode == new_inode) GOTO(cleanup, rc = 0); - /* - * if we are about to remove the target at first, pass the EA of that - * inode to client to perform and cleanup on OST. - */ + /* if we are about to remove the target at first, pass the EA of + * that inode to client to perform and cleanup on OST */ body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); LASSERT(body != NULL); @@ -3196,9 +2977,10 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, down(&mds->mds_pending_dir->d_inode->i_sem); cleanup_phase = 3; /* up(&pending_dir->i_sem) */ } else if (S_ISREG(new_inode->i_mode)) { - mds_pack_inode2body(obd, body, new_inode, 0); - mds_pack_md(obd, req->rq_repmsg, 1, body, - new_inode, MDS_PACK_MD_LOCK); + mds_pack_inode2fid(obd, &body->fid1, new_inode); + mds_pack_inode2body(obd, body, new_inode); + mds_pack_md(obd, req->rq_repmsg, 1, body, new_inode, + MDS_PACK_MD_LOCK); } } @@ -3260,10 +3042,8 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, GOTO(cleanup, rc); cleanup: - EXIT; - rc = mds_finish_transno(mds, (de_tgtdir ? de_tgtdir->d_inode : NULL), + rc = mds_finish_transno(mds, de_tgtdir ? de_tgtdir->d_inode : NULL, handle, req, rc, 0); - switch (cleanup_phase) { case 3: up(&mds->mds_pending_dir->d_inode->i_sem); diff --git a/lustre/mds/mds_unlink_open.c b/lustre/mds/mds_unlink_open.c index b52f1e5..20191c6 100644 --- a/lustre/mds/mds_unlink_open.c +++ b/lustre/mds/mds_unlink_open.c @@ -56,7 +56,7 @@ static int mds_osc_destroy_orphan(struct mds_obd *mds, if (lmm_size == 0) RETURN(0); - rc = obd_unpackmd(mds->mds_lov_exp, &lsm, lmm, lmm_size); + rc = obd_unpackmd(mds->mds_osc_exp, &lsm, lmm, lmm_size); if (rc < 0) { CERROR("Error unpack md %p\n", lmm); RETURN(rc); @@ -78,13 +78,13 @@ static int mds_osc_destroy_orphan(struct mds_obd *mds, oti.oti_logcookies = logcookies; } - rc = obd_destroy(mds->mds_lov_exp, oa, lsm, &oti); + rc = obd_destroy(mds->mds_osc_exp, oa, lsm, &oti); obdo_free(oa); if (rc) CDEBUG(D_INODE, "destroy orphan objid 0x"LPX64" on ost error " "%d\n", lsm->lsm_object_id, rc); out_free_memmd: - obd_free_memmd(mds->mds_lov_exp, &lsm); + obd_free_memmd(mds->mds_osc_exp, &lsm); RETURN(rc); } @@ -99,7 +99,7 @@ static int mds_unlink_orphan(struct obd_device *obd, struct dentry *dchild, int rc, err; ENTRY; - LASSERT(mds->mds_lov_obd != NULL); + LASSERT(mds->mds_osc_obd != NULL); OBD_ALLOC(lmm, mds->mds_max_mdsize); if (lmm == NULL) @@ -175,7 +175,7 @@ int mds_cleanup_orphans(struct obd_device *obd) struct inode *child_inode, *pending_dir = mds->mds_pending_dir->d_inode; struct l_linux_dirent *dirent, *n; struct list_head dentry_list; - char d_name[LL_ID_NAMELEN]; + char d_name[LL_FID_NAMELEN]; __u64 i = 0; int rc = 0, item = 0, namlen; ENTRY; diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 3706464..e464b58 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -484,7 +484,6 @@ struct obd_export *class_new_export(struct obd_device *obd) atomic_set(&export->exp_refcount, 2); atomic_set(&export->exp_rpc_count, 0); export->exp_obd = obd; - export->exp_flags = 0; INIT_LIST_HEAD(&export->exp_outstanding_replies); /* XXX this should be in LDLM init */ INIT_LIST_HEAD(&export->exp_ldlm_data.led_held_locks); @@ -657,7 +656,7 @@ int class_disconnect(struct obd_export *export, int flags) CDEBUG(D_IOCTL, "disconnect: cookie "LPX64"\n", export->exp_handle.h_cookie); - if (export->exp_handle.h_cookie == LL_POISON) { + if (export->exp_handle.h_cookie == 0x5a5a5a5a5a5a5a5a) { CERROR("disconnecting freed export %p, ignoring\n", export); } else { class_unlink_export(export); @@ -668,9 +667,9 @@ int class_disconnect(struct obd_export *export, int flags) static void class_disconnect_export_list(struct list_head *list, int flags) { - struct obd_export *fake_exp, *exp; - struct lustre_handle fake_conn; int rc; + struct lustre_handle fake_conn; + struct obd_export *fake_exp, *exp; ENTRY; /* Move all of the exports from obd_exports to a work list, en masse. */ @@ -685,10 +684,8 @@ static void class_disconnect_export_list(struct list_head *list, int flags) CDEBUG(D_HA, "exp %p export uuid == obd uuid, don't discon\n", exp); - /* - * need to delete this now so we don't end up pointing - * to work_list later when this export is cleaned up. - */ + /* Need to delete this now so we don't end up pointing + * to work_list later when this export is cleaned up. */ list_del_init(&exp->exp_obd_chain); class_export_put(exp); continue; @@ -700,7 +697,6 @@ static void class_disconnect_export_list(struct list_head *list, int flags) class_export_put(exp); continue; } - rc = obd_disconnect(fake_exp, flags); class_export_put(exp); if (rc) { diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 8c2e1b1..d685687 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -45,6 +45,7 @@ #include #if defined(LPROCFS) && defined(__KERNEL__) + struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head, const char *name) { @@ -64,6 +65,7 @@ struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head, } /* lprocfs API calls */ + int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list, void *data) { @@ -659,13 +661,13 @@ int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats) LPROCFS_OBD_OP_INIT(num_private_stats, stats, unpin); LPROCFS_OBD_OP_INIT(num_private_stats, stats, import_event); LPROCFS_OBD_OP_INIT(num_private_stats, stats, notify); - LPROCFS_OBD_OP_INIT(num_private_stats, stats, getready); LPROCFS_OBD_OP_INIT(num_private_stats, stats, init_ea_size); for (i = num_private_stats; i < num_stats; i++) { - /* if this LBUGs, it is likely that an obd operation was added - * to struct obd_ops in , and that the - * corresponding line item LPROCFS_OBD_OP_INIT(.., .., opname) + /* If this LBUGs, it is likely that an obd + * operation was added to struct obd_ops in + * , and that the corresponding line item + * LPROCFS_OBD_OP_INIT(.., .., opname) * is missing from the list above. */ if (stats->ls_percpu[0]->lp_cntr[i].lc_name == NULL) { CERROR("Missing obd_stat initializer obd_op " diff --git a/lustre/obdclass/mea.c b/lustre/obdclass/mea.c index 8dffec3..ec276fe8 100644 --- a/lustre/obdclass/mea.c +++ b/lustre/obdclass/mea.c @@ -93,3 +93,4 @@ int mea_name2idx(struct mea *mea, char *name, int namelen) return c; } + diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index b61a28e..325c2c1 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -433,9 +433,8 @@ struct lustre_profile *class_get_profile(char * prof) RETURN(NULL); } -int class_add_profile(int proflen, char *prof, - int lovlen, char *lov, - int lmvlen, char *lmv) +int class_add_profile(int proflen, char *prof, int osclen, char *osc, + int mdclen, char *mdc) { struct lustre_profile *lprof; int err = 0; @@ -451,18 +450,18 @@ int class_add_profile(int proflen, char *prof, GOTO(out, err = -ENOMEM); memcpy(lprof->lp_profile, prof, proflen); - LASSERT(lovlen == (strlen(lov) + 1)); - OBD_ALLOC(lprof->lp_lov, lovlen); + LASSERT(osclen == (strlen(osc) + 1)); + OBD_ALLOC(lprof->lp_osc, osclen); if (lprof->lp_profile == NULL) GOTO(out, err = -ENOMEM); - memcpy(lprof->lp_lov, lov, lovlen); + memcpy(lprof->lp_osc, osc, osclen); - if (lmvlen > 0) { - LASSERT(lmvlen == (strlen(lmv) + 1)); - OBD_ALLOC(lprof->lp_lmv, lmvlen); - if (lprof->lp_lmv == NULL) + if (mdclen > 0) { + LASSERT(mdclen == (strlen(mdc) + 1)); + OBD_ALLOC(lprof->lp_mdc, mdclen); + if (lprof->lp_mdc == NULL) GOTO(out, err = -ENOMEM); - memcpy(lprof->lp_lmv, lmv, lmvlen); + memcpy(lprof->lp_mdc, mdc, mdclen); } list_add(&lprof->lp_list, &lustre_profile_list); @@ -479,9 +478,9 @@ void class_del_profile(char *prof) if (lprof) { list_del(&lprof->lp_list); OBD_FREE(lprof->lp_profile, strlen(lprof->lp_profile) + 1); - OBD_FREE(lprof->lp_lov, strlen(lprof->lp_lov) + 1); - if (lprof->lp_lmv) - OBD_FREE(lprof->lp_lmv, strlen(lprof->lp_lmv) + 1); + OBD_FREE(lprof->lp_osc, strlen(lprof->lp_osc) + 1); + if (lprof->lp_mdc) + OBD_FREE(lprof->lp_mdc, strlen(lprof->lp_mdc) + 1); OBD_FREE(lprof, sizeof *lprof); } } diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c index dbbdba1..e5e9ce8 100644 --- a/lustre/obdecho/echo.c +++ b/lustre/obdecho/echo.c @@ -69,6 +69,7 @@ static int echo_disconnect(struct obd_export *exp, int flags) unsigned long irqflags; LASSERT (exp != NULL); + ldlm_cancel_locks_for_export(exp); spin_lock_irqsave(&exp->exp_lock, irqflags); diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index b6446a9..ab194ce 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -650,7 +650,7 @@ static int filter_read_group_internal(struct obd_device *obd, int group, name[24] = '\0'; if (!create) { - dentry = ll_lookup_one_len(name, filter->fo_dentry_O, + dentry = ll_lookup_one_len(name, filter->fo_dentry_O, strlen(name)); if (IS_ERR(dentry)) { CERROR("Cannot lookup expected object group %d: %ld\n", @@ -1146,16 +1146,16 @@ struct dentry *filter_parent_lock(struct obd_device *obd, obd_gr group, return dparent; } -/* How to get files, dentries, inodes from object store cookie. +/* How to get files, dentries, inodes from object id's. * * If dir_dentry is passed, the caller has already locked the parent * appropriately for this operation (normally a write lock). If * dir_dentry is NULL, we do a read lock while we do the lookup to * avoid races with create/destroy and such changing the directory * internal to the filesystem code. */ -struct dentry *filter_id2dentry(struct obd_device *obd, - struct dentry *dir_dentry, - obd_gr group, obd_id id) +struct dentry *filter_fid2dentry(struct obd_device *obd, + struct dentry *dir_dentry, + obd_gr group, obd_id id) { struct dentry *dparent = dir_dentry; struct dentry *dchild; @@ -1728,7 +1728,7 @@ static int filter_connect(struct lustre_handle *conn, struct obd_device *obd, GOTO(cleanup, rc); } rc = filter_group_set_fs_flags(obd, group); - if (rc != 0) { + if (rc != 0) { CERROR("can't set kml flags %u\n", group); GOTO(cleanup, rc); } @@ -1963,10 +1963,11 @@ static int filter_disconnect(struct obd_export *exp, int flags) filter_grant_sanity_check(obd, __FUNCTION__); filter_grant_discard(exp); - /* disconnect early so that clients can't keep using export */ + /* Disconnect early so that clients can't keep using export */ rc = class_disconnect(exp, flags); ldlm_cancel_locks_for_export(exp); + fsfilt_sync(obd, obd->u.filter.fo_sb); /* flush any remaining cancel messages out to the target */ @@ -1985,7 +1986,7 @@ struct dentry *__filter_oa2dentry(struct obd_device *obd, if (oa->o_valid & OBD_MD_FLGROUP) group = oa->o_gr; - dchild = filter_id2dentry(obd, NULL, group, oa->o_id); + dchild = filter_fid2dentry(obd, NULL, group, oa->o_id); if (IS_ERR(dchild)) { CERROR("%s error looking up object: "LPU64"\n", what, oa->o_id); @@ -2314,7 +2315,8 @@ static int filter_precreate(struct obd_device *obd, struct obdo *oa, /*only do precreate rec record. so clean kml flags here*/ fsfilt_clear_fs_flags(obd, dparent->d_inode, SM_DO_REC); - dchild = filter_id2dentry(obd, dparent, group, next_id); + + dchild = filter_fid2dentry(obd, dparent, group, next_id); if (IS_ERR(dchild)) GOTO(cleanup, rc = PTR_ERR(dchild)); cleanup_phase = 2; @@ -2520,7 +2522,7 @@ static int filter_destroy(struct obd_export *exp, struct obdo *oa, GOTO(cleanup, rc = PTR_ERR(dparent)); cleanup_phase = 1; - dchild = filter_id2dentry(obd, dparent, oa->o_gr, oa->o_id); + dchild = filter_fid2dentry(obd, dparent, oa->o_gr, oa->o_id); if (IS_ERR(dchild)) GOTO(cleanup, rc = -ENOENT); cleanup_phase = 2; @@ -2956,14 +2958,14 @@ static int filter_llog_connect(struct obd_export *exp, RETURN(rc); } -static struct dentry *filter_lvfs_id2dentry(__u64 id, __u32 gen, - __u64 gr, void *data) +static struct dentry *filter_lvfs_fid2dentry(__u64 id, __u32 gen, __u64 gr, + void *data) { - return filter_id2dentry(data, NULL, gr, id); + return filter_fid2dentry(data, NULL, gr, id); } static struct lvfs_callback_ops filter_lvfs_ops = { - l_id2dentry: filter_lvfs_id2dentry, + l_fid2dentry: filter_lvfs_fid2dentry, }; static struct obd_ops filter_obd_ops = { diff --git a/lustre/obdfilter/filter_internal.h b/lustre/obdfilter/filter_internal.h index f6e0628..12ad087 100644 --- a/lustre/obdfilter/filter_internal.h +++ b/lustre/obdfilter/filter_internal.h @@ -92,8 +92,8 @@ enum { /* filter.c */ void f_dput(struct dentry *); -struct dentry *filter_id2dentry(struct obd_device *, struct dentry *dir, - obd_gr group, obd_id id); +struct dentry *filter_fid2dentry(struct obd_device *, struct dentry *dir, + obd_gr group, obd_id id); struct dentry *__filter_oa2dentry(struct obd_device *obd, struct obdo *oa, const char *what); #define filter_oa2dentry(obd, oa) __filter_oa2dentry(obd, oa, __FUNCTION__) @@ -154,9 +154,9 @@ int filter_direct_io(int rw, struct dentry *dchild, void *iobuf, struct ost_filterdata { __u32 ofd_epoch; }; - int filter_log_sz_change(struct llog_handle *cathandle, - struct lustre_id *id, __u32 io_epoch, + struct ll_fid *mds_fid, + __u32 io_epoch, struct llog_cookie *logcookie, struct inode *inode); //int filter_get_catalog(struct obd_device *); diff --git a/lustre/obdfilter/filter_io.c b/lustre/obdfilter/filter_io.c index 6c32ebb..8b09fc7 100644 --- a/lustre/obdfilter/filter_io.c +++ b/lustre/obdfilter/filter_io.c @@ -527,8 +527,8 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa, cleanup_phase = 1; push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL); - dentry = filter_id2dentry(exp->exp_obd, NULL, obj->ioo_gr, - obj->ioo_id); + dentry = filter_fid2dentry(exp->exp_obd, NULL, obj->ioo_gr, + obj->ioo_id); if (IS_ERR(dentry)) GOTO(cleanup, rc = PTR_ERR(dentry)); @@ -782,8 +782,8 @@ int filter_do_cow(struct obd_export *exp, struct obd_ioobj *obj, push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL); - dentry = filter_id2dentry(exp->exp_obd, NULL, obj->ioo_gr, - obj->ioo_id); + dentry = filter_fid2dentry(exp->exp_obd, NULL, obj->ioo_gr, + obj->ioo_id); if (IS_ERR(dentry)) { pop_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL); RETURN (PTR_ERR(dentry)); @@ -842,8 +842,9 @@ int filter_write_extents(struct obd_export *exp, struct obd_ioobj *obj, int nobj LASSERT(nobj == 1); push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL); - dentry = filter_id2dentry(exp->exp_obd, NULL, obj->ioo_gr, - obj->ioo_id); + + dentry = filter_fid2dentry(exp->exp_obd, NULL, obj->ioo_gr, + obj->ioo_id); if (IS_ERR(dentry)) { pop_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL); RETURN (PTR_ERR(dentry)); diff --git a/lustre/obdfilter/filter_log.c b/lustre/obdfilter/filter_log.c index c271382..386da62 100644 --- a/lustre/obdfilter/filter_log.c +++ b/lustre/obdfilter/filter_log.c @@ -38,7 +38,8 @@ #include "filter_internal.h" int filter_log_sz_change(struct llog_handle *cathandle, - struct lustre_id *id, __u32 io_epoch, + struct ll_fid *mds_fid, + __u32 io_epoch, struct llog_cookie *logcookie, struct inode *inode) { @@ -76,7 +77,7 @@ int filter_log_sz_change(struct llog_handle *cathandle, RETURN(-ENOMEM); lsc->lsc_hdr.lrh_len = lsc->lsc_tail.lrt_len = sizeof(*lsc); lsc->lsc_hdr.lrh_type = OST_SZ_REC; - lsc->lsc_id = *id; + lsc->lsc_fid = *mds_fid; lsc->lsc_io_epoch = io_epoch; rc = llog_cat_add_rec(cathandle, &lsc->lsc_hdr, logcookie, diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index b23327d..fbd698f 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -48,7 +48,7 @@ # include #endif -#include +# include #include #include #include @@ -2797,7 +2797,7 @@ static int osc_get_info(struct obd_export *exp, obd_count keylen, ptlrpc_req_finished(req); RETURN(rc); } - RETURN(-EPROTO); + RETURN(-EINVAL); } static int osc_set_info(struct obd_export *exp, obd_count keylen, @@ -2926,9 +2926,10 @@ static int osc_connect(struct lustre_handle *exph, unsigned long connect_flags) { int rc; - ENTRY; + rc = client_connect_import(exph, obd, cluuid, connect_flags); - RETURN(rc); + + return rc; } static int osc_disconnect(struct obd_export *exp, int flags) @@ -2936,7 +2937,6 @@ static int osc_disconnect(struct obd_export *exp, int flags) struct obd_device *obd = class_exp2obd(exp); struct llog_ctxt *ctxt; int rc; - ENTRY; ctxt = llog_get_context(&obd->obd_llogs, LLOG_SIZE_REPL_CTXT); if (obd->u.cli.cl_conn_count == 1) @@ -2944,7 +2944,7 @@ static int osc_disconnect(struct obd_export *exp, int flags) llog_sync(ctxt, exp); rc = client_disconnect_export(exp, flags); - RETURN(rc); + return rc; } static int osc_import_event(struct obd_device *obd, diff --git a/lustre/portals/include/linux/kp30.h b/lustre/portals/include/linux/kp30.h index de642bd..db63a08 100644 --- a/lustre/portals/include/linux/kp30.h +++ b/lustre/portals/include/linux/kp30.h @@ -728,13 +728,4 @@ typedef int (*cfg_record_cb_t)(enum cfg_record_type, int len, void *data); # error "No word size defined" #endif -/* lustre_id output helper macros */ -#define DLID4 "%lu/%lu/%lu/%lu" - -#define OLID4(id) \ - (unsigned long)(id)->li_fid.lf_id, \ - (unsigned long)(id)->li_fid.lf_group, \ - (unsigned long)(id)->li_stc.u.e3s.l3s_ino, \ - (unsigned long)(id)->li_stc.u.e3s.l3s_gen - #endif diff --git a/lustre/portals/include/linux/libcfs.h b/lustre/portals/include/linux/libcfs.h index 17d5a11..d1a5c44 100644 --- a/lustre/portals/include/linux/libcfs.h +++ b/lustre/portals/include/linux/libcfs.h @@ -145,13 +145,6 @@ struct ptldebug_header { # endif #endif -#ifndef likely -# define likely(exp) (exp) -#endif -#ifndef unlikely -# define unlikely(exp) (exp) -#endif - #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5) #ifdef __KERNEL__ diff --git a/lustre/portals/knals/qswnal/qswnal.h b/lustre/portals/knals/qswnal/qswnal.h index d25d201..438edc6 100644 --- a/lustre/portals/knals/qswnal/qswnal.h +++ b/lustre/portals/knals/qswnal/qswnal.h @@ -79,7 +79,6 @@ #include #include #include -#include #define KQSW_CHECKSUM 0 #if KQSW_CHECKSUM diff --git a/lustre/portals/utils/portals.c b/lustre/portals/utils/portals.c index 0e109cb..1bde59f 100644 --- a/lustre/portals/utils/portals.c +++ b/lustre/portals/utils/portals.c @@ -37,8 +37,10 @@ #include #ifdef __CYGWIN__ + #include -#endif + +#endif /* __CYGWIN__ */ #include #include @@ -52,7 +54,12 @@ unsigned int portal_printk; static unsigned int g_nal = 0; -typedef struct { +static int g_socket_txmem = 0; +static int g_socket_rxmem = 0; +static int g_socket_nonagle = 1; + +typedef struct +{ char *name; int num; } name2num_t; diff --git a/lustre/ptlbd/client.c b/lustre/ptlbd/client.c index 6a1d759..633d64f 100644 --- a/lustre/ptlbd/client.c +++ b/lustre/ptlbd/client.c @@ -166,13 +166,13 @@ out_disco: /* modelled after ptlrpc_import_disconnect() */ -int ptlbd_cl_disconnect(struct obd_export *exp, int flags) +int ptlbd_cl_disconnect(struct obd_export *exp, int failover) { struct obd_device *obd = exp->exp_obd; struct ptlbd_obd *ptlbd = &obd->u.ptlbd; struct obd_import *imp = ptlbd->bd_import; struct ptlrpc_request *request; - int rc, err; + int rc, err; ENTRY; if (!obd) diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index d2ccb41..24806f1 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -394,7 +394,7 @@ out: } static int ptlrpc_connect_interpret(struct ptlrpc_request *request, - void *data, int rc) + void * data, int rc) { struct ptlrpc_connect_async_args *aa = data; struct obd_import *imp = request->rq_import; @@ -515,6 +515,7 @@ finish: IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON); if (aa->pcaa_initial_connect && !imp->imp_initial_recov) ptlrpc_deactivate_import(imp); + CDEBUG(D_HA, "recovery of %s on %s failed (%d)\n", imp->imp_target_uuid.uuid, (char *)imp->imp_connection->c_remote_uuid.uuid, rc); @@ -525,7 +526,7 @@ finish: } static int completed_replay_interpret(struct ptlrpc_request *req, - void *data, int rc) + void * data, int rc) { atomic_dec(&req->rq_import->imp_replay_inflight); if (req->rq_status == 0) { @@ -648,7 +649,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp) switch (imp->imp_connect_op) { case OST_CONNECT: rq_opc = OST_DISCONNECT; break; case MDS_CONNECT: rq_opc = MDS_DISCONNECT; break; - case MGMT_CONNECT: rq_opc = MGMT_DISCONNECT; break; + case MGMT_CONNECT:rq_opc = MGMT_DISCONNECT;break; default: CERROR("don't know how to disconnect from %s (connect_op %d)\n", imp->imp_target_uuid.uuid, imp->imp_connect_op); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index bb9b1e9..3b853dd 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -380,23 +380,21 @@ void lustre_swab_obdo (struct obdo *o) __swab32s (&o->o_valid); __swab32s (&o->o_misc); __swab32s (&o->o_easize); - __swab32s (&o->o_mds); - __swab64s (&o->o_fid); /* o_inline is opaque */ } /* mdc pack methods used by mdc and smfs*/ void *mdc_create_pack(struct lustre_msg *msg, int offset, - struct mdc_op_data *op_data, __u32 mode, - __u64 rdev, const void *data, int datalen) + struct mdc_op_data *op_data, __u32 mode, __u64 rdev, + const void *data, int datalen) { struct mds_rec_create *rec; char *tmp; rec = lustre_msg_buf(msg, offset, sizeof (*rec)); rec->cr_opcode = REINT_CREATE; - rec->cr_id = op_data->id1; - memset(&rec->cr_replayid, 0, sizeof(rec->cr_replayid)); + rec->cr_fid = op_data->fid1; + memset(&rec->cr_replayfid, 0, sizeof(rec->cr_replayfid)); rec->cr_mode = mode; rec->cr_rdev = rdev; rec->cr_time = op_data->mod_time; @@ -419,7 +417,7 @@ void *mdc_setattr_pack(struct lustre_msg *msg, int offset, char *tmp = NULL; rec->sa_opcode = REINT_SETATTR; - rec->sa_id = data->id1; + rec->sa_fid = data->fid1; if (iattr) { rec->sa_valid = iattr->ia_valid; @@ -438,18 +436,20 @@ void *mdc_setattr_pack(struct lustre_msg *msg, int offset, return (void*)tmp; memcpy(lustre_msg_buf(msg, offset + 1, ealen), ea, ealen); + tmp += size_round(ealen); if (ea2len == 0) return (void*)tmp; - memcpy(lustre_msg_buf(msg, offset + 2, ea2len), ea2, ea2len); tmp += size_round(ea2len); + memcpy(lustre_msg_buf(msg, offset + 2, ea2len), ea2, ea2len); + return (void*)tmp; } void *mdc_unlink_pack(struct lustre_msg *msg, int offset, - struct mdc_op_data *data) + struct mdc_op_data *data) { struct mds_rec_unlink *rec; char *tmp; @@ -459,8 +459,8 @@ void *mdc_unlink_pack(struct lustre_msg *msg, int offset, rec->ul_opcode = REINT_UNLINK; rec->ul_mode = data->create_mode; - rec->ul_id1 = data->id1; - rec->ul_id2 = data->id2; + rec->ul_fid1 = data->fid1; + rec->ul_fid2 = data->fid2; rec->ul_time = data->mod_time; tmp = lustre_msg_buf(msg, offset + 1, data->namelen + 1); @@ -470,7 +470,7 @@ void *mdc_unlink_pack(struct lustre_msg *msg, int offset, } void *mdc_link_pack(struct lustre_msg *msg, int offset, - struct mdc_op_data *data) + struct mdc_op_data *data) { struct mds_rec_link *rec; char *tmp; @@ -478,8 +478,8 @@ void *mdc_link_pack(struct lustre_msg *msg, int offset, rec = lustre_msg_buf(msg, offset, sizeof (*rec)); rec->lk_opcode = REINT_LINK; - rec->lk_id1 = data->id1; - rec->lk_id2 = data->id2; + rec->lk_fid1 = data->fid1; + rec->lk_fid2 = data->fid2; rec->lk_time = data->mod_time; tmp = lustre_msg_buf(msg, offset + 1, data->namelen + 1); @@ -490,8 +490,7 @@ void *mdc_link_pack(struct lustre_msg *msg, int offset, void *mdc_rename_pack(struct lustre_msg *msg, int offset, struct mdc_op_data *data, - const char *old, int oldlen, - const char *new, int newlen) + const char *old, int oldlen, const char *new, int newlen) { struct mds_rec_rename *rec; char *tmp; @@ -500,8 +499,8 @@ void *mdc_rename_pack(struct lustre_msg *msg, int offset, /* XXX do something about time, uid, gid */ rec->rn_opcode = REINT_RENAME; - rec->rn_id1 = data->id1; - rec->rn_id2 = data->id2; + rec->rn_fid1 = data->fid1; + rec->rn_fid2 = data->fid2; rec->rn_time = data->mod_time; tmp = lustre_msg_buf(msg, offset + 1, oldlen + 1); @@ -552,11 +551,6 @@ void lustre_swab_ost_last_id(obd_id *id) __swab64s(id); } -void lustre_swab_generic_32s(__u32 *val) -{ - __swab32s(val); -} - void lustre_swab_ost_lvb(struct ost_lvb *lvb) { __swab64s(&lvb->lvb_size); @@ -566,24 +560,11 @@ void lustre_swab_ost_lvb(struct ost_lvb *lvb) __swab64s(&lvb->lvb_blocks); } -void lustre_swab_lustre_stc (struct lustre_stc *stc) -{ - __swab64s (&stc->u.e3s.l3s_ino); - __swab32s (&stc->u.e3s.l3s_gen); - __swab32s (&stc->u.e3s.l3s_type); -} - -void lustre_swab_lustre_fid(struct lustre_fid *fid) -{ - __swab64s (&fid->lf_id); - __swab64s (&fid->lf_group); - __swab32s (&fid->lf_version); -} - -void lustre_swab_lustre_id (struct lustre_id *id) +void lustre_swab_ll_fid (struct ll_fid *fid) { - lustre_swab_lustre_stc(&id->li_stc); - lustre_swab_lustre_fid(&id->li_fid); + __swab64s (&fid->id); + __swab32s (&fid->generation); + __swab32s (&fid->f_type); } void lustre_swab_mds_status_req (struct mds_status_req *r) @@ -635,11 +616,12 @@ struct mds_req_sec_desc *lustre_swab_mds_secdesc(struct ptlrpc_request *req, void lustre_swab_mds_body (struct mds_body *b) { - lustre_swab_lustre_id (&b->id1); - lustre_swab_lustre_id (&b->id2); + lustre_swab_ll_fid (&b->fid1); + lustre_swab_ll_fid (&b->fid2); /* handle is opaque */ __swab64s (&b->size); __swab64s (&b->blocks); + __swab32s (&b->ino); __swab32s (&b->valid); __swab32s (&b->mode); __swab32s (&b->uid); @@ -650,13 +632,15 @@ void lustre_swab_mds_body (struct mds_body *b) __swab32s (&b->flags); __swab32s (&b->rdev); __swab32s (&b->nlink); + __swab32s (&b->generation); __swab32s (&b->eadatasize); + __swab32s (&b->mds); } void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa) { __swab32s (&sa->sa_opcode); __swab32s (&sa->sa_valid); - lustre_swab_lustre_id (&sa->sa_id); + lustre_swab_ll_fid (&sa->sa_fid); __swab32s (&sa->sa_mode); __swab32s (&sa->sa_uid); __swab32s (&sa->sa_gid); @@ -672,8 +656,8 @@ void lustre_swab_mds_rec_create (struct mds_rec_create *cr) __swab32s (&cr->cr_opcode); __swab32s (&cr->cr_flags); /* for use with open */ __swab32s (&cr->cr_mode); - lustre_swab_lustre_id (&cr->cr_id); - lustre_swab_lustre_id (&cr->cr_replayid); + lustre_swab_ll_fid (&cr->cr_fid); + lustre_swab_ll_fid (&cr->cr_replayfid); __swab64s (&cr->cr_time); __swab64s (&cr->cr_rdev); } @@ -681,23 +665,23 @@ void lustre_swab_mds_rec_create (struct mds_rec_create *cr) void lustre_swab_mds_rec_link (struct mds_rec_link *lk) { __swab32s (&lk->lk_opcode); - lustre_swab_lustre_id (&lk->lk_id1); - lustre_swab_lustre_id (&lk->lk_id2); + lustre_swab_ll_fid (&lk->lk_fid1); + lustre_swab_ll_fid (&lk->lk_fid2); } void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul) { __swab32s (&ul->ul_opcode); __swab32s (&ul->ul_mode); - lustre_swab_lustre_id (&ul->ul_id1); - lustre_swab_lustre_id (&ul->ul_id2); + lustre_swab_ll_fid (&ul->ul_fid1); + lustre_swab_ll_fid (&ul->ul_fid2); } void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn) { __swab32s (&rn->rn_opcode); - lustre_swab_lustre_id (&rn->rn_id1); - lustre_swab_lustre_id (&rn->rn_id2); + lustre_swab_ll_fid (&rn->rn_fid1); + lustre_swab_ll_fid (&rn->rn_fid2); } void lustre_swab_lov_desc (struct lov_desc *ld) @@ -836,5 +820,1393 @@ void lustre_swab_llogd_conn_body (struct llogd_conn_body *d) void lustre_assert_wire_constants(void) { + /* Wire protocol assertions generated by 'wirecheck' + * running on Linux build 2.4.24-cmd2 #1 SMP Tue Sep 14 10:34:54 MDT 2004 i686 i686 i386 GNU/ + * with gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) */ + + + /* Constants... */ + LASSERTF(PTLRPC_MSG_MAGIC == 0x0BD00BD0," found %lld\n", + (long long)PTLRPC_MSG_MAGIC); + LASSERTF(PTLRPC_MSG_VERSION == 0x00000003," found %lld\n", + (long long)PTLRPC_MSG_VERSION); + LASSERTF(PTL_RPC_MSG_REQUEST == 4711, " found %lld\n", + (long long)PTL_RPC_MSG_REQUEST); + LASSERTF(PTL_RPC_MSG_ERR == 4712, " found %lld\n", + (long long)PTL_RPC_MSG_ERR); + LASSERTF(PTL_RPC_MSG_REPLY == 4713, " found %lld\n", + (long long)PTL_RPC_MSG_REPLY); + LASSERTF(MSG_LAST_REPLAY == 1, " found %lld\n", + (long long)MSG_LAST_REPLAY); + LASSERTF(MSG_RESENT == 2, " found %lld\n", + (long long)MSG_RESENT); + LASSERTF(MSG_REPLAY == 4, " found %lld\n", + (long long)MSG_REPLAY); + LASSERTF(MSG_CONNECT_RECOVERING == 1, " found %lld\n", + (long long)MSG_CONNECT_RECOVERING); + LASSERTF(MSG_CONNECT_RECONNECT == 2, " found %lld\n", + (long long)MSG_CONNECT_RECONNECT); + LASSERTF(MSG_CONNECT_REPLAYABLE == 4, " found %lld\n", + (long long)MSG_CONNECT_REPLAYABLE); + LASSERTF(OST_REPLY == 0, " found %lld\n", + (long long)OST_REPLY); + LASSERTF(OST_GETATTR == 1, " found %lld\n", + (long long)OST_GETATTR); + LASSERTF(OST_SETATTR == 2, " found %lld\n", + (long long)OST_SETATTR); + LASSERTF(OST_READ == 3, " found %lld\n", + (long long)OST_READ); + LASSERTF(OST_WRITE == 4, " found %lld\n", + (long long)OST_WRITE); + LASSERTF(OST_CREATE == 5, " found %lld\n", + (long long)OST_CREATE); + LASSERTF(OST_DESTROY == 6, " found %lld\n", + (long long)OST_DESTROY); + LASSERTF(OST_GET_INFO == 7, " found %lld\n", + (long long)OST_GET_INFO); + LASSERTF(OST_CONNECT == 8, " found %lld\n", + (long long)OST_CONNECT); + LASSERTF(OST_DISCONNECT == 9, " found %lld\n", + (long long)OST_DISCONNECT); + LASSERTF(OST_PUNCH == 10, " found %lld\n", + (long long)OST_PUNCH); + LASSERTF(OST_OPEN == 11, " found %lld\n", + (long long)OST_OPEN); + LASSERTF(OST_CLOSE == 12, " found %lld\n", + (long long)OST_CLOSE); + LASSERTF(OST_STATFS == 13, " found %lld\n", + (long long)OST_STATFS); + LASSERTF(OST_SAN_READ == 14, " found %lld\n", + (long long)OST_SAN_READ); + LASSERTF(OST_SAN_WRITE == 15, " found %lld\n", + (long long)OST_SAN_WRITE); + LASSERTF(OST_SYNC == 16, " found %lld\n", + (long long)OST_SYNC); + LASSERTF(OST_LAST_OPC == 18, " found %lld\n", + (long long)OST_LAST_OPC); + LASSERTF(OBD_OBJECT_EOF == 0xffffffffffffffffULL," found %lld\n", + (long long)OBD_OBJECT_EOF); + LASSERTF(OST_REQ_HAS_OA1 == 1, " found %lld\n", + (long long)OST_REQ_HAS_OA1); + LASSERTF(MDS_GETATTR == 33, " found %lld\n", + (long long)MDS_GETATTR); + LASSERTF(MDS_GETATTR_LOCK == 34, " found %lld\n", + (long long)MDS_GETATTR_LOCK); + LASSERTF(MDS_CLOSE == 35, " found %lld\n", + (long long)MDS_CLOSE); + LASSERTF(MDS_REINT == 36, " found %lld\n", + (long long)MDS_REINT); + LASSERTF(MDS_READPAGE == 37, " found %lld\n", + (long long)MDS_READPAGE); + LASSERTF(MDS_CONNECT == 38, " found %lld\n", + (long long)MDS_CONNECT); + LASSERTF(MDS_DISCONNECT == 39, " found %lld\n", + (long long)MDS_DISCONNECT); + LASSERTF(MDS_GETSTATUS == 40, " found %lld\n", + (long long)MDS_GETSTATUS); + LASSERTF(MDS_STATFS == 41, " found %lld\n", + (long long)MDS_STATFS); + LASSERTF(MDS_PIN == 42, " found %lld\n", + (long long)MDS_PIN); + LASSERTF(MDS_UNPIN == 43, " found %lld\n", + (long long)MDS_UNPIN); + LASSERTF(MDS_SYNC == 44, " found %lld\n", + (long long)MDS_SYNC); + LASSERTF(MDS_DONE_WRITING == 45, " found %lld\n", + (long long)MDS_DONE_WRITING); + LASSERTF(MDS_LAST_OPC == 46, " found %lld\n", + (long long)MDS_LAST_OPC); + LASSERTF(REINT_SETATTR == 1, " found %lld\n", + (long long)REINT_SETATTR); + LASSERTF(REINT_CREATE == 2, " found %lld\n", + (long long)REINT_CREATE); + LASSERTF(REINT_LINK == 3, " found %lld\n", + (long long)REINT_LINK); + LASSERTF(REINT_UNLINK == 4, " found %lld\n", + (long long)REINT_UNLINK); + LASSERTF(REINT_RENAME == 5, " found %lld\n", + (long long)REINT_RENAME); + LASSERTF(REINT_OPEN == 6, " found %lld\n", + (long long)REINT_OPEN); + LASSERTF(REINT_MAX == 8, " found %lld\n", + (long long)REINT_MAX); + LASSERTF(DISP_IT_EXECD == 1, " found %lld\n", + (long long)DISP_IT_EXECD); + LASSERTF(DISP_LOOKUP_EXECD == 2, " found %lld\n", + (long long)DISP_LOOKUP_EXECD); + LASSERTF(DISP_LOOKUP_NEG == 4, " found %lld\n", + (long long)DISP_LOOKUP_NEG); + LASSERTF(DISP_LOOKUP_POS == 8, " found %lld\n", + (long long)DISP_LOOKUP_POS); + LASSERTF(DISP_OPEN_CREATE == 16, " found %lld\n", + (long long)DISP_OPEN_CREATE); + LASSERTF(DISP_OPEN_OPEN == 32, " found %lld\n", + (long long)DISP_OPEN_OPEN); + LASSERTF(MDS_STATUS_CONN == 1, " found %lld\n", + (long long)MDS_STATUS_CONN); + LASSERTF(MDS_STATUS_LOV == 2, " found %lld\n", + (long long)MDS_STATUS_LOV); + LASSERTF(MDS_OPEN_HAS_EA == 1073741824, " found %lld\n", + (long long)MDS_OPEN_HAS_EA); + LASSERTF(LDLM_ENQUEUE == 101, " found %lld\n", + (long long)LDLM_ENQUEUE); + LASSERTF(LDLM_CONVERT == 102, " found %lld\n", + (long long)LDLM_CONVERT); + LASSERTF(LDLM_CANCEL == 103, " found %lld\n", + (long long)LDLM_CANCEL); + LASSERTF(LDLM_BL_CALLBACK == 104, " found %lld\n", + (long long)LDLM_BL_CALLBACK); + LASSERTF(LDLM_CP_CALLBACK == 105, " found %lld\n", + (long long)LDLM_CP_CALLBACK); + LASSERTF(LDLM_LAST_OPC == 107, " found %lld\n", + (long long)LDLM_LAST_OPC); + LASSERTF(LCK_EX == 1, " found %lld\n", + (long long)LCK_EX); + LASSERTF(LCK_PW == 2, " found %lld\n", + (long long)LCK_PW); + LASSERTF(LCK_PR == 4, " found %lld\n", + (long long)LCK_PR); + LASSERTF(LCK_CW == 8, " found %lld\n", + (long long)LCK_CW); + LASSERTF(LCK_CR == 16, " found %lld\n", + (long long)LCK_CR); + LASSERTF(LCK_NL == 32, " found %lld\n", + (long long)LCK_NL); + LASSERTF(PTLBD_QUERY == 200, " found %lld\n", + (long long)PTLBD_QUERY); + LASSERTF(PTLBD_READ == 201, " found %lld\n", + (long long)PTLBD_READ); + LASSERTF(PTLBD_WRITE == 202, " found %lld\n", + (long long)PTLBD_WRITE); + LASSERTF(PTLBD_FLUSH == 203, " found %lld\n", + (long long)PTLBD_FLUSH); + LASSERTF(PTLBD_CONNECT == 204, " found %lld\n", + (long long)PTLBD_CONNECT); + LASSERTF(PTLBD_DISCONNECT == 205, " found %lld\n", + (long long)PTLBD_DISCONNECT); + LASSERTF(PTLBD_LAST_OPC == 206, " found %lld\n", + (long long)PTLBD_LAST_OPC); + LASSERTF(MGMT_CONNECT == 250, " found %lld\n", + (long long)MGMT_CONNECT); + LASSERTF(MGMT_DISCONNECT == 251, " found %lld\n", + (long long)MGMT_DISCONNECT); + LASSERTF(MGMT_EXCEPTION == 252, " found %lld\n", + (long long)MGMT_EXCEPTION); + LASSERTF(OBD_PING == 400, " found %lld\n", + (long long)OBD_PING); + LASSERTF(OBD_LOG_CANCEL == 401, " found %lld\n", + (long long)OBD_LOG_CANCEL); + LASSERTF(OBD_LAST_OPC == 402, " found %lld\n", + (long long)OBD_LAST_OPC); + /* Sizes and Offsets */ + + + /* Checks for struct lustre_handle */ + LASSERTF((int)sizeof(struct lustre_handle) == 8, " found %lld\n", + (long long)(int)sizeof(struct lustre_handle)); + LASSERTF((int)offsetof(struct lustre_handle, cookie) == 0, " found %lld\n", + (long long)(int)offsetof(struct lustre_handle, cookie)); + LASSERTF((int)sizeof(((struct lustre_handle *)0)->cookie) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lustre_handle *)0)->cookie)); + + /* Checks for struct lustre_msg */ + LASSERTF((int)sizeof(struct lustre_msg) == 64, " found %lld\n", + (long long)(int)sizeof(struct lustre_msg)); + LASSERTF((int)offsetof(struct lustre_msg, handle) == 0, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, handle)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->handle) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->handle)); + LASSERTF((int)offsetof(struct lustre_msg, magic) == 8, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, magic)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->magic) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->magic)); + LASSERTF((int)offsetof(struct lustre_msg, type) == 12, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, type)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->type) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->type)); + LASSERTF((int)offsetof(struct lustre_msg, version) == 16, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, version)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->version) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->version)); + LASSERTF((int)offsetof(struct lustre_msg, opc) == 20, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, opc)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->opc) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->opc)); + LASSERTF((int)offsetof(struct lustre_msg, last_xid) == 24, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, last_xid)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->last_xid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->last_xid)); + LASSERTF((int)offsetof(struct lustre_msg, last_committed) == 32, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, last_committed)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->last_committed) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->last_committed)); + LASSERTF((int)offsetof(struct lustre_msg, transno) == 40, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, transno)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->transno) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->transno)); + LASSERTF((int)offsetof(struct lustre_msg, status) == 48, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, status)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->status) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->status)); + LASSERTF((int)offsetof(struct lustre_msg, flags) == 52, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, flags)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->flags)); + LASSERTF((int)offsetof(struct lustre_msg, bufcount) == 60, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, bufcount)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->bufcount) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->bufcount)); + LASSERTF((int)offsetof(struct lustre_msg, buflens[7]) == 92, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, buflens[7])); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->buflens[7]) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->buflens[7])); + + /* Checks for struct obdo */ + LASSERTF((int)sizeof(struct obdo) == 176, " found %lld\n", + (long long)(int)sizeof(struct obdo)); + LASSERTF((int)offsetof(struct obdo, o_id) == 0, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_id)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_id) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_id)); + LASSERTF((int)offsetof(struct obdo, o_gr) == 8, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_gr)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_gr) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_gr)); + LASSERTF((int)offsetof(struct obdo, o_atime) == 32, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_atime)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_atime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_atime)); + LASSERTF((int)offsetof(struct obdo, o_mtime) == 24, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_mtime)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_mtime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_mtime)); + LASSERTF((int)offsetof(struct obdo, o_ctime) == 40, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_ctime)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_ctime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_ctime)); + LASSERTF((int)offsetof(struct obdo, o_size) == 16, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_size)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_size) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_size)); + LASSERTF((int)offsetof(struct obdo, o_blocks) == 48, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_blocks)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_blocks) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_blocks)); + LASSERTF((int)offsetof(struct obdo, o_grant) == 56, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_grant)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_grant) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_grant)); + LASSERTF((int)offsetof(struct obdo, o_blksize) == 64, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_blksize)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_blksize) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_blksize)); + LASSERTF((int)offsetof(struct obdo, o_mode) == 68, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_mode)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_mode)); + LASSERTF((int)offsetof(struct obdo, o_uid) == 72, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_uid)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_uid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_uid)); + LASSERTF((int)offsetof(struct obdo, o_gid) == 76, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_gid)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_gid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_gid)); + LASSERTF((int)offsetof(struct obdo, o_flags) == 80, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_flags)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_flags)); + LASSERTF((int)offsetof(struct obdo, o_nlink) == 84, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_nlink)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_nlink) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_nlink)); + LASSERTF((int)offsetof(struct obdo, o_generation) == 88, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_generation)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_generation) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_generation)); + LASSERTF((int)offsetof(struct obdo, o_valid) == 92, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_valid)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_valid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_valid)); + LASSERTF((int)offsetof(struct obdo, o_misc) == 96, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_misc)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_misc) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_misc)); + LASSERTF((int)offsetof(struct obdo, o_easize) == 100, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_easize)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_easize) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_easize)); + LASSERTF((int)offsetof(struct obdo, o_mds) == 104, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_mds)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_mds) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_mds)); + LASSERTF((int)offsetof(struct obdo, o_padding) == 108, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_padding)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_padding) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_padding)); + LASSERTF((int)offsetof(struct obdo, o_inline) == 112, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_inline)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_inline) == 64, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_inline)); + LASSERTF(OBD_MD_FLID == 1, " found %lld\n", + (long long)OBD_MD_FLID); + LASSERTF(OBD_MD_FLATIME == 2, " found %lld\n", + (long long)OBD_MD_FLATIME); + LASSERTF(OBD_MD_FLMTIME == 4, " found %lld\n", + (long long)OBD_MD_FLMTIME); + LASSERTF(OBD_MD_FLCTIME == 8, " found %lld\n", + (long long)OBD_MD_FLCTIME); + LASSERTF(OBD_MD_FLSIZE == 16, " found %lld\n", + (long long)OBD_MD_FLSIZE); + LASSERTF(OBD_MD_FLBLOCKS == 32, " found %lld\n", + (long long)OBD_MD_FLBLOCKS); + LASSERTF(OBD_MD_FLBLKSZ == 64, " found %lld\n", + (long long)OBD_MD_FLBLKSZ); + LASSERTF(OBD_MD_FLMODE == 128, " found %lld\n", + (long long)OBD_MD_FLMODE); + LASSERTF(OBD_MD_FLTYPE == 256, " found %lld\n", + (long long)OBD_MD_FLTYPE); + LASSERTF(OBD_MD_FLUID == 512, " found %lld\n", + (long long)OBD_MD_FLUID); + LASSERTF(OBD_MD_FLGID == 1024, " found %lld\n", + (long long)OBD_MD_FLGID); + LASSERTF(OBD_MD_FLFLAGS == 2048, " found %lld\n", + (long long)OBD_MD_FLFLAGS); + LASSERTF(OBD_MD_FLNLINK == 8192, " found %lld\n", + (long long)OBD_MD_FLNLINK); + LASSERTF(OBD_MD_FLGENER == 16384, " found %lld\n", + (long long)OBD_MD_FLGENER); + LASSERTF(OBD_MD_FLINLINE == 32768, " found %lld\n", + (long long)OBD_MD_FLINLINE); + LASSERTF(OBD_MD_FLRDEV == 65536, " found %lld\n", + (long long)OBD_MD_FLRDEV); + LASSERTF(OBD_MD_FLEASIZE == 131072, " found %lld\n", + (long long)OBD_MD_FLEASIZE); + LASSERTF(OBD_MD_LINKNAME == 262144, " found %lld\n", + (long long)OBD_MD_LINKNAME); + LASSERTF(OBD_MD_FLHANDLE == 524288, " found %lld\n", + (long long)OBD_MD_FLHANDLE); + LASSERTF(OBD_MD_FLCKSUM == 1048576, " found %lld\n", + (long long)OBD_MD_FLCKSUM); + LASSERTF(OBD_MD_FLQOS == 2097152, " found %lld\n", + (long long)OBD_MD_FLQOS); + LASSERTF(OBD_MD_FLOSCOPQ == 4194304, " found %lld\n", + (long long)OBD_MD_FLOSCOPQ); + LASSERTF(OBD_MD_FLCOOKIE == 8388608, " found %lld\n", + (long long)OBD_MD_FLCOOKIE); + LASSERTF(OBD_MD_FLGROUP == 16777216, " found %lld\n", + (long long)OBD_MD_FLGROUP); + LASSERTF(OBD_FL_INLINEDATA == 1, " found %lld\n", + (long long)OBD_FL_INLINEDATA); + LASSERTF(OBD_FL_OBDMDEXISTS == 2, " found %lld\n", + (long long)OBD_FL_OBDMDEXISTS); + LASSERTF(OBD_FL_DELORPHAN == 4, " found %lld\n", + (long long)OBD_FL_DELORPHAN); + LASSERTF(OBD_FL_NORPC == 8, " found %lld\n", + (long long)OBD_FL_NORPC); + LASSERTF(OBD_FL_IDONLY == 16, " found %lld\n", + (long long)OBD_FL_IDONLY); + LASSERTF(OBD_FL_RECREATE_OBJS == 32, " found %lld\n", + (long long)OBD_FL_RECREATE_OBJS); + + /* Checks for struct lov_mds_md_v1 */ + LASSERTF((int)sizeof(struct lov_mds_md_v1) == 32, " found %lld\n", + (long long)(int)sizeof(struct lov_mds_md_v1)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_magic) == 0, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_magic)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_magic) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_magic)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_pattern) == 4, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_pattern)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_pattern) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_pattern)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_object_id) == 8, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_object_id)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_id) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_id)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_object_gr) == 16, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_object_gr)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_gr) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_gr)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_stripe_size) == 24, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_stripe_size)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_size) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_size)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_stripe_count) == 28, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_stripe_count)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_count) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_count)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_objects) == 32, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_objects)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects) == 0, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects)); + + /* Checks for struct lov_ost_data_v1 */ + LASSERTF((int)sizeof(struct lov_ost_data_v1) == 24, " found %lld\n", + (long long)(int)sizeof(struct lov_ost_data_v1)); + LASSERTF((int)offsetof(struct lov_ost_data_v1, l_object_id) == 0, " found %lld\n", + (long long)(int)offsetof(struct lov_ost_data_v1, l_object_id)); + LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_id) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_id)); + LASSERTF((int)offsetof(struct lov_ost_data_v1, l_object_gr) == 8, " found %lld\n", + (long long)(int)offsetof(struct lov_ost_data_v1, l_object_gr)); + LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_gr) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_gr)); + LASSERTF((int)offsetof(struct lov_ost_data_v1, l_ost_gen) == 16, " found %lld\n", + (long long)(int)offsetof(struct lov_ost_data_v1, l_ost_gen)); + LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_gen) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_gen)); + LASSERTF((int)offsetof(struct lov_ost_data_v1, l_ost_idx) == 20, " found %lld\n", + (long long)(int)offsetof(struct lov_ost_data_v1, l_ost_idx)); + LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_idx) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_idx)); + LASSERTF(LOV_MAGIC_V0 == 198183888, " found %lld\n", + (long long)LOV_MAGIC_V0); + LASSERTF(LOV_MAGIC_V1 == 198249424, " found %lld\n", + (long long)LOV_MAGIC_V1); + LASSERTF(LOV_PATTERN_RAID0 == 1, " found %lld\n", + (long long)LOV_PATTERN_RAID0); + LASSERTF(LOV_PATTERN_RAID1 == 2, " found %lld\n", + (long long)LOV_PATTERN_RAID1); + + /* Checks for struct obd_statfs */ + LASSERTF((int)sizeof(struct obd_statfs) == 144, " found %lld\n", + (long long)(int)sizeof(struct obd_statfs)); + LASSERTF((int)offsetof(struct obd_statfs, os_type) == 0, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_type)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_type) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_type)); + LASSERTF((int)offsetof(struct obd_statfs, os_blocks) == 8, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_blocks)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_blocks) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_blocks)); + LASSERTF((int)offsetof(struct obd_statfs, os_bfree) == 16, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_bfree)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_bfree) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_bfree)); + LASSERTF((int)offsetof(struct obd_statfs, os_bavail) == 24, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_bavail)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_bavail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_bavail)); + LASSERTF((int)offsetof(struct obd_statfs, os_ffree) == 40, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_ffree)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_ffree) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_ffree)); + LASSERTF((int)offsetof(struct obd_statfs, os_fsid) == 48, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_fsid)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_fsid) == 40, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_fsid)); + LASSERTF((int)offsetof(struct obd_statfs, os_bsize) == 88, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_bsize)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_bsize) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_bsize)); + LASSERTF((int)offsetof(struct obd_statfs, os_namelen) == 92, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_namelen)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_namelen) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_namelen)); + LASSERTF((int)offsetof(struct obd_statfs, os_spare) == 104, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_spare)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_spare) == 40, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_spare)); + + /* Checks for struct obd_ioobj */ + LASSERTF((int)sizeof(struct obd_ioobj) == 24, " found %lld\n", + (long long)(int)sizeof(struct obd_ioobj)); + LASSERTF((int)offsetof(struct obd_ioobj, ioo_id) == 0, " found %lld\n", + (long long)(int)offsetof(struct obd_ioobj, ioo_id)); + LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_id) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_id)); + LASSERTF((int)offsetof(struct obd_ioobj, ioo_gr) == 8, " found %lld\n", + (long long)(int)offsetof(struct obd_ioobj, ioo_gr)); + LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_gr) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_gr)); + LASSERTF((int)offsetof(struct obd_ioobj, ioo_type) == 16, " found %lld\n", + (long long)(int)offsetof(struct obd_ioobj, ioo_type)); + LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_type) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_type)); + LASSERTF((int)offsetof(struct obd_ioobj, ioo_bufcnt) == 20, " found %lld\n", + (long long)(int)offsetof(struct obd_ioobj, ioo_bufcnt)); + LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt)); + + /* Checks for struct niobuf_remote */ + LASSERTF((int)sizeof(struct niobuf_remote) == 16, " found %lld\n", + (long long)(int)sizeof(struct niobuf_remote)); + LASSERTF((int)offsetof(struct niobuf_remote, offset) == 0, " found %lld\n", + (long long)(int)offsetof(struct niobuf_remote, offset)); + LASSERTF((int)sizeof(((struct niobuf_remote *)0)->offset) == 8, " found %lld\n", + (long long)(int)sizeof(((struct niobuf_remote *)0)->offset)); + LASSERTF((int)offsetof(struct niobuf_remote, len) == 8, " found %lld\n", + (long long)(int)offsetof(struct niobuf_remote, len)); + LASSERTF((int)sizeof(((struct niobuf_remote *)0)->len) == 4, " found %lld\n", + (long long)(int)sizeof(((struct niobuf_remote *)0)->len)); + LASSERTF((int)offsetof(struct niobuf_remote, flags) == 12, " found %lld\n", + (long long)(int)offsetof(struct niobuf_remote, flags)); + LASSERTF((int)sizeof(((struct niobuf_remote *)0)->flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct niobuf_remote *)0)->flags)); + LASSERTF(OBD_BRW_READ == 1, " found %lld\n", + (long long)OBD_BRW_READ); + LASSERTF(OBD_BRW_WRITE == 2, " found %lld\n", + (long long)OBD_BRW_WRITE); + LASSERTF(OBD_BRW_SYNC == 8, " found %lld\n", + (long long)OBD_BRW_SYNC); + LASSERTF(OBD_BRW_FROM_GRANT == 32, " found %lld\n", + (long long)OBD_BRW_FROM_GRANT); + + /* Checks for struct ost_body */ + LASSERTF((int)sizeof(struct ost_body) == 176, " found %lld\n", + (long long)(int)sizeof(struct ost_body)); + LASSERTF((int)offsetof(struct ost_body, oa) == 0, " found %lld\n", + (long long)(int)offsetof(struct ost_body, oa)); + LASSERTF((int)sizeof(((struct ost_body *)0)->oa) == 176, " found %lld\n", + (long long)(int)sizeof(((struct ost_body *)0)->oa)); + + /* Checks for struct ll_fid */ + LASSERTF((int)sizeof(struct ll_fid) == 24, " found %lld\n", + (long long)(int)sizeof(struct ll_fid)); + LASSERTF((int)offsetof(struct ll_fid, id) == 0, " found %lld\n", + (long long)(int)offsetof(struct ll_fid, id)); + LASSERTF((int)sizeof(((struct ll_fid *)0)->id) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ll_fid *)0)->id)); + LASSERTF((int)offsetof(struct ll_fid, generation) == 8, " found %lld\n", + (long long)(int)offsetof(struct ll_fid, generation)); + LASSERTF((int)sizeof(((struct ll_fid *)0)->generation) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ll_fid *)0)->generation)); + LASSERTF((int)offsetof(struct ll_fid, f_type) == 12, " found %lld\n", + (long long)(int)offsetof(struct ll_fid, f_type)); + LASSERTF((int)sizeof(((struct ll_fid *)0)->f_type) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ll_fid *)0)->f_type)); + + /* Checks for struct mds_status_req */ + LASSERTF((int)sizeof(struct mds_status_req) == 8, " found %lld\n", + (long long)(int)sizeof(struct mds_status_req)); + LASSERTF((int)offsetof(struct mds_status_req, flags) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_status_req, flags)); + LASSERTF((int)sizeof(((struct mds_status_req *)0)->flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_status_req *)0)->flags)); + LASSERTF((int)offsetof(struct mds_status_req, repbuf) == 4, " found %lld\n", + (long long)(int)offsetof(struct mds_status_req, repbuf)); + LASSERTF((int)sizeof(((struct mds_status_req *)0)->repbuf) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_status_req *)0)->repbuf)); + + /* Checks for struct mds_body */ + LASSERTF((int)sizeof(struct mds_body) == 136, " found %lld\n", + (long long)(int)sizeof(struct mds_body)); + LASSERTF((int)offsetof(struct mds_body, fid1) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_body, fid1)); + LASSERTF((int)sizeof(((struct mds_body *)0)->fid1) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->fid1)); + LASSERTF((int)offsetof(struct mds_body, fid2) == 24, " found %lld\n", + (long long)(int)offsetof(struct mds_body, fid2)); + LASSERTF((int)sizeof(((struct mds_body *)0)->fid2) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->fid2)); + LASSERTF((int)offsetof(struct mds_body, handle) == 48, " found %lld\n", + (long long)(int)offsetof(struct mds_body, handle)); + LASSERTF((int)sizeof(((struct mds_body *)0)->handle) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->handle)); + LASSERTF((int)offsetof(struct mds_body, size) == 56, " found %lld\n", + (long long)(int)offsetof(struct mds_body, size)); + LASSERTF((int)sizeof(((struct mds_body *)0)->size) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->size)); + LASSERTF((int)offsetof(struct mds_body, blocks) == 64, " found %lld\n", + (long long)(int)offsetof(struct mds_body, blocks)); + LASSERTF((int)sizeof(((struct mds_body *)0)->blocks) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->blocks)); + LASSERTF((int)offsetof(struct mds_body, io_epoch) == 72, " found %lld\n", + (long long)(int)offsetof(struct mds_body, io_epoch)); + LASSERTF((int)sizeof(((struct mds_body *)0)->io_epoch) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->io_epoch)); + LASSERTF((int)offsetof(struct mds_body, ino) == 80, " found %lld\n", + (long long)(int)offsetof(struct mds_body, ino)); + LASSERTF((int)sizeof(((struct mds_body *)0)->ino) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->ino)); + LASSERTF((int)offsetof(struct mds_body, valid) == 84, " found %lld\n", + (long long)(int)offsetof(struct mds_body, valid)); + LASSERTF((int)sizeof(((struct mds_body *)0)->valid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->valid)); + LASSERTF((int)offsetof(struct mds_body, mode) == 88, " found %lld\n", + (long long)(int)offsetof(struct mds_body, mode)); + LASSERTF((int)sizeof(((struct mds_body *)0)->mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->mode)); + LASSERTF((int)offsetof(struct mds_body, uid) == 92, " found %lld\n", + (long long)(int)offsetof(struct mds_body, uid)); + LASSERTF((int)sizeof(((struct mds_body *)0)->uid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->uid)); + LASSERTF((int)offsetof(struct mds_body, gid) == 96, " found %lld\n", + (long long)(int)offsetof(struct mds_body, gid)); + LASSERTF((int)sizeof(((struct mds_body *)0)->gid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->gid)); + LASSERTF((int)offsetof(struct mds_body, mtime) == 100, " found %lld\n", + (long long)(int)offsetof(struct mds_body, mtime)); + LASSERTF((int)sizeof(((struct mds_body *)0)->mtime) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->mtime)); + LASSERTF((int)offsetof(struct mds_body, ctime) == 104, " found %lld\n", + (long long)(int)offsetof(struct mds_body, ctime)); + LASSERTF((int)sizeof(((struct mds_body *)0)->ctime) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->ctime)); + LASSERTF((int)offsetof(struct mds_body, atime) == 108, " found %lld\n", + (long long)(int)offsetof(struct mds_body, atime)); + LASSERTF((int)sizeof(((struct mds_body *)0)->atime) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->atime)); + LASSERTF((int)offsetof(struct mds_body, flags) == 112, " found %lld\n", + (long long)(int)offsetof(struct mds_body, flags)); + LASSERTF((int)sizeof(((struct mds_body *)0)->flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->flags)); + LASSERTF((int)offsetof(struct mds_body, rdev) == 116, " found %lld\n", + (long long)(int)offsetof(struct mds_body, rdev)); + LASSERTF((int)sizeof(((struct mds_body *)0)->rdev) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->rdev)); + LASSERTF((int)offsetof(struct mds_body, nlink) == 120, " found %lld\n", + (long long)(int)offsetof(struct mds_body, nlink)); + LASSERTF((int)sizeof(((struct mds_body *)0)->nlink) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->nlink)); + LASSERTF((int)offsetof(struct mds_body, generation) == 124, " found %lld\n", + (long long)(int)offsetof(struct mds_body, generation)); + LASSERTF((int)sizeof(((struct mds_body *)0)->generation) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->generation)); + LASSERTF((int)offsetof(struct mds_body, eadatasize) == 128, " found %lld\n", + (long long)(int)offsetof(struct mds_body, eadatasize)); + LASSERTF((int)sizeof(((struct mds_body *)0)->eadatasize) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->eadatasize)); + LASSERTF((int)offsetof(struct mds_body, mds) == 132, " found %lld\n", + (long long)(int)offsetof(struct mds_body, mds)); + LASSERTF((int)sizeof(((struct mds_body *)0)->mds) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->mds)); + LASSERTF(FMODE_READ == 1, " found %lld\n", + (long long)FMODE_READ); + LASSERTF(FMODE_WRITE == 2, " found %lld\n", + (long long)FMODE_WRITE); + LASSERTF(FMODE_EXEC == 4, " found %lld\n", + (long long)FMODE_EXEC); + LASSERTF(MDS_OPEN_CREAT == 64, " found %lld\n", + (long long)MDS_OPEN_CREAT); + LASSERTF(MDS_OPEN_EXCL == 128, " found %lld\n", + (long long)MDS_OPEN_EXCL); + LASSERTF(MDS_OPEN_TRUNC == 512, " found %lld\n", + (long long)MDS_OPEN_TRUNC); + LASSERTF(MDS_OPEN_APPEND == 1024, " found %lld\n", + (long long)MDS_OPEN_APPEND); + LASSERTF(MDS_OPEN_SYNC == 4096, " found %lld\n", + (long long)MDS_OPEN_SYNC); + LASSERTF(MDS_OPEN_DIRECTORY == 65536, " found %lld\n", + (long long)MDS_OPEN_DIRECTORY); + LASSERTF(MDS_OPEN_DELAY_CREATE == 16777216, " found %lld\n", + (long long)MDS_OPEN_DELAY_CREATE); + LASSERTF(MDS_OPEN_HAS_EA == 1073741824, " found %lld\n", + (long long)MDS_OPEN_HAS_EA); + + /* Checks for struct mds_rec_setattr */ + LASSERTF((int)sizeof(struct mds_rec_setattr) == 80, " found %lld\n", + (long long)(int)sizeof(struct mds_rec_setattr)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_opcode) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_opcode)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_opcode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_opcode)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_valid) == 4, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_valid)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_valid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_valid)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_fid) == 8, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_fid)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_fid) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_fid)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_mode) == 32, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_mode)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_mode)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_uid) == 36, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_uid)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_uid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_uid)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_gid) == 40, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_gid)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_gid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_gid)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_attr_flags) == 44, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_attr_flags)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_attr_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_attr_flags)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_size) == 48, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_size)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_size) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_size)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_atime) == 56, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_atime)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_atime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_atime)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_mtime) == 64, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_mtime)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_mtime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_mtime)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_ctime) == 72, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_ctime)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_ctime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_ctime)); + + /* Checks for struct mds_rec_create */ + LASSERTF((int)sizeof(struct mds_rec_create) == 80, " found %lld\n", + (long long)(int)sizeof(struct mds_rec_create)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_opcode) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_opcode)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_opcode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_opcode)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_flags) == 4, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_flags)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_flags)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_mode) == 8, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_mode)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_mode)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_padding) == 12, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_padding)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_padding) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_padding)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_fid) == 16, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_fid)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_fid) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_fid)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_replayfid) == 40, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_replayfid)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_replayfid) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_replayfid)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_time) == 64, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_time)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_time) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_time)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_rdev) == 72, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_rdev)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_rdev) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_rdev)); + + /* Checks for struct mds_rec_link */ + LASSERTF((int)sizeof(struct mds_rec_link) == 64, " found %lld\n", + (long long)(int)sizeof(struct mds_rec_link)); + LASSERTF((int)offsetof(struct mds_rec_link, lk_opcode) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_link, lk_opcode)); + LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_opcode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_link *)0)->lk_opcode)); + LASSERTF((int)offsetof(struct mds_rec_link, lk_padding) == 4, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_link, lk_padding)); + LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_padding) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_link *)0)->lk_padding)); + LASSERTF((int)offsetof(struct mds_rec_link, lk_fid1) == 8, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_link, lk_fid1)); + LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_fid1) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_link *)0)->lk_fid1)); + LASSERTF((int)offsetof(struct mds_rec_link, lk_fid2) == 32, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_link, lk_fid2)); + LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_fid2) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_link *)0)->lk_fid2)); + LASSERTF((int)offsetof(struct mds_rec_link, lk_time) == 56, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_link, lk_time)); + LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_time) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_link *)0)->lk_time)); + + /* Checks for struct mds_rec_unlink */ + LASSERTF((int)sizeof(struct mds_rec_unlink) == 64, " found %lld\n", + (long long)(int)sizeof(struct mds_rec_unlink)); + LASSERTF((int)offsetof(struct mds_rec_unlink, ul_opcode) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_unlink, ul_opcode)); + LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_opcode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_opcode)); + LASSERTF((int)offsetof(struct mds_rec_unlink, ul_mode) == 4, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_unlink, ul_mode)); + LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_mode)); + LASSERTF((int)offsetof(struct mds_rec_unlink, ul_fid1) == 8, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_unlink, ul_fid1)); + LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_fid1) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_fid1)); + LASSERTF((int)offsetof(struct mds_rec_unlink, ul_fid2) == 32, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_unlink, ul_fid2)); + LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_fid2) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_fid2)); + LASSERTF((int)offsetof(struct mds_rec_unlink, ul_time) == 56, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_unlink, ul_time)); + LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_time) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_time)); + + /* Checks for struct mds_rec_rename */ + LASSERTF((int)sizeof(struct mds_rec_rename) == 64, " found %lld\n", + (long long)(int)sizeof(struct mds_rec_rename)); + LASSERTF((int)offsetof(struct mds_rec_rename, rn_opcode) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_rename, rn_opcode)); + LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_opcode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_opcode)); + LASSERTF((int)offsetof(struct mds_rec_rename, rn_padding) == 4, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_rename, rn_padding)); + LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_padding) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_padding)); + LASSERTF((int)offsetof(struct mds_rec_rename, rn_fid1) == 8, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_rename, rn_fid1)); + LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_fid1) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_fid1)); + LASSERTF((int)offsetof(struct mds_rec_rename, rn_fid2) == 32, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_rename, rn_fid2)); + LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_fid2) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_fid2)); + LASSERTF((int)offsetof(struct mds_rec_rename, rn_time) == 56, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_rename, rn_time)); + LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_time) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_time)); + + /* Checks for struct lov_desc */ + LASSERTF((int)sizeof(struct lov_desc) == 72, " found %lld\n", + (long long)(int)sizeof(struct lov_desc)); + LASSERTF((int)offsetof(struct lov_desc, ld_tgt_count) == 0, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_tgt_count)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_tgt_count) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_tgt_count)); + LASSERTF((int)offsetof(struct lov_desc, ld_active_tgt_count) == 4, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_active_tgt_count)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_active_tgt_count) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_active_tgt_count)); + LASSERTF((int)offsetof(struct lov_desc, ld_default_stripe_count) == 8, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_default_stripe_count)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_default_stripe_count) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_default_stripe_count)); + LASSERTF((int)offsetof(struct lov_desc, ld_pattern) == 12, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_pattern)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_pattern) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_pattern)); + LASSERTF((int)offsetof(struct lov_desc, ld_default_stripe_size) == 16, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_default_stripe_size)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_default_stripe_size) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_default_stripe_size)); + LASSERTF((int)offsetof(struct lov_desc, ld_default_stripe_offset) == 24, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_default_stripe_offset)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_default_stripe_offset) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_default_stripe_offset)); + LASSERTF((int)offsetof(struct lov_desc, ld_uuid) == 32, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_uuid)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_uuid) == 40, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_uuid)); + + /* Checks for struct ldlm_res_id */ + LASSERTF((int)sizeof(struct ldlm_res_id) == 32, " found %lld\n", + (long long)(int)sizeof(struct ldlm_res_id)); + LASSERTF((int)offsetof(struct ldlm_res_id, name[4]) == 32, " found %lld\n", + (long long)(int)offsetof(struct ldlm_res_id, name[4])); + LASSERTF((int)sizeof(((struct ldlm_res_id *)0)->name[4]) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_res_id *)0)->name[4])); + + /* Checks for struct ldlm_extent */ + LASSERTF((int)sizeof(struct ldlm_extent) == 24, " found %lld\n", + (long long)(int)sizeof(struct ldlm_extent)); + LASSERTF((int)offsetof(struct ldlm_extent, start) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_extent, start)); + LASSERTF((int)sizeof(((struct ldlm_extent *)0)->start) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_extent *)0)->start)); + LASSERTF((int)offsetof(struct ldlm_extent, end) == 8, " found %lld\n", + (long long)(int)offsetof(struct ldlm_extent, end)); + LASSERTF((int)sizeof(((struct ldlm_extent *)0)->end) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_extent *)0)->end)); + LASSERTF((int)offsetof(struct ldlm_extent, gid) == 16, " found %lld\n", + (long long)(int)offsetof(struct ldlm_extent, gid)); + LASSERTF((int)sizeof(((struct ldlm_extent *)0)->gid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_extent *)0)->gid)); + + /* Checks for struct ldlm_flock */ + LASSERTF((int)sizeof(struct ldlm_flock) == 40, " found %lld\n", + (long long)(int)sizeof(struct ldlm_flock)); + LASSERTF((int)offsetof(struct ldlm_flock, start) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_flock, start)); + LASSERTF((int)sizeof(((struct ldlm_flock *)0)->start) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_flock *)0)->start)); + LASSERTF((int)offsetof(struct ldlm_flock, end) == 8, " found %lld\n", + (long long)(int)offsetof(struct ldlm_flock, end)); + LASSERTF((int)sizeof(((struct ldlm_flock *)0)->end) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_flock *)0)->end)); + LASSERTF((int)offsetof(struct ldlm_flock, pid) == 16, " found %lld\n", + (long long)(int)offsetof(struct ldlm_flock, pid)); + LASSERTF((int)sizeof(((struct ldlm_flock *)0)->pid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_flock *)0)->pid)); + LASSERTF((int)offsetof(struct ldlm_flock, blocking_pid) == 24, " found %lld\n", + (long long)(int)offsetof(struct ldlm_flock, blocking_pid)); + LASSERTF((int)sizeof(((struct ldlm_flock *)0)->blocking_pid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_flock *)0)->blocking_pid)); + LASSERTF((int)offsetof(struct ldlm_flock, blocking_export) == 32, " found %lld\n", + (long long)(int)offsetof(struct ldlm_flock, blocking_export)); + LASSERTF((int)sizeof(((struct ldlm_flock *)0)->blocking_export) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_flock *)0)->blocking_export)); + + /* Checks for struct ldlm_intent */ + LASSERTF((int)sizeof(struct ldlm_intent) == 8, " found %lld\n", + (long long)(int)sizeof(struct ldlm_intent)); + LASSERTF((int)offsetof(struct ldlm_intent, opc) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_intent, opc)); + LASSERTF((int)sizeof(((struct ldlm_intent *)0)->opc) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_intent *)0)->opc)); + + /* Checks for struct ldlm_resource_desc */ + LASSERTF((int)sizeof(struct ldlm_resource_desc) == 40, " found %lld\n", + (long long)(int)sizeof(struct ldlm_resource_desc)); + LASSERTF((int)offsetof(struct ldlm_resource_desc, lr_type) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_resource_desc, lr_type)); + LASSERTF((int)sizeof(((struct ldlm_resource_desc *)0)->lr_type) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_resource_desc *)0)->lr_type)); + LASSERTF((int)offsetof(struct ldlm_resource_desc, lr_name) == 8, " found %lld\n", + (long long)(int)offsetof(struct ldlm_resource_desc, lr_name)); + LASSERTF((int)sizeof(((struct ldlm_resource_desc *)0)->lr_name) == 32, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_resource_desc *)0)->lr_name)); + + /* Checks for struct ldlm_lock_desc */ + LASSERTF((int)sizeof(struct ldlm_lock_desc) == 88, " found %lld\n", + (long long)(int)sizeof(struct ldlm_lock_desc)); + LASSERTF((int)offsetof(struct ldlm_lock_desc, l_resource) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_lock_desc, l_resource)); + LASSERTF((int)sizeof(((struct ldlm_lock_desc *)0)->l_resource) == 40, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_lock_desc *)0)->l_resource)); + LASSERTF((int)offsetof(struct ldlm_lock_desc, l_req_mode) == 40, " found %lld\n", + (long long)(int)offsetof(struct ldlm_lock_desc, l_req_mode)); + LASSERTF((int)sizeof(((struct ldlm_lock_desc *)0)->l_req_mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_lock_desc *)0)->l_req_mode)); + LASSERTF((int)offsetof(struct ldlm_lock_desc, l_granted_mode) == 44, " found %lld\n", + (long long)(int)offsetof(struct ldlm_lock_desc, l_granted_mode)); + LASSERTF((int)sizeof(((struct ldlm_lock_desc *)0)->l_granted_mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_lock_desc *)0)->l_granted_mode)); + LASSERTF((int)offsetof(struct ldlm_lock_desc, l_policy_data) == 48, " found %lld\n", + (long long)(int)offsetof(struct ldlm_lock_desc, l_policy_data)); + LASSERTF((int)sizeof(((struct ldlm_lock_desc *)0)->l_policy_data) == 40, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_lock_desc *)0)->l_policy_data)); + + /* Checks for struct ldlm_request */ + LASSERTF((int)sizeof(struct ldlm_request) == 112, " found %lld\n", + (long long)(int)sizeof(struct ldlm_request)); + LASSERTF((int)offsetof(struct ldlm_request, lock_flags) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_request, lock_flags)); + LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_request *)0)->lock_flags)); + LASSERTF((int)offsetof(struct ldlm_request, lock_desc) == 8, " found %lld\n", + (long long)(int)offsetof(struct ldlm_request, lock_desc)); + LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_desc) == 88, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_request *)0)->lock_desc)); + LASSERTF((int)offsetof(struct ldlm_request, lock_handle1) == 96, " found %lld\n", + (long long)(int)offsetof(struct ldlm_request, lock_handle1)); + LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_handle1) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_request *)0)->lock_handle1)); + LASSERTF((int)offsetof(struct ldlm_request, lock_handle2) == 104, " found %lld\n", + (long long)(int)offsetof(struct ldlm_request, lock_handle2)); + LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_handle2) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_request *)0)->lock_handle2)); + + /* Checks for struct ldlm_reply */ + LASSERTF((int)sizeof(struct ldlm_reply) == 120, " found %lld\n", + (long long)(int)sizeof(struct ldlm_reply)); + LASSERTF((int)offsetof(struct ldlm_reply, lock_flags) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_reply, lock_flags)); + LASSERTF((int)sizeof(((struct ldlm_reply *)0)->lock_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_reply *)0)->lock_flags)); + LASSERTF((int)offsetof(struct ldlm_request, lock_desc) == 8, " found %lld\n", + (long long)(int)offsetof(struct ldlm_request, lock_desc)); + LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_desc) == 88, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_request *)0)->lock_desc)); + LASSERTF((int)offsetof(struct ldlm_reply, lock_handle) == 96, " found %lld\n", + (long long)(int)offsetof(struct ldlm_reply, lock_handle)); + LASSERTF((int)sizeof(((struct ldlm_reply *)0)->lock_handle) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_reply *)0)->lock_handle)); + LASSERTF((int)offsetof(struct ldlm_reply, lock_policy_res1) == 104, " found %lld\n", + (long long)(int)offsetof(struct ldlm_reply, lock_policy_res1)); + LASSERTF((int)sizeof(((struct ldlm_reply *)0)->lock_policy_res1) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_reply *)0)->lock_policy_res1)); + LASSERTF((int)offsetof(struct ldlm_reply, lock_policy_res2) == 112, " found %lld\n", + (long long)(int)offsetof(struct ldlm_reply, lock_policy_res2)); + LASSERTF((int)sizeof(((struct ldlm_reply *)0)->lock_policy_res2) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_reply *)0)->lock_policy_res2)); + + /* Checks for struct ost_lvb */ + LASSERTF((int)sizeof(struct ost_lvb) == 40, " found %lld\n", + (long long)(int)sizeof(struct ost_lvb)); + LASSERTF((int)offsetof(struct ost_lvb, lvb_size) == 0, " found %lld\n", + (long long)(int)offsetof(struct ost_lvb, lvb_size)); + LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_size) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ost_lvb *)0)->lvb_size)); + LASSERTF((int)offsetof(struct ost_lvb, lvb_mtime) == 8, " found %lld\n", + (long long)(int)offsetof(struct ost_lvb, lvb_mtime)); + LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_mtime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ost_lvb *)0)->lvb_mtime)); + LASSERTF((int)offsetof(struct ost_lvb, lvb_atime) == 16, " found %lld\n", + (long long)(int)offsetof(struct ost_lvb, lvb_atime)); + LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_atime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ost_lvb *)0)->lvb_atime)); + LASSERTF((int)offsetof(struct ost_lvb, lvb_ctime) == 24, " found %lld\n", + (long long)(int)offsetof(struct ost_lvb, lvb_ctime)); + LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_ctime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ost_lvb *)0)->lvb_ctime)); + LASSERTF((int)offsetof(struct ost_lvb, lvb_blocks) == 32, " found %lld\n", + (long long)(int)offsetof(struct ost_lvb, lvb_blocks)); + LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_blocks) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ost_lvb *)0)->lvb_blocks)); + + /* Checks for struct ptlbd_op */ + LASSERTF((int)sizeof(struct ptlbd_op) == 12, " found %lld\n", + (long long)(int)sizeof(struct ptlbd_op)); + LASSERTF((int)offsetof(struct ptlbd_op, op_cmd) == 0, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_op, op_cmd)); + LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op_cmd) == 2, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_op *)0)->op_cmd)); + LASSERTF((int)offsetof(struct ptlbd_op, op_lun) == 2, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_op, op_lun)); + LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op_lun) == 2, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_op *)0)->op_lun)); + LASSERTF((int)offsetof(struct ptlbd_op, op_niob_cnt) == 4, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_op, op_niob_cnt)); + LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op_niob_cnt) == 2, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_op *)0)->op_niob_cnt)); + LASSERTF((int)offsetof(struct ptlbd_op, op__padding) == 6, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_op, op__padding)); + LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op__padding) == 2, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_op *)0)->op__padding)); + LASSERTF((int)offsetof(struct ptlbd_op, op_block_cnt) == 8, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_op, op_block_cnt)); + LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op_block_cnt) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_op *)0)->op_block_cnt)); + + /* Checks for struct ptlbd_niob */ + LASSERTF((int)sizeof(struct ptlbd_niob) == 24, " found %lld\n", + (long long)(int)sizeof(struct ptlbd_niob)); + LASSERTF((int)offsetof(struct ptlbd_niob, n_xid) == 0, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_niob, n_xid)); + LASSERTF((int)sizeof(((struct ptlbd_niob *)0)->n_xid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_niob *)0)->n_xid)); + LASSERTF((int)offsetof(struct ptlbd_niob, n_block_nr) == 8, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_niob, n_block_nr)); + LASSERTF((int)sizeof(((struct ptlbd_niob *)0)->n_block_nr) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_niob *)0)->n_block_nr)); + LASSERTF((int)offsetof(struct ptlbd_niob, n_offset) == 16, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_niob, n_offset)); + LASSERTF((int)sizeof(((struct ptlbd_niob *)0)->n_offset) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_niob *)0)->n_offset)); + LASSERTF((int)offsetof(struct ptlbd_niob, n_length) == 20, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_niob, n_length)); + LASSERTF((int)sizeof(((struct ptlbd_niob *)0)->n_length) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_niob *)0)->n_length)); + + /* Checks for struct ptlbd_rsp */ + LASSERTF((int)sizeof(struct ptlbd_rsp) == 4, " found %lld\n", + (long long)(int)sizeof(struct ptlbd_rsp)); + LASSERTF((int)offsetof(struct ptlbd_rsp, r_status) == 0, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_rsp, r_status)); + LASSERTF((int)sizeof(((struct ptlbd_rsp *)0)->r_status) == 2, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_rsp *)0)->r_status)); + LASSERTF((int)offsetof(struct ptlbd_rsp, r_error_cnt) == 2, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_rsp, r_error_cnt)); + LASSERTF((int)sizeof(((struct ptlbd_rsp *)0)->r_error_cnt) == 2, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_rsp *)0)->r_error_cnt)); + + /* Checks for struct llog_logid */ + LASSERTF((int)sizeof(struct llog_logid) == 20, " found %lld\n", + (long long)(int)sizeof(struct llog_logid)); + LASSERTF((int)offsetof(struct llog_logid, lgl_oid) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_logid, lgl_oid)); + LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_oid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_logid *)0)->lgl_oid)); + LASSERTF((int)offsetof(struct llog_logid, lgl_ogr) == 8, " found %lld\n", + (long long)(int)offsetof(struct llog_logid, lgl_ogr)); + LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_ogr) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_logid *)0)->lgl_ogr)); + LASSERTF((int)offsetof(struct llog_logid, lgl_ogen) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_logid, lgl_ogen)); + LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_ogen) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_logid *)0)->lgl_ogen)); + LASSERTF(OST_SZ_REC == 274730752, " found %lld\n", + (long long)OST_SZ_REC); + LASSERTF(OST_RAID1_REC == 274731008, " found %lld\n", + (long long)OST_RAID1_REC); + LASSERTF(MDS_UNLINK_REC == 274801668, " found %lld\n", + (long long)MDS_UNLINK_REC); + LASSERTF(OBD_CFG_REC == 274857984, " found %lld\n", + (long long)OBD_CFG_REC); + LASSERTF(PTL_CFG_REC == 274923520, " found %lld\n", + (long long)PTL_CFG_REC); + LASSERTF(LLOG_GEN_REC == 274989056, " found %lld\n", + (long long)LLOG_GEN_REC); + LASSERTF(LLOG_HDR_MAGIC == 275010873, " found %lld\n", + (long long)LLOG_HDR_MAGIC); + LASSERTF(LLOG_LOGID_MAGIC == 275010875, " found %lld\n", + (long long)LLOG_LOGID_MAGIC); + + /* Checks for struct llog_catid */ + LASSERTF((int)sizeof(struct llog_catid) == 32, " found %lld\n", + (long long)(int)sizeof(struct llog_catid)); + LASSERTF((int)offsetof(struct llog_catid, lci_logid) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_catid, lci_logid)); + LASSERTF((int)sizeof(((struct llog_catid *)0)->lci_logid) == 20, " found %lld\n", + (long long)(int)sizeof(((struct llog_catid *)0)->lci_logid)); + + /* Checks for struct llog_rec_hdr */ + LASSERTF((int)sizeof(struct llog_rec_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(struct llog_rec_hdr)); + LASSERTF((int)offsetof(struct llog_rec_hdr, lrh_len) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_rec_hdr, lrh_len)); + LASSERTF((int)sizeof(((struct llog_rec_hdr *)0)->lrh_len) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_rec_hdr *)0)->lrh_len)); + LASSERTF((int)offsetof(struct llog_rec_hdr, lrh_index) == 4, " found %lld\n", + (long long)(int)offsetof(struct llog_rec_hdr, lrh_index)); + LASSERTF((int)sizeof(((struct llog_rec_hdr *)0)->lrh_index) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_rec_hdr *)0)->lrh_index)); + LASSERTF((int)offsetof(struct llog_rec_hdr, lrh_type) == 8, " found %lld\n", + (long long)(int)offsetof(struct llog_rec_hdr, lrh_type)); + LASSERTF((int)sizeof(((struct llog_rec_hdr *)0)->lrh_type) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_rec_hdr *)0)->lrh_type)); + + /* Checks for struct llog_rec_tail */ + LASSERTF((int)sizeof(struct llog_rec_tail) == 8, " found %lld\n", + (long long)(int)sizeof(struct llog_rec_tail)); + LASSERTF((int)offsetof(struct llog_rec_tail, lrt_len) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_rec_tail, lrt_len)); + LASSERTF((int)sizeof(((struct llog_rec_tail *)0)->lrt_len) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_rec_tail *)0)->lrt_len)); + LASSERTF((int)offsetof(struct llog_rec_tail, lrt_index) == 4, " found %lld\n", + (long long)(int)offsetof(struct llog_rec_tail, lrt_index)); + LASSERTF((int)sizeof(((struct llog_rec_tail *)0)->lrt_index) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_rec_tail *)0)->lrt_index)); + + /* Checks for struct llog_logid_rec */ + LASSERTF((int)sizeof(struct llog_logid_rec) == 64, " found %lld\n", + (long long)(int)sizeof(struct llog_logid_rec)); + LASSERTF((int)offsetof(struct llog_logid_rec, lid_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_logid_rec, lid_hdr)); + LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_hdr)); + LASSERTF((int)offsetof(struct llog_logid_rec, lid_id) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_logid_rec, lid_id)); + LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_id) == 20, " found %lld\n", + (long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_id)); + LASSERTF((int)offsetof(struct llog_logid_rec, lid_tail) == 56, " found %lld\n", + (long long)(int)offsetof(struct llog_logid_rec, lid_tail)); + LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_tail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_tail)); + + /* Checks for struct llog_create_rec */ + LASSERTF((int)sizeof(struct llog_create_rec) == 64, " found %lld\n", + (long long)(int)sizeof(struct llog_create_rec)); + LASSERTF((int)offsetof(struct llog_create_rec, lcr_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_create_rec, lcr_hdr)); + LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_hdr)); + LASSERTF((int)offsetof(struct llog_create_rec, lcr_fid) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_create_rec, lcr_fid)); + LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_fid) == 24, " found %lld\n", + (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_fid)); + LASSERTF((int)offsetof(struct llog_create_rec, lcr_oid) == 40, " found %lld\n", + (long long)(int)offsetof(struct llog_create_rec, lcr_oid)); + LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_oid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_oid)); + LASSERTF((int)offsetof(struct llog_create_rec, lcr_ogen) == 48, " found %lld\n", + (long long)(int)offsetof(struct llog_create_rec, lcr_ogen)); + LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_ogen) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_ogen)); + + /* Checks for struct llog_orphan_rec */ + LASSERTF((int)sizeof(struct llog_orphan_rec) == 40, " found %lld\n", + (long long)(int)sizeof(struct llog_orphan_rec)); + LASSERTF((int)offsetof(struct llog_orphan_rec, lor_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_orphan_rec, lor_hdr)); + LASSERTF((int)sizeof(((struct llog_orphan_rec *)0)->lor_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_orphan_rec *)0)->lor_hdr)); + LASSERTF((int)offsetof(struct llog_orphan_rec, lor_oid) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_orphan_rec, lor_oid)); + LASSERTF((int)sizeof(((struct llog_orphan_rec *)0)->lor_oid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_orphan_rec *)0)->lor_oid)); + LASSERTF((int)offsetof(struct llog_orphan_rec, lor_ogen) == 24, " found %lld\n", + (long long)(int)offsetof(struct llog_orphan_rec, lor_ogen)); + LASSERTF((int)sizeof(((struct llog_orphan_rec *)0)->lor_ogen) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_orphan_rec *)0)->lor_ogen)); + LASSERTF((int)offsetof(struct llog_orphan_rec, lor_tail) == 32, " found %lld\n", + (long long)(int)offsetof(struct llog_orphan_rec, lor_tail)); + LASSERTF((int)sizeof(((struct llog_orphan_rec *)0)->lor_tail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_orphan_rec *)0)->lor_tail)); + + /* Checks for struct llog_unlink_rec */ + LASSERTF((int)sizeof(struct llog_unlink_rec) == 40, " found %lld\n", + (long long)(int)sizeof(struct llog_unlink_rec)); + LASSERTF((int)offsetof(struct llog_unlink_rec, lur_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_unlink_rec, lur_hdr)); + LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_hdr)); + LASSERTF((int)offsetof(struct llog_unlink_rec, lur_oid) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_unlink_rec, lur_oid)); + LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_oid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_oid)); + LASSERTF((int)offsetof(struct llog_unlink_rec, lur_ogen) == 24, " found %lld\n", + (long long)(int)offsetof(struct llog_unlink_rec, lur_ogen)); + LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_ogen) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_ogen)); + LASSERTF((int)offsetof(struct llog_unlink_rec, lur_tail) == 32, " found %lld\n", + (long long)(int)offsetof(struct llog_unlink_rec, lur_tail)); + LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_tail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_tail)); + + /* Checks for struct llog_size_change_rec */ + LASSERTF((int)sizeof(struct llog_size_change_rec) == 56, " found %lld\n", + (long long)(int)sizeof(struct llog_size_change_rec)); + LASSERTF((int)offsetof(struct llog_size_change_rec, lsc_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_size_change_rec, lsc_hdr)); + LASSERTF((int)sizeof(((struct llog_size_change_rec *)0)->lsc_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_size_change_rec *)0)->lsc_hdr)); + LASSERTF((int)offsetof(struct llog_size_change_rec, lsc_fid) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_size_change_rec, lsc_fid)); + LASSERTF((int)sizeof(((struct llog_size_change_rec *)0)->lsc_fid) == 24, " found %lld\n", + (long long)(int)sizeof(((struct llog_size_change_rec *)0)->lsc_fid)); + LASSERTF((int)offsetof(struct llog_size_change_rec, lsc_io_epoch) == 40, " found %lld\n", + (long long)(int)offsetof(struct llog_size_change_rec, lsc_io_epoch)); + LASSERTF((int)sizeof(((struct llog_size_change_rec *)0)->lsc_io_epoch) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_size_change_rec *)0)->lsc_io_epoch)); + LASSERTF((int)offsetof(struct llog_size_change_rec, lsc_tail) == 48, " found %lld\n", + (long long)(int)offsetof(struct llog_size_change_rec, lsc_tail)); + LASSERTF((int)sizeof(((struct llog_size_change_rec *)0)->lsc_tail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_size_change_rec *)0)->lsc_tail)); + + /* Checks for struct llog_gen */ + LASSERTF((int)sizeof(struct llog_gen) == 16, " found %lld\n", + (long long)(int)sizeof(struct llog_gen)); + LASSERTF((int)offsetof(struct llog_gen, mnt_cnt) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_gen, mnt_cnt)); + LASSERTF((int)sizeof(((struct llog_gen *)0)->mnt_cnt) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_gen *)0)->mnt_cnt)); + LASSERTF((int)offsetof(struct llog_gen, conn_cnt) == 8, " found %lld\n", + (long long)(int)offsetof(struct llog_gen, conn_cnt)); + LASSERTF((int)sizeof(((struct llog_gen *)0)->conn_cnt) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_gen *)0)->conn_cnt)); + + /* Checks for struct llog_gen_rec */ + LASSERTF((int)sizeof(struct llog_gen_rec) == 40, " found %lld\n", + (long long)(int)sizeof(struct llog_gen_rec)); + LASSERTF((int)offsetof(struct llog_gen_rec, lgr_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_gen_rec, lgr_hdr)); + LASSERTF((int)sizeof(((struct llog_gen_rec *)0)->lgr_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_gen_rec *)0)->lgr_hdr)); + LASSERTF((int)offsetof(struct llog_gen_rec, lgr_gen) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_gen_rec, lgr_gen)); + LASSERTF((int)sizeof(((struct llog_gen_rec *)0)->lgr_gen) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_gen_rec *)0)->lgr_gen)); + LASSERTF((int)offsetof(struct llog_gen_rec, lgr_tail) == 32, " found %lld\n", + (long long)(int)offsetof(struct llog_gen_rec, lgr_tail)); + LASSERTF((int)sizeof(((struct llog_gen_rec *)0)->lgr_tail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_gen_rec *)0)->lgr_tail)); + + /* Checks for struct llog_log_hdr */ + LASSERTF((int)sizeof(struct llog_log_hdr) == 8192, " found %lld\n", + (long long)(int)sizeof(struct llog_log_hdr)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_hdr)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_hdr)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_timestamp) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_timestamp)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_timestamp) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_timestamp)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_count) == 24, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_count)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_count) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_count)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_bitmap_offset) == 28, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_bitmap_offset)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap_offset) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap_offset)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_size) == 32, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_size)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_size) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_size)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_flags) == 36, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_flags)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_flags)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_cat_idx) == 40, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_cat_idx)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_cat_idx) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_cat_idx)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_tgtuuid) == 44, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_tgtuuid)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_tgtuuid) == 40, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_tgtuuid)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_bitmap) == 88, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_bitmap)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap) == 8096, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_tail) == 8184, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_tail)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_tail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_tail)); + + /* Checks for struct llog_cookie */ + LASSERTF((int)sizeof(struct llog_cookie) == 32, " found %lld\n", + (long long)(int)sizeof(struct llog_cookie)); + LASSERTF((int)offsetof(struct llog_cookie, lgc_lgl) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_cookie, lgc_lgl)); + LASSERTF((int)sizeof(((struct llog_cookie *)0)->lgc_lgl) == 20, " found %lld\n", + (long long)(int)sizeof(((struct llog_cookie *)0)->lgc_lgl)); + LASSERTF((int)offsetof(struct llog_cookie, lgc_subsys) == 20, " found %lld\n", + (long long)(int)offsetof(struct llog_cookie, lgc_subsys)); + LASSERTF((int)sizeof(((struct llog_cookie *)0)->lgc_subsys) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_cookie *)0)->lgc_subsys)); + LASSERTF((int)offsetof(struct llog_cookie, lgc_index) == 24, " found %lld\n", + (long long)(int)offsetof(struct llog_cookie, lgc_index)); + LASSERTF((int)sizeof(((struct llog_cookie *)0)->lgc_index) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_cookie *)0)->lgc_index)); + + /* Checks for struct llogd_body */ + LASSERTF((int)sizeof(struct llogd_body) == 48, " found %lld\n", + (long long)(int)sizeof(struct llogd_body)); + LASSERTF((int)offsetof(struct llogd_body, lgd_logid) == 0, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_logid)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_logid) == 20, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_logid)); + LASSERTF((int)offsetof(struct llogd_body, lgd_ctxt_idx) == 20, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_ctxt_idx)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_ctxt_idx) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_ctxt_idx)); + LASSERTF((int)offsetof(struct llogd_body, lgd_llh_flags) == 24, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_llh_flags)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_llh_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_llh_flags)); + LASSERTF((int)offsetof(struct llogd_body, lgd_index) == 28, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_index)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_index) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_index)); + LASSERTF((int)offsetof(struct llogd_body, lgd_saved_index) == 32, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_saved_index)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_saved_index) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_saved_index)); + LASSERTF((int)offsetof(struct llogd_body, lgd_len) == 36, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_len)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_len) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_len)); + LASSERTF((int)offsetof(struct llogd_body, lgd_cur_offset) == 40, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_cur_offset)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_cur_offset) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_cur_offset)); + LASSERTF(LLOG_ORIGIN_HANDLE_OPEN == 501, " found %lld\n", + (long long)LLOG_ORIGIN_HANDLE_OPEN); + LASSERTF(LLOG_ORIGIN_HANDLE_NEXT_BLOCK == 502, " found %lld\n", + (long long)LLOG_ORIGIN_HANDLE_NEXT_BLOCK); + LASSERTF(LLOG_ORIGIN_HANDLE_READ_HEADER == 503, " found %lld\n", + (long long)LLOG_ORIGIN_HANDLE_READ_HEADER); + LASSERTF(LLOG_ORIGIN_HANDLE_WRITE_REC == 504, " found %lld\n", + (long long)LLOG_ORIGIN_HANDLE_WRITE_REC); + LASSERTF(LLOG_ORIGIN_HANDLE_CLOSE == 505, " found %lld\n", + (long long)LLOG_ORIGIN_HANDLE_CLOSE); + LASSERTF(LLOG_ORIGIN_CONNECT == 506, " found %lld\n", + (long long)LLOG_ORIGIN_CONNECT); + LASSERTF(LLOG_CATINFO == 507, " found %lld\n", + (long long)LLOG_CATINFO); + + /* Checks for struct llogd_conn_body */ + LASSERTF((int)sizeof(struct llogd_conn_body) == 40, " found %lld\n", + (long long)(int)sizeof(struct llogd_conn_body)); + LASSERTF((int)offsetof(struct llogd_conn_body, lgdc_gen) == 0, " found %lld\n", + (long long)(int)offsetof(struct llogd_conn_body, lgdc_gen)); + LASSERTF((int)sizeof(((struct llogd_conn_body *)0)->lgdc_gen) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llogd_conn_body *)0)->lgdc_gen)); + LASSERTF((int)offsetof(struct llogd_conn_body, lgdc_logid) == 16, " found %lld\n", + (long long)(int)offsetof(struct llogd_conn_body, lgdc_logid)); + LASSERTF((int)sizeof(((struct llogd_conn_body *)0)->lgdc_logid) == 20, " found %lld\n", + (long long)(int)sizeof(((struct llogd_conn_body *)0)->lgdc_logid)); + LASSERTF((int)offsetof(struct llogd_conn_body, lgdc_ctxt_idx) == 36, " found %lld\n", + (long long)(int)offsetof(struct llogd_conn_body, lgdc_ctxt_idx)); + LASSERTF((int)sizeof(((struct llogd_conn_body *)0)->lgdc_ctxt_idx) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llogd_conn_body *)0)->lgdc_ctxt_idx)); } diff --git a/lustre/ptlrpc/ptlrpc_module.c b/lustre/ptlrpc/ptlrpc_module.c index 5cbdf4f..5c59f02 100644 --- a/lustre/ptlrpc/ptlrpc_module.c +++ b/lustre/ptlrpc/ptlrpc_module.c @@ -166,10 +166,7 @@ EXPORT_SYMBOL(lustre_swab_niobuf_remote); EXPORT_SYMBOL(lustre_swab_ost_body); EXPORT_SYMBOL(lustre_swab_ost_last_id); EXPORT_SYMBOL(lustre_swab_ost_lvb); -EXPORT_SYMBOL(lustre_swab_generic_32s); -EXPORT_SYMBOL(lustre_swab_lustre_id); -EXPORT_SYMBOL(lustre_swab_lustre_stc); -EXPORT_SYMBOL(lustre_swab_lustre_fid); +EXPORT_SYMBOL(lustre_swab_ll_fid); EXPORT_SYMBOL(lustre_swab_mds_status_req); EXPORT_SYMBOL(lustre_swab_mds_secdesc); EXPORT_SYMBOL(lustre_swab_mds_body); diff --git a/lustre/smfs/cache_space.c b/lustre/smfs/cache_space.c index e42156f..674a264 100644 --- a/lustre/smfs/cache_space.c +++ b/lustre/smfs/cache_space.c @@ -31,14 +31,13 @@ #include "smfs_internal.h" struct cache_purge_param { - int nfract; /* percentage of cache dirty to activate - * cpurge */ - int ndirty; /* maximum number of objects to write out per - wake-cycle */ - int interval; /* jiffies delay between cache purge */ - int nfract_sync; /* percentage of cache dirty to activate cpurge - synchronously */ - int nfract_stop_cpurge; /* percentage of cache dirty to stop cpurge */ + int nfract; /* Percentage of cache dirty to activate cpurge */ + int ndirty; /* Maximum number of objects to write out per + wake-cycle */ + int interval; /* jiffies delay between cache purge */ + int nfract_sync;/* Percentage of cache dirty to activate + cpurge synchronously */ + int nfract_stop_cpurge; /* Percentage of cache dirty to stop cpurge */ } cf_prm = {30, 512, 600 * HZ, 60, 20}; static struct cache_purge_queue smfs_cpq; @@ -122,8 +121,7 @@ static int cache_leaf_node(struct dentry *dentry, __u64 *active_entry) if (S_ISDIR(inode->i_mode)) { if (inode->i_nlink != 2) return 0; - if (!strncmp(dentry->d_name.name, "lost+found", - dentry->d_name.len)) + if (!strncmp(dentry->d_name.name, "lost+found", dentry->d_name.len)) return 0; LASSERT(active_entry != NULL); get_active_entry(inode, active_entry); @@ -137,7 +135,6 @@ static int cache_leaf_node(struct dentry *dentry, __u64 *active_entry) return 1; } } - static int cache_pre_leaf_node(struct dentry *dentry, __u64 *active_entry, int op) { if (((op == 0 && dentry->d_inode->i_nlink == 0) || @@ -159,45 +156,38 @@ static int set_lru_logcookie(struct inode *inode, void *handle, { struct fsfilt_operations *fsops = I2CSB(inode)->sm_fsfilt; int rc; - ENTRY; - rc = fsops->fs_set_xattr(inode, handle, XATTR_SMFS_CACHE_LOGCOOKIE, logcookie, sizeof(*logcookie)); RETURN(rc); } - static int get_lru_logcookie(struct inode *inode, struct llog_cookie *logcookie) { struct fsfilt_operations *fsops = I2CSB(inode)->sm_fsfilt; int rc; - - ENTRY; rc = fsops->fs_get_xattr(inode, XATTR_SMFS_CACHE_LOGCOOKIE, logcookie, sizeof(*logcookie)); RETURN(rc); } -static int try2purge_from_cache(struct lustre_id cid, - struct lustre_id pid) +static int try2purge_from_cache(struct ll_fid cfid, struct ll_fid pfid) { struct inode *inode, *parent; struct super_block *sb = cpq->cpq_sb; + //struct llog_cookie logcookie; __u32 hoard_priority = 0; int rc = 0; ENTRY; - inode = iget(sb, cid.li_stc.u.e3s.l3s_ino); + inode = iget(sb, cfid.id); if (IS_ERR(inode)) { CERROR("not existent inode: "LPX64"/%u\n", - cid.li_stc.u.e3s.l3s_ino, - cid.li_stc.u.e3s.l3s_gen); + cfid.id, cfid.generation); RETURN(-ENOENT); } - parent = iget(sb, pid.li_stc.u.e3s.l3s_ino); + parent = iget(sb, pfid.id); if (IS_ERR(parent)) { CERROR("not existent inode: "LPX64"/%u\n", - pid.li_stc.u.e3s.l3s_ino, - pid.li_stc.u.e3s.l3s_gen); + pfid.id, pfid.generation); iput(inode); RETURN(-ENOENT); } @@ -239,10 +229,9 @@ static int cache_lru_get_rec_cb(struct llog_handle *llh, llr = (struct llog_lru_rec *)rec; - if (try2purge_from_cache(llr->llr_cid, llr->llr_pid)==1){ + if (try2purge_from_cache(llr->llr_cfid, llr->llr_pfid)==1){ CDEBUG(D_INODE, "purge ino/gen "LPX64"/%u from cache\n", - llr->llr_cid.li_stc.u.e3s.l3s_ino, - llr->llr_cid.li_stc.u.e3s.l3s_gen); + llr->llr_cfid.id, llr->llr_cfid.generation); count --; if (count == 0) rc = LLOG_PROC_BREAK; @@ -306,16 +295,13 @@ static int purge_some_cache(int *count) } #define CFLUSH_NR 512 - static void check_cache_space(void) { int state = cache_balance_state(); ENTRY; - if (state < 0) { - EXIT; + if (state < 0) return; - } wakeup_cpurge(); @@ -323,7 +309,6 @@ static void check_cache_space(void) int count = CFLUSH_NR; purge_some_cache(&count); } - EXIT; } void cache_space_pre(struct inode *inode, int op) @@ -332,12 +317,10 @@ void cache_space_pre(struct inode *inode, int op) /* FIXME have not used op */ check_cache_space(); - - EXIT; } static int cache_space_hook_lru(struct inode *inode, struct inode *parent, - void *handle, int op, int flags) + void *handle, int op, int flags) { struct fsfilt_operations *fsops = S2SMI(cpq->cpq_sb)->sm_fsfilt; struct llog_ctxt *ctxt = cpq->cpq_loghandle->lgh_ctxt; @@ -390,15 +373,12 @@ insert: llr->llr_hdr.lrh_len = llr->llr_tail.lrt_len = sizeof(*llr); llr->llr_hdr.lrh_type = CACHE_LRU_REC; - - /* FIXME-UMKA: should we setup fid components here? */ - llr->llr_cid.li_stc.u.e3s.l3s_ino = inode->i_ino; - llr->llr_cid.li_stc.u.e3s.l3s_gen = inode->i_generation; - llr->llr_cid.li_stc.u.e3s.l3s_type = inode->i_mode & S_IFMT; - - llr->llr_pid.li_stc.u.e3s.l3s_ino = parent->i_ino; - llr->llr_pid.li_stc.u.e3s.l3s_gen = parent->i_generation; - llr->llr_pid.li_stc.u.e3s.l3s_type = parent->i_mode & S_IFMT; + llr->llr_cfid.id = inode->i_ino; + llr->llr_cfid.generation = inode->i_generation; + llr->llr_cfid.f_type = inode->i_mode & S_IFMT; + llr->llr_pfid.id = parent->i_ino; + llr->llr_pfid.generation = parent->i_generation; + llr->llr_pfid.f_type = parent->i_mode & S_IFMT; rc = llog_add(ctxt, &llr->llr_hdr, NULL, logcookie, 1, NULL, NULL, NULL); @@ -460,7 +440,7 @@ static int cache_purge_thread(void *args) } cpq->cpq_flags = SVC_STOPPED; complete(&cpq->cpq_comp); - RETURN(0); + return 0; } int cache_space_hook_setup(struct super_block *sb) @@ -516,7 +496,6 @@ int cache_space_hook_cleanup(void) ctxt = cpq->cpq_loghandle->lgh_ctxt; rc = llog_catalog_cleanup(ctxt); OBD_FREE(ctxt, sizeof(*ctxt)); - if (rc) CERROR("failed to clean up cache lru list catalog %d\n", rc); @@ -529,7 +508,6 @@ static int cache_space_hook_create(void *handle, struct inode *dir, { __u64 active_entry = 0; int rc; - ENTRY; LASSERT(cache_leaf_node(dentry, NULL)); rc = cache_space_hook_lru(dentry->d_inode, dir, handle, @@ -548,28 +526,24 @@ static int cache_space_hook_create(void *handle, struct inode *dir, rc = set_active_entry(dir, &active_entry, handle); RETURN(rc); } - static int cache_space_hook_lookup(void *handle, struct inode *dir, struct dentry *dentry, struct inode *new_dir, struct dentry *new_dentry) { __u64 active_entry; int rc = 0; - ENTRY; if (cache_leaf_node(dentry, &active_entry)) rc = cache_space_hook_lru(dentry->d_inode, dir, handle, CACHE_SPACE_DELETE | CACHE_SPACE_INSERT,1); RETURN(rc); } - static int cache_space_hook_link(void *handle, struct inode *dir, struct dentry *dentry, struct inode *new_dir, struct dentry *new_dentry) { __u64 active_entry = 0; int rc = 0; - ENTRY; if (cache_pre_leaf_node(dentry, NULL, 1)) { rc = cache_space_hook_lru(dentry->d_inode, NULL, @@ -579,7 +553,7 @@ static int cache_space_hook_link(void *handle, struct inode *dir, } if (cache_leaf_node(dentry->d_parent, &active_entry)) { - rc = cache_space_hook_lru(dir, NULL, handle, CACHE_SPACE_DELETE, 0); + rc = cache_space_hook_lru(dir,NULL,handle,CACHE_SPACE_DELETE,0); if (rc) RETURN(rc); } @@ -591,14 +565,12 @@ static int cache_space_hook_link(void *handle, struct inode *dir, rc = set_active_entry(dir, &active_entry, handle); RETURN(rc); } - static int cache_space_hook_unlink(void *handle, struct inode *dir, struct dentry *dentry, struct inode *new_dir, struct dentry *new_dentry) { __u64 active_entry; int rc = 0; - ENTRY; if (cache_pre_leaf_node(dentry, NULL, 0)) rc = cache_space_hook_lru(dentry->d_inode, NULL, @@ -619,31 +591,27 @@ static int cache_space_hook_unlink(void *handle, struct inode *dir, handle, CACHE_SPACE_INSERT, 0); RETURN(rc); } - static int cache_space_hook_mkdir(void *handle, struct inode *dir, struct dentry *dentry, struct inode *new_dir, struct dentry *new_dentry) { __u64 active_entry; int rc; - ENTRY; LASSERT(cache_leaf_node(dentry, &active_entry)); rc = cache_space_hook_lru(dentry->d_inode, dir, handle, - CACHE_SPACE_INSERT, 0); + CACHE_SPACE_INSERT,0); if (!rc && cache_pre_leaf_node(dentry->d_parent, &active_entry, 3)) - rc = cache_space_hook_lru(dir, NULL, handle, CACHE_SPACE_DELETE, 0); + rc = cache_space_hook_lru(dir,NULL,handle,CACHE_SPACE_DELETE,0); RETURN(rc); } - static int cache_space_hook_rmdir(void *handle, struct inode *dir, struct dentry *dentry, struct inode *new_dir, struct dentry *new_dentry) { __u64 active_entry; int rc; - ENTRY; LASSERT(cache_pre_leaf_node(dentry, &active_entry, 2)); rc = cache_space_hook_lru(dentry->d_inode, NULL, handle, @@ -655,14 +623,12 @@ static int cache_space_hook_rmdir(void *handle, struct inode *dir, handle, CACHE_SPACE_INSERT, 0); RETURN(rc); } - static int cache_space_hook_rename(void *handle, struct inode *old_dir, - struct dentry *old_dentry, struct inode *new_dir, - struct dentry *new_dentry) + struct dentry *old_dentry, struct inode *new_dir, + struct dentry *new_dentry) { __u64 active_entry; int rc = 0; - ENTRY; if (new_dentry->d_inode) { if (cache_pre_leaf_node(new_dentry, NULL, 0)) @@ -695,17 +661,14 @@ static int cache_space_hook_rename(void *handle, struct inode *old_dir, active_entry --; if (!rc) rc = set_active_entry(old_dir, &active_entry, handle); - } else if (cache_pre_leaf_node(new_dentry->d_parent, &active_entry, 3)) { + } else if (cache_pre_leaf_node(new_dentry->d_parent, &active_entry, 3)) rc = cache_space_hook_lru(new_dir, NULL, handle, CACHE_SPACE_DELETE, 0); - } - if (!rc && cache_leaf_node(old_dentry->d_parent, &active_entry)) { + if (!rc && cache_leaf_node(old_dentry->d_parent, &active_entry)) rc = cache_space_hook_lru(old_dir, - old_dentry->d_parent->d_parent->d_inode, - handle, CACHE_SPACE_INSERT, 0); - } - + old_dentry->d_parent->d_parent->d_inode, + handle, CACHE_SPACE_INSERT, 0); RETURN(rc); } @@ -729,8 +692,8 @@ static cache_hook_op cache_space_hook_ops[HOOK_MAX + 1] = { }; int cache_space_post(int op, void *handle, struct inode *old_dir, - struct dentry *old_dentry, struct inode *new_dir, - struct dentry *new_dentry) + struct dentry *old_dentry, struct inode *new_dir, + struct dentry *new_dentry) { int rc = 0; ENTRY; diff --git a/lustre/smfs/dir.c b/lustre/smfs/dir.c index 685d6ff..85fb5b4 100644 --- a/lustre/smfs/dir.c +++ b/lustre/smfs/dir.c @@ -67,9 +67,8 @@ static int smfs_create(struct inode *dir, struct dentry *dentry, RETURN(-ENOSPC); lock_kernel(); - SMFS_HOOK(dir, dentry, NULL, NULL, HOOK_CREATE, handle, - PRE_HOOK, rc, exit); - + SMFS_HOOK(dir, dentry, NULL, NULL, HOOK_CREATE, handle, PRE_HOOK, rc, + exit); cache_parent = pre_smfs_dentry(NULL, cache_dir, dentry); cache_dentry = pre_smfs_dentry(cache_parent, NULL, dentry); @@ -77,7 +76,6 @@ static int smfs_create(struct inode *dir, struct dentry *dentry, GOTO(exit, rc = -ENOMEM); pre_smfs_inode(dir, cache_dir); - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) if (cache_dir && cache_dir->i_op->create) rc = cache_dir->i_op->create(cache_dir, cache_dentry, @@ -90,14 +88,13 @@ static int smfs_create(struct inode *dir, struct dentry *dentry, if (rc) GOTO(exit, rc); - SMFS_GET_INODE(dir->i_sb, cache_dentry->d_inode, dir, inode, - rc, exit); + SMFS_GET_INODE(dir->i_sb, cache_dentry->d_inode, dir, inode, rc, exit); d_instantiate(dentry, inode); post_smfs_inode(dir, cache_dir); - SMFS_HOOK(dir, dentry, NULL, NULL, HOOK_CREATE, handle, - POST_HOOK, rc, exit); + SMFS_HOOK(dir, dentry, NULL, NULL, HOOK_CREATE, handle, POST_HOOK, rc, + exit); exit: unlock_kernel(); post_smfs_dentry(cache_dentry); @@ -171,19 +168,20 @@ exit: RETURN(rc); } -static int smfs_link(struct dentry *old_dentry, - struct inode *dir, struct dentry *dentry) +static int smfs_link(struct dentry * old_dentry, + struct inode * dir, struct dentry *dentry) { - struct inode *cache_old_inode = NULL; - struct inode *cache_dir = I2CI(dir); - struct inode *inode = NULL; - struct dentry *cache_dentry = NULL; - struct dentry *cache_old_dentry = NULL; - struct dentry *cache_parent = NULL; - void *handle = NULL; - int rc = 0; + struct inode *cache_old_inode = NULL; + struct inode *cache_dir = I2CI(dir); + struct inode *inode = NULL; + struct dentry *cache_dentry = NULL; + struct dentry *cache_old_dentry = NULL; + struct dentry *cache_parent = NULL; + void *handle = NULL; + int rc = 0; inode = old_dentry->d_inode; + cache_old_inode = I2CI(inode); handle = smfs_trans_start(dir, FSFILT_OP_LINK, NULL); @@ -191,8 +189,8 @@ static int smfs_link(struct dentry *old_dentry, RETURN(-ENOSPC); lock_kernel(); - SMFS_HOOK(dir, old_dentry, NULL, NULL, HOOK_LINK, handle, - PRE_HOOK, rc, exit); + SMFS_HOOK(dir, old_dentry, NULL, NULL, HOOK_LINK, handle, PRE_HOOK, rc, + exit); cache_parent = pre_smfs_dentry(NULL, cache_dir, dentry); cache_dentry = pre_smfs_dentry(cache_parent, NULL, dentry); @@ -200,8 +198,7 @@ static int smfs_link(struct dentry *old_dentry, if (!cache_parent || !cache_dentry) GOTO(exit, rc = -ENOMEM); - cache_old_dentry = pre_smfs_dentry(NULL, cache_old_inode, - old_dentry); + cache_old_dentry = pre_smfs_dentry(NULL, cache_old_inode, old_dentry); if (!cache_old_dentry) GOTO(exit, rc = -ENOMEM); @@ -219,8 +216,8 @@ static int smfs_link(struct dentry *old_dentry, d_instantiate(dentry, inode); post_smfs_inode(dir, cache_dir); - SMFS_HOOK(dir, old_dentry, dentry, NULL, HOOK_LINK, handle, - POST_HOOK, rc, exit); + SMFS_HOOK(dir, old_dentry, dentry, NULL, HOOK_LINK, handle, POST_HOOK, + rc, exit); exit: unlock_kernel(); post_smfs_dentry(cache_dentry); @@ -484,8 +481,8 @@ exit: RETURN(rc); } -static int smfs_rename(struct inode *old_dir, struct dentry *old_dentry, - struct inode *new_dir,struct dentry *new_dentry) +static int smfs_rename(struct inode * old_dir, struct dentry *old_dentry, + struct inode * new_dir,struct dentry *new_dentry) { struct inode *cache_old_dir = I2CI(old_dir); struct inode *cache_new_dir = I2CI(new_dir); @@ -512,22 +509,18 @@ static int smfs_rename(struct inode *old_dir, struct dentry *old_dentry, lock_kernel(); - SMFS_HOOK(old_dir, old_dentry, new_dir, new_dentry, HOOK_RENAME, - handle, PRE_HOOK, rc, exit); + SMFS_HOOK(old_dir, old_dentry, new_dir, new_dentry, HOOK_RENAME, handle, + PRE_HOOK, rc, exit); cache_old_parent = pre_smfs_dentry(NULL, cache_old_dir, old_dentry); - cache_old_dentry = pre_smfs_dentry(cache_old_parent, cache_old_inode, old_dentry); - if (!cache_old_parent || !cache_old_dentry) GOTO(exit, rc = -ENOMEM); cache_new_parent = pre_smfs_dentry(NULL, cache_new_dir, new_dentry); - cache_new_dentry = pre_smfs_dentry(cache_new_parent, cache_new_inode, new_dentry); - if (!cache_new_parent || !cache_new_dentry) GOTO(exit, rc = -ENOMEM); @@ -635,10 +628,10 @@ exit: } struct file_operations smfs_dir_fops = { - .read = smfs_read_dir, - .readdir = smfs_readdir, /* BKL held */ - .ioctl = smfs_ioctl, /* BKL held */ - .fsync = smfs_fsync, /* BKL held */ - .open = smfs_open, - .release = smfs_release, + read: smfs_read_dir, + readdir: smfs_readdir, /* BKL held */ + ioctl: smfs_ioctl, /* BKL held */ + fsync: smfs_fsync, /* BKL held */ + open: smfs_open, + release: smfs_release, }; diff --git a/lustre/smfs/file.c b/lustre/smfs/file.c index f427884b..3a79ddd 100644 --- a/lustre/smfs/file.c +++ b/lustre/smfs/file.c @@ -544,10 +544,10 @@ int smfs_removexattr(struct dentry *dentry, const char *name) } struct inode_operations smfs_file_iops = { - .truncate = smfs_truncate, /* BKL held */ - .setattr = smfs_setattr, /* BKL held */ - .setxattr = smfs_setxattr, /* BKL held */ - .getxattr = smfs_getxattr, /* BKL held */ - .listxattr = smfs_listxattr, /* BKL held */ - .removexattr = smfs_removexattr, /* BKL held */ + truncate: smfs_truncate, /* BKL held */ + setattr: smfs_setattr, /* BKL held */ + setxattr: smfs_setxattr, /* BKL held */ + getxattr: smfs_getxattr, /* BKL held */ + listxattr: smfs_listxattr, /* BKL held */ + removexattr: smfs_removexattr, /* BKL held */ }; diff --git a/lustre/smfs/inode.c b/lustre/smfs/inode.c index c7fff18..2f2f4d2 100644 --- a/lustre/smfs/inode.c +++ b/lustre/smfs/inode.c @@ -37,36 +37,27 @@ #include #include "smfs_internal.h" -static void smfs_init_inode_info(struct inode *inode, void *opaque) +static void smfs_init_inode_info (struct inode *inode, void *opaque) { - if (!I2SMI(inode)) { - struct inode *cache_inode = NULL; - struct smfs_iget_args *sargs; - unsigned long ino; - - sargs = (struct smfs_iget_args *)opaque; - - /* getting backing fs inode. */ - ino = sargs ? sargs->s_ino : inode->i_ino; - cache_inode = iget(S2CSB(inode->i_sb), ino); - - OBD_ALLOC(inode->u.generic_ip, - sizeof(struct smfs_inode_info)); - - LASSERT(inode->u.generic_ip); - I2CI(inode) = cache_inode; - - CDEBUG(D_INODE, "cache_inode i_count ino %lu i_count %d\n", - cache_inode->i_ino, atomic_read(&cache_inode->i_count)); - - post_smfs_inode(inode, cache_inode); - sm_set_inode_ops(cache_inode, inode); + struct smfs_iget_args *sargs = (struct smfs_iget_args*)opaque; + struct inode *cache_inode = NULL; - if (sargs) { - struct inode *dir = sargs->s_inode; - if (dir) - I2SMI(inode)->smi_flags = I2SMI(dir)->smi_flags; - } + if (sargs) + cache_inode = iget(S2CSB(inode->i_sb), sargs->s_ino); + else + cache_inode = iget(S2CSB(inode->i_sb), inode->i_ino); + + OBD_ALLOC(I2SMI(inode), sizeof(struct smfs_inode_info)); + LASSERT(I2SMI(inode)); + I2CI(inode) = cache_inode; + CDEBUG(D_INODE, "cache_inode i_count ino %lu i_count %d\n", + cache_inode->i_ino, atomic_read(&cache_inode->i_count)); + post_smfs_inode(inode, cache_inode); + sm_set_inode_ops(cache_inode, inode); + if (sargs) { + struct inode *dir = sargs->s_inode; + if (dir) + I2SMI(inode)->smi_flags = I2SMI(dir)->smi_flags; } } @@ -74,19 +65,15 @@ static void smfs_clear_inode_info(struct inode *inode) { if (I2SMI(inode)) { struct inode *cache_inode = I2CI(inode); - LASSERTF(((atomic_read(&cache_inode->i_count) == 1) || - cache_inode == cache_inode->i_sb->s_root->d_inode), + cache_inode == cache_inode->i_sb->s_root->d_inode), "inode %p cache inode %p %lu i_count %d != 0 \n", - inode, cache_inode, cache_inode->i_ino, - atomic_read(&cache_inode->i_count)); - + inode, cache_inode, cache_inode->i_ino, + atomic_read(&cache_inode->i_count)); if (cache_inode != cache_inode->i_sb->s_root->d_inode) iput(cache_inode); - - OBD_FREE(inode->u.generic_ip, - sizeof(struct smfs_inode_info)); - inode->u.generic_ip = NULL; + OBD_FREE(I2SMI(inode), sizeof(struct smfs_inode_info)); + I2SMI(inode) = NULL; } } @@ -94,21 +81,20 @@ static void smfs_read_inode2(struct inode *inode, void *opaque) { ENTRY; - if (!inode) { - EXIT; + if (!inode) return; - } CDEBUG(D_INODE, "read_inode ino %lu\n", inode->i_ino); smfs_init_inode_info(inode, opaque); CDEBUG(D_INODE, "read_inode ino %lu icount %d \n", inode->i_ino, atomic_read(&inode->i_count)); EXIT; + return; } #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) static int smfs_test_inode(struct inode *inode, unsigned long ino, - void *opaque) + void *opaque) #else static int smfs_test_inode(struct inode *inode, void *opaque) #endif @@ -116,32 +102,25 @@ static int smfs_test_inode(struct inode *inode, void *opaque) struct smfs_iget_args *sargs = (struct smfs_iget_args*)opaque; LASSERT(sargs); - if (!sargs) return 1; if (inode->i_ino != sargs->s_ino) - return 0; - -#ifdef CONFIG_SNAPFS + return 0; +#ifdef CONFIG_SNAPFS if (SMFS_DO_COW(S2SMI(inode->i_sb)) && !smfs_snap_test_inode(inode, opaque)) return 0; -#endif +#endif if (I2SMI(inode)) { struct inode *cache_inode = I2CI(inode); - - /* this is needed to make symatry between smfs_put_inode(). */ - LASSERT(cache_inode != NULL); - igrab(cache_inode); - + LASSERTF(cache_inode->i_ino == inode->i_ino, "inode ino %lu != cache ino %lu", cache_inode->i_ino, inode->i_ino); - } else { - smfs_init_inode_info(inode, opaque); } - + if (!I2SMI(inode)) + smfs_init_inode_info(inode, opaque); return 1; } @@ -156,16 +135,16 @@ struct inode *smfs_iget(struct super_block *sb, ino_t hash, struct smfs_iget_args *sargs) { struct inode *inode; + LASSERT(hash != 0); - inode = iget5_locked(sb, hash, smfs_test_inode, - smfs_set_inode, sargs); + inode = iget5_locked(sb, hash, smfs_test_inode, smfs_set_inode, sargs); if (inode) { if (inode->i_state & I_NEW) unlock_new_inode(inode); - CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p) index %d " - "ino %lu \n", inode->i_ino, inode->i_generation, - inode, sargs->s_index, sargs->s_ino); + CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p) index %d ino %lu \n", + inode->i_ino, inode->i_generation, inode, sargs->s_index, + sargs->s_ino); inode->i_ino = hash; } return inode; @@ -178,8 +157,10 @@ struct inode *smfs_iget(struct super_block *sb, ino_t hash, LASSERT(hash != 0); inode = iget4(sb, hash, smfs_test_inode, sargs); + if (inode) { struct inode *cache_inode = I2CI(inode); + LASSERTF((inode->i_ino == cache_inode->i_ino), "inode %p ino %lu != cache inode %p ino %lu", inode, inode->i_ino, cache_inode, cache_inode->i_ino); @@ -189,37 +170,48 @@ struct inode *smfs_iget(struct super_block *sb, ino_t hash, return inode; } #endif - -struct inode *smfs_get_inode(struct super_block *sb, ino_t hash, - struct inode *dir, int index) +struct inode *smfs_get_inode (struct super_block *sb, ino_t hash, + struct inode *dir, int index) { - struct smfs_iget_args sargs; struct inode *inode; + struct smfs_iget_args sargs; ENTRY; - sargs.s_ino = hash; - sargs.s_inode = dir; sargs.s_index = index; + sargs.s_inode = dir; + sargs.s_ino = hash; inode = smfs_iget(sb, hash, &sargs); - + RETURN(inode); } static void smfs_delete_inode(struct inode *inode) { + struct inode *cache_inode; + ENTRY; - clear_inode(inode); - EXIT; + if (I2SMI(inode)) { + cache_inode = I2CI(inode); + if (!cache_inode || !S2CSB(inode->i_sb)) + return; + post_smfs_inode(inode, cache_inode); + smfs_clear_inode_info(inode); + } + inode->i_state = I_CLEAR; + return; } static void smfs_write_inode(struct inode *inode, int wait) { struct inode *cache_inode; - ENTRY; + ENTRY; cache_inode = I2CI(inode); - LASSERT(cache_inode != NULL); + if (!cache_inode) { + CWARN("cache inode null\n"); + return; + } pre_smfs_inode(inode, cache_inode); if (S2CSB(inode->i_sb)->s_op->write_inode) S2CSB(inode->i_sb)->s_op->write_inode(cache_inode, wait); @@ -231,13 +223,12 @@ static void smfs_write_inode(struct inode *inode, int wait) static void smfs_dirty_inode(struct inode *inode) { struct inode *cache_inode; - ENTRY; + ENTRY; cache_inode = I2CI(inode); - if (!cache_inode || !S2CSB(inode->i_sb)) { - EXIT; + + if (!cache_inode || !S2CSB(inode->i_sb)) return; - } pre_smfs_inode(inode, cache_inode); if (S2CSB(inode->i_sb)->s_op->dirty_inode) @@ -250,50 +241,57 @@ static void smfs_dirty_inode(struct inode *inode) static void smfs_put_inode(struct inode *inode) { struct inode *cache_inode; - ENTRY; + ENTRY; cache_inode = I2CI(inode); - LASSERT(cache_inode != NULL); - if (atomic_read(&cache_inode->i_count) > 1) + if (!cache_inode) { + CWARN("cache inode null\n"); + return; + } + + if (atomic_read(&cache_inode->i_count) > 1) { iput(cache_inode); - - /* - * check if we have to release backend inode. As iput() calls fs - * specific ->put_inode() first and than decrements inode rerfcount, we - * should check here ->i_count for 1, not for 0. - - * In principle we could rely on ->clear_inode(), but it will be called - * later, and thus we will have iputing of @inode and @cache_inode in - * different control paths, this is why we do it here. --umka - */ - if (atomic_read(&inode->i_count) == 1 && + } + + if (S2CSB(inode->i_sb)->s_op->put_inode) + S2CSB(inode->i_sb)->s_op->put_inode(cache_inode); + + if (atomic_read(&inode->i_count) == 0 && cache_inode->i_sb->s_root->d_inode != cache_inode) smfs_clear_inode_info(inode); EXIT; } -static void smfs_clear_inode(struct inode *inode) -{ - ENTRY; - smfs_clear_inode_info(inode); - EXIT; -} - static void smfs_write_super(struct super_block *sb) { ENTRY; - if (!S2CSB(sb)) { - EXIT; + if (!S2CSB(sb)) return; - } if (S2CSB(sb)->s_op->write_super) S2CSB(sb)->s_op->write_super(S2CSB(sb)); duplicate_sb(sb, S2CSB(sb)); EXIT; + return; +} + +static void smfs_clear_inode(struct inode *inode) +{ + struct inode *cache_inode; + + ENTRY; + + if (!inode) return; + + cache_inode = I2CI(inode); + + smfs_clear_inode_info(inode); + + EXIT; + return; } static void smfs_write_super_lockfs(struct super_block *sb) @@ -302,10 +300,8 @@ static void smfs_write_super_lockfs(struct super_block *sb) ENTRY; cache_sb = S2CSB(sb); - if (!cache_sb) { - EXIT; + if (!cache_sb) return; - } if (cache_sb->s_op->write_super_lockfs) cache_sb->s_op->write_super_lockfs(cache_sb); @@ -320,10 +316,8 @@ static void smfs_unlockfs(struct super_block *sb) ENTRY; cache_sb = S2CSB(sb); - if (!cache_sb) { - EXIT; + if (!cache_sb) return; - } if (cache_sb->s_op->unlockfs) cache_sb->s_op->unlockfs(cache_sb); @@ -350,6 +344,7 @@ static int smfs_statfs(struct super_block *sb, struct kstatfs *buf) rc = cache_sb->s_op->statfs(cache_sb, buf); duplicate_sb(sb, cache_sb); + RETURN(rc); } static int smfs_remount(struct super_block *sb, int *flags, char *data) @@ -369,7 +364,6 @@ static int smfs_remount(struct super_block *sb, int *flags, char *data) duplicate_sb(sb, cache_sb); RETURN(rc); } - struct super_operations smfs_super_ops = { #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) .read_inode2 = smfs_read_inode2, diff --git a/lustre/smfs/ioctl.c b/lustre/smfs/ioctl.c index 4faae61..f9d9c2c 100644 --- a/lustre/smfs/ioctl.c +++ b/lustre/smfs/ioctl.c @@ -168,11 +168,10 @@ static struct file_operations smfscontrol_fops = { .open = smfs_psdev_open, /* open */ .release = smfs_psdev_release, /* release */ }; - static struct miscdevice smfscontrol_dev = { - .minor = SMFS_MINOR, - .name = "smfscontrol", - .fops = &smfscontrol_fops + minor: SMFS_MINOR, + name: "smfscontrol", + fops: &smfscontrol_fops }; int init_smfs_psdev(void) diff --git a/lustre/smfs/kml.c b/lustre/smfs/kml.c index 6ddf777..81a7e1c 100644 --- a/lustre/smfs/kml.c +++ b/lustre/smfs/kml.c @@ -55,11 +55,11 @@ do { \ static smfs_pack_rec_func smfs_get_rec_pack_type(struct super_block *sb) { - int idx = 0; struct smfs_super_info *smsi = S2SMI(sb); - idx = GET_REC_PACK_TYPE_INDEX(smsi->smsi_flags); - return smsi->smsi_pack_rec[idx]; + int index = GET_REC_PACK_TYPE_INDEX(smsi->smsi_flags); + + return smsi->smsi_pack_rec[index]; } static int smfs_post_kml_rec(struct inode *dir, void *de, void *data1, @@ -78,22 +78,16 @@ static int smfs_rec_post_hook(struct inode *inode, void *dentry, } #define KML_HOOK "kml_hook" - int smfs_rec_init(struct super_block *sb) { - int rc = 0; struct smfs_super_info *smfs_info = S2SMI(sb); struct smfs_hook_ops *rec_hops = NULL; + int rc = 0; SMFS_SET_REC(smfs_info); - rc = ost_rec_pack_init(smfs_info); - if (rc) - return rc; - - rc = mds_rec_pack_init(smfs_info); - if (rc) - return rc; + ost_rec_pack_init(smfs_info); + mds_rec_pack_init(smfs_info); rec_hops = smfs_alloc_hook_ops(KML_HOOK, NULL, smfs_rec_post_hook); if (!rec_hops) { @@ -119,8 +113,7 @@ int smfs_rec_cleanup(struct smfs_super_info *smfs_info) RETURN(rc); } -static inline void copy_inode_attr(struct iattr *iattr, - struct inode *inode) +static inline void copy_inode_attr(struct iattr *iattr, struct inode *inode) { iattr->ia_mode = inode->i_mode; iattr->ia_uid = inode->i_uid; @@ -146,12 +139,11 @@ static inline int unpack_rec_data(char **p_buffer, int *size, OBD_ALLOC(*p_buffer, *size + args_len + 1); if (!*p_buffer) RETURN(-ENOMEM); - - /* first copy reint dir. */ + /*First copy reint dir */ if (args_data) memcpy(*p_buffer, args_data, args_len); - /* then copy the node name. */ + /*then copy the node name */ memcpy(*p_buffer + args_len, (in_data + sizeof(int)), *size); @@ -165,11 +157,10 @@ int smfs_rec_unpack(struct smfs_proc_args *args, char *record, { int offset = *(int *)(record); char *tmp = record + offset + sizeof(int); - + int rc = 0; *opcode = *(int *)tmp; *pbuf = tmp + sizeof(*opcode); - - return 0; + RETURN(rc); } EXPORT_SYMBOL(smfs_rec_unpack); @@ -273,7 +264,7 @@ int smfs_rec_setattr(struct inode *dir, struct dentry *dentry, } EXPORT_SYMBOL(smfs_rec_setattr); -int smfs_rec_md(struct inode *inode, void *lmm, int lmm_size) +int smfs_rec_md(struct inode *inode, void * lmm, int lmm_size) { char *set_lmm = NULL; int rc = 0; @@ -331,8 +322,9 @@ int smfs_process_rec(struct super_block *sb, if (SMFS_DO_REINT_REC(flags)) { struct llog_gen_rec *lgr; - /* for reint rec, we need insert a gen rec to identify - * the end of the rec.*/ + /*For reint rec, we need insert + *a gen rec to identify the end + *of the rec.*/ OBD_ALLOC(lgr, sizeof(*lgr)); if (!lgr) RETURN(-ENOMEM); @@ -443,8 +435,8 @@ static int smfs_pack_rec (char *buffer, struct dentry *dentry, return rc; } -int smfs_post_rec_create(struct inode *dir, struct dentry *dentry, - void *data1, void *data2) +int smfs_post_rec_create(struct inode *dir, struct dentry *dentry, void *data1, + void *data2) { struct smfs_super_info *sinfo; char *buffer = NULL, *pbuf; @@ -483,10 +475,10 @@ exit: static int smfs_post_rec_link(struct inode *dir, struct dentry *dentry, void *data1, void *data2) { - struct dentry *new_dentry = (struct dentry *)data1; - int rc = 0, length = 0, buf_len = 0; - char *buffer = NULL, *pbuf = NULL; struct smfs_super_info *sinfo; + struct dentry *old_dentry = (struct dentry *)data1; + char *buffer = NULL, *pbuf = NULL; + int rc = 0, length = 0, buf_len = 0; sinfo = S2SMI(dir->i_sb); if (!sinfo) @@ -497,7 +489,6 @@ static int smfs_post_rec_link(struct inode *dir, struct dentry *dentry, buf_len = PAGE_SIZE; KML_BUF_REC_INIT(buffer, pbuf, buf_len); - rc = smfs_log_path(dir->i_sb, dentry, pbuf, buf_len); if (rc < 0) GOTO(exit, rc); @@ -505,13 +496,13 @@ static int smfs_post_rec_link(struct inode *dir, struct dentry *dentry, length = rc; KML_BUF_REC_END(buffer, length, pbuf); - rc = smfs_pack_rec(pbuf, dentry, dir, dentry, - new_dentry, REINT_LINK); + rc = smfs_pack_rec(pbuf, dentry, dir, dentry->d_parent, + old_dentry->d_parent, REINT_LINK); if (rc <= 0) GOTO(exit, rc); - - length += rc; - rc = smfs_llog_add_rec(sinfo, (void *)buffer, length); + else + length += rc; + rc = smfs_llog_add_rec(sinfo, (void*)buffer, length); exit: if (buffer) OBD_FREE(buffer, PAGE_SIZE); @@ -583,9 +574,8 @@ static int smfs_post_rec_rename(struct inode *dir, struct dentry *dentry, pbuf += rc; length += rc; - buf_len -= rc; - - /* record new_dentry path. */ + buf_len -= rc; + /*record new_dentry path*/ rc = smfs_log_path(dir->i_sb, new_dentry, pbuf, buf_len); if (rc < 0) GOTO(exit, rc); diff --git a/lustre/smfs/mds_kml.c b/lustre/smfs/mds_kml.c index 7b9de0f..7bc87d7 100644 --- a/lustre/smfs/mds_kml.c +++ b/lustre/smfs/mds_kml.c @@ -40,56 +40,61 @@ static int mds_rec_link_pack(char *buffer, struct dentry *dentry, struct inode *dir, void *data1, void *data2) { - struct dentry *src = (struct dentry *)data1; - struct dentry *tgt = (struct dentry *)data2; + struct mdc_op_data op_data; struct mds_kml_pack_info *mkpi; + struct dentry *tgt = (struct dentry *)data1; + struct dentry *src = (struct dentry *)data2; + void *tmp = NULL; struct lustre_msg *msg = NULL; - struct mdc_op_data op_data; - void *tmp = NULL; - int rc = 0; + int rc = 0; - mdc_prepare_mdc_data(&op_data, src->d_inode, dir, - tgt->d_name.name, tgt->d_name.len, 0); + ll_prepare_mdc_op_data(&op_data, src->d_inode, dir, tgt->d_name.name, + tgt->d_name.len, 0); PACK_KML_REC_INIT(buffer, MDS_REINT); - mkpi = (struct mds_kml_pack_info *)buffer; + + mkpi = (struct mds_kml_pack_info*)buffer; mkpi->mpi_bufcount = 2; mkpi->mpi_size[0] = sizeof(struct mds_rec_link); mkpi->mpi_size[1] = op_data.namelen + 1; - /* the mds reint log format is: opcode + mkpi + request */ + /*the mds reint log format + *opcode + mkpi + request + */ msg = (struct lustre_msg *)(buffer + sizeof(*mkpi)); lustre_init_msg(msg, mkpi->mpi_bufcount, mkpi->mpi_size, NULL); tmp = mdc_link_pack(msg, 0, &op_data); - mkpi->mpi_total_size = tmp - (void *)msg; + mkpi->mpi_total_size = tmp - (void*)msg; rc = mkpi->mpi_total_size + sizeof(*mkpi) + sizeof(int); return rc; } -/* FIXME-WANGDI: did not think about EA situation. */ static int mds_rec_setattr_pack(char *buffer, struct dentry *dentry, struct inode *dir, void *data1, void *data2) { - struct iattr *iattr = (struct iattr *)data1; struct mds_rec_setattr *rec = NULL; + struct mdc_op_data op_data; struct mds_kml_pack_info *mkpi; + struct iattr *iattr = (struct iattr *)data1; struct lustre_msg *msg = NULL; - struct mdc_op_data op_data; - int rc = 0, ealen = 0; - char *ea = NULL; - void *tmp = NULL; + char *ea = NULL; + void *tmp = NULL; + int rc = 0, ealen = 0; - mdc_prepare_mdc_data(&op_data, dir, NULL, NULL, 0, 0); + ll_prepare_mdc_op_data(&op_data, dir, NULL, NULL, 0, 0); PACK_KML_REC_INIT(buffer, MDS_REINT); + mkpi = (struct mds_kml_pack_info*)buffer; + /*FIXME later, did not think about EA situation*/ + mkpi->mpi_bufcount = 1; mkpi->mpi_size[0] = sizeof(struct mds_rec_setattr); if (data2) { - mkpi->mpi_bufcount++; + mkpi->mpi_bufcount ++; mkpi->mpi_size[1] = *(int *)data2; ealen = *(int *)data2; ea = data2 + sizeof(ealen); @@ -100,8 +105,9 @@ static int mds_rec_setattr_pack(char *buffer, struct dentry *dentry, tmp = mdc_setattr_pack(msg, 0, &op_data, iattr, ea, ealen, NULL, 0); - /* FIXME-WANGDI: there are maybe some better ways to set the time - * attr. */ + /*There are maybe some better ways + *to set the time attr FIXME WANGDI later + */ rec = (struct mds_rec_setattr *)lustre_msg_buf(msg, 0, 0); if (rec->sa_valid & ATTR_CTIME) rec->sa_valid |= ATTR_CTIME_SET; @@ -110,41 +116,38 @@ static int mds_rec_setattr_pack(char *buffer, struct dentry *dentry, if (rec->sa_valid & ATTR_ATIME) rec->sa_valid |= ATTR_ATIME_SET; - mkpi->mpi_total_size = tmp - (void *)msg; + mkpi->mpi_total_size = tmp - (void*)msg; rc = mkpi->mpi_total_size + sizeof(*mkpi) + sizeof(int); return rc; } static int mds_rec_create_pack(char *buffer, struct dentry *dentry, - struct inode *dir, void *data1, - void *data2) + struct inode *dir, void *data1, void *data2) { - struct mds_kml_pack_info *mkpi; struct lustre_msg *msg = NULL; struct mdc_op_data op_data; struct mds_rec_create *rec; - int rc = 0, tgt_len = 0; - void *tmp = NULL; - - mdc_prepare_mdc_data(&op_data, dir, dentry->d_inode, - dentry->d_name.name, dentry->d_name.len, 0); + struct mds_kml_pack_info *mkpi; + void *tmp = NULL; + int rc = 0, tgt_len = 0; + ll_prepare_mdc_op_data(&op_data, dir, dentry->d_inode, + dentry->d_name.name, dentry->d_name.len, 0); PACK_KML_REC_INIT(buffer, MDS_REINT); - mkpi = (struct mds_kml_pack_info *)buffer; + mkpi = (struct mds_kml_pack_info*)buffer; mkpi->mpi_bufcount = 2; mkpi->mpi_size[0] = sizeof(struct mds_rec_create); mkpi->mpi_size[1] = op_data.namelen + 1; - if (data1 && data2) { mkpi->mpi_size[2] = *(int *)data2; mkpi->mpi_bufcount++; } if (data1) { - /* for symlink, data1 will be the tgt name. */ - tgt_len = *(int *)data2; + /*for symlink, data1 will be the tgt name */ + tgt_len = *(int*)data2; } msg = (struct lustre_msg *)(buffer + sizeof(*mkpi)); lustre_init_msg(msg, mkpi->mpi_bufcount, mkpi->mpi_size, NULL); @@ -153,32 +156,31 @@ static int mds_rec_create_pack(char *buffer, struct dentry *dentry, dentry->d_inode->i_mode, data1, tgt_len); rec = (struct mds_rec_create *)lustre_msg_buf(msg, 0, 0); - rec->cr_replayid = op_data.id2; + + rec->cr_replayfid = op_data.fid2; rec->cr_flags |= REC_REINT_CREATE; - mkpi->mpi_total_size = tmp - (void *)msg; + mkpi->mpi_total_size = tmp - (void*)msg; rc = mkpi->mpi_total_size + sizeof(*mkpi) + sizeof(int); return rc; } static int mds_rec_unlink_pack(char *buffer, struct dentry *dentry, - struct inode *dir, void *data1, - void *data2) + struct inode *dir, void *data1, void *data2) { struct lustre_msg *msg = NULL; - struct mds_kml_pack_info *mkpi; struct mdc_op_data op_data; - int mode = *(int*)data1; - void *tmp = NULL; - int rc = 0; + struct mds_kml_pack_info *mkpi; + int mode = *(int*)data1; + void *tmp = NULL; + int rc = 0; - mdc_prepare_mdc_data(&op_data, dir, NULL, - dentry->d_name.name, - dentry->d_name.len, mode); + ll_prepare_mdc_op_data(&op_data, dir, NULL, dentry->d_name.name, + dentry->d_name.len, mode); PACK_KML_REC_INIT(buffer, MDS_REINT); - mkpi = (struct mds_kml_pack_info*)buffer; + mkpi = (struct mds_kml_pack_info*)buffer; mkpi->mpi_bufcount = 2; mkpi->mpi_size[0] = sizeof(struct mds_rec_unlink); mkpi->mpi_size[1] = op_data.namelen + 1; @@ -197,20 +199,20 @@ static int mds_rec_unlink_pack(char *buffer, struct dentry *dentry, static int mds_rec_rename_pack(char *buffer, struct dentry *dentry, struct inode *dir, void *data1, void *data2) { - struct dentry *new_dentry = (struct dentry *)data2; - struct inode *new_dir = (struct inode *)data1; - struct mds_kml_pack_info *mkpi; struct lustre_msg *msg = NULL; + struct dentry *new_dir = (struct dentry *)data1; + struct dentry *new_dentry = (struct dentry *)data2; struct mdc_op_data op_data; + struct mds_kml_pack_info *mkpi; struct mds_rec_rename *rec; - void *tmp = NULL; - int rc = 0; + void *tmp = NULL; + int rc = 0; - mdc_prepare_mdc_data(&op_data, dir, new_dir, NULL, 0, 0); + ll_prepare_mdc_op_data(&op_data, dir, new_dir->d_inode, NULL, 0, 0); PACK_KML_REC_INIT(buffer, MDS_REINT); - mkpi = (struct mds_kml_pack_info*)buffer; + mkpi = (struct mds_kml_pack_info*)buffer; mkpi->mpi_bufcount = 3; mkpi->mpi_size[0] = sizeof(struct mds_rec_rename); mkpi->mpi_size[1] = dentry->d_name.len + 1; @@ -218,7 +220,6 @@ static int mds_rec_rename_pack(char *buffer, struct dentry *dentry, rec = (struct mds_rec_rename *)(buffer + sizeof(*mkpi)); - msg = (struct lustre_msg *)(buffer + sizeof(*mkpi)); lustre_init_msg(msg, mkpi->mpi_bufcount, mkpi->mpi_size, NULL); @@ -233,7 +234,6 @@ static int mds_rec_rename_pack(char *buffer, struct dentry *dentry, typedef int (*mds_pack_rec_func)(char *buffer, struct dentry *dentry, struct inode *dir, void *data1, void *data2); - static mds_pack_rec_func mds_kml_pack[REINT_MAX + 1] = { [REINT_LINK] mds_rec_link_pack, [REINT_SETATTR] mds_rec_setattr_pack, @@ -252,6 +252,7 @@ int mds_rec_pack_init(struct smfs_super_info *smsi) { smsi->smsi_pack_rec[PACK_MDS] = mds_rec_pack; + return 0; } diff --git a/lustre/smfs/ost_kml.c b/lustre/smfs/ost_kml.c index c0dd244..c334aff 100644 --- a/lustre/smfs/ost_kml.c +++ b/lustre/smfs/ost_kml.c @@ -51,7 +51,6 @@ static int smfs_ost_get_id(obd_id *id, char *data, int size) return -EINVAL; return 0; } - /* Group 0 is no longer a legal group, to catch uninitialized IDs */ #define FILTER_MIN_GROUPS 3 static int smfs_ost_get_group(struct dentry *dentry, struct obdo *oa) @@ -167,7 +166,6 @@ static int ost_rec_write_pack(char *buffer, struct dentry *dentry, out: RETURN(rc); } - typedef int (*ost_pack_rec_func)(char *buffer, struct dentry *dentry, struct inode *dir, void *data1, void *data2); static ost_pack_rec_func ost_kml_pack[REINT_MAX + 1] = { @@ -189,5 +187,6 @@ int ost_rec_pack_init(struct smfs_super_info *smsi) { smsi->smsi_pack_rec[PACK_OST] = ost_rec_pack; + return 0; } diff --git a/lustre/smfs/smfs_internal.h b/lustre/smfs/smfs_internal.h index 5b73d03..ebca06e 100644 --- a/lustre/smfs/smfs_internal.h +++ b/lustre/smfs/smfs_internal.h @@ -292,9 +292,8 @@ static inline int get_active_entry(struct inode *dir, __u64 *active_entry) #define HOOK_READDIR 12 #define HOOK_MAX 12 -#define PRE_HOOK 0 -#define POST_HOOK 1 - +#define PRE_HOOK 0 +#define POST_HOOK 1 #define SMFS_HOOK(inode, dentry, data1, data2, op, handle, flag, rc, label) \ do { \ LASSERT(inode->i_sb); \ diff --git a/lustre/smfs/smfs_lib.c b/lustre/smfs/smfs_lib.c index f47f869..b4561c7 100644 --- a/lustre/smfs/smfs_lib.c +++ b/lustre/smfs/smfs_lib.c @@ -45,9 +45,8 @@ #include #include "smfs_internal.h" -static char *smfs_options(char *data, char **devstr, - char **namestr, char *opts, - int *flags) +static char *smfs_options(char *data, char **devstr, char **namestr, + char *opts, int *flags) { struct option *opt_value = NULL; char *pos; @@ -75,7 +74,7 @@ static char *smfs_options(char *data, char **devstr, sprintf((char *)opts + strlen(opts), ",%s", opt_value->value); } else { - /* FIXME-WANGDI: how about the opt_value->value */ + /*FIXME:WANGDI How about the opt_value->value*/ if (strlen(opts) == 0) sprintf((char *)opts + strlen(opts), "%s", opt_value->opt); @@ -86,35 +85,6 @@ static char *smfs_options(char *data, char **devstr, } return pos; } - -struct super_block *smfs_get_sb_by_path(char *path, int len) -{ - struct super_block *sb; - struct nameidata nd; - int error = 0; - - ENTRY; - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - if (path_init(path, LOOKUP_FOLLOW, &nd)) { -#else - if (path_lookup(path, LOOKUP_FOLLOW, &nd)) { -#endif - error = path_walk(path, &nd); - if (error) { - path_release(&nd); - RETURN(NULL); - } - } else { - RETURN(NULL); - } - - /* FIXME-WANGDI: add some check code here. */ - sb = nd.dentry->d_sb; - path_release(&nd); - RETURN(sb); -} - static struct smfs_super_info *smfs_init_smb(struct super_block *sb) { struct smfs_super_info *smb; @@ -124,16 +94,14 @@ static struct smfs_super_info *smfs_init_smb(struct super_block *sb) if (!smb) RETURN(NULL); - S2FSI(sb) = smb; + S2SMI(sb) = smb; RETURN(smb); } - static int smfs_init_fsfilt_ops(struct smfs_super_info *smb) { ENTRY; if (!smb->sm_cache_fsfilt) { - smb->sm_cache_fsfilt = - fsfilt_get_ops(smb->smsi_cache_ftype); + smb->sm_cache_fsfilt = fsfilt_get_ops(smb->smsi_cache_ftype); if (!smb->sm_cache_fsfilt) { CERROR("Can not get %s fsfilt ops needed by kml\n", smb->smsi_cache_ftype); @@ -141,8 +109,7 @@ static int smfs_init_fsfilt_ops(struct smfs_super_info *smb) } } if (!smb->sm_fsfilt) { - smb->sm_fsfilt = - fsfilt_get_ops(smb->smsi_ftype); + smb->sm_fsfilt = fsfilt_get_ops(smb->smsi_ftype); if (!smb->sm_fsfilt) { CERROR("Can not get %s fsfilt ops needed by kml\n", smb->smsi_ftype); @@ -170,10 +137,11 @@ static int smfs_mount_cache(struct smfs_super_info *smb, char *devstr, typelen = strlen(typestr); printk("smfs: mounting %s at %s\n", typestr, devstr); + mnt = do_kern_mount(typestr, 0, devstr, (void *)opts); + if (IS_ERR(mnt)) { - CERROR("do_kern_mount failed: rc = %ld\n", - PTR_ERR(mnt)); + CERROR("do_kern_mount failed: rc = %ld\n", PTR_ERR(mnt)); GOTO(err_out, err = PTR_ERR(mnt)); } @@ -217,10 +185,11 @@ static int smfs_umount_cache(struct smfs_super_info *smb) static int smfs_init_hook_ops(struct smfs_super_info *smb) { ENTRY; + INIT_LIST_HEAD(&smb->smsi_hook_list); + RETURN(0); } - static void smfs_cleanup_hook_ops(struct smfs_super_info *smb) { struct list_head *hlist = &smb->smsi_hook_list; @@ -237,6 +206,7 @@ static void smfs_cleanup_hook_ops(struct smfs_super_info *smb) smfs_free_hook_ops(smfs_hops); } EXIT; + return; } static void smfs_cleanup_smb(struct super_block *sb) @@ -248,8 +218,8 @@ static void smfs_cleanup_smb(struct super_block *sb) if (smb) OBD_FREE(smb, sizeof(*smb)); EXIT; + return; } - void smfs_cleanup_hooks(struct smfs_super_info *smb) { @@ -273,6 +243,7 @@ void smfs_put_super(struct super_block *sb) if (sb) smfs_umount_cache(smfs_info); smfs_cleanup_smb(sb); + return; } static int smfs_init_hooks(struct super_block *sb) @@ -302,8 +273,7 @@ int smfs_fill_super(struct super_block *sb, void *data, int silent) ENTRY; - CDEBUG(D_SUPER, "mount opts: %s\n", data ? - (char *)data : "(none)"); + CDEBUG(D_SUPER, "mount opts: %s\n", data ? (char *)data : "(none)"); smb = smfs_init_smb(sb); if (!smb) @@ -312,7 +282,7 @@ int smfs_fill_super(struct super_block *sb, void *data, int silent) page = __get_free_page(GFP_KERNEL); if (!page) GOTO(out_err, err = -ENOMEM); - + memset((void *)page, 0, PAGE_SIZE); opts = (char *)page; @@ -324,17 +294,17 @@ int smfs_fill_super(struct super_block *sb, void *data, int silent) "option %s\n", cache_data); if (!typestr || !devstr) { - CERROR("mount options name and dev are mandatory\n"); + CERROR("mount options name and dev mandatory\n"); free_page(page); GOTO(out_err, err = -EINVAL); } - err = smfs_mount_cache(smb, devstr, typestr, opts); + free_page(page); if (err) { CERROR("Can not mount %s as %s\n", devstr, typestr); - GOTO(out_err, err); + GOTO(out_err, 0); } duplicate_sb(sb, smb->smsi_sb); @@ -343,11 +313,9 @@ int smfs_fill_super(struct super_block *sb, void *data, int silent) err = smfs_init_hook_ops(smb); if (err) { CERROR("Can not init super hook ops err %d\n", err); - smfs_umount_cache(smb); - GOTO(out_err, err); + GOTO(out_err, 0); } - - /* init the root_inode of smfs. */ + /*init the root_inode of smfs*/ dget(S2CSB(sb)->s_root); root_ino = S2CSB(sb)->s_root->d_inode->i_ino; root_inode = smfs_get_inode(sb, root_ino, NULL, 0); @@ -359,13 +327,13 @@ int smfs_fill_super(struct super_block *sb, void *data, int silent) if (!sb->s_root) { smfs_umount_cache(smb); - GOTO(out_err, err = -ENOMEM); + GOTO(out_err, err=-EINVAL); } err = smfs_init_hooks(sb); if (err) { smfs_umount_cache(smb); - GOTO(out_err, err); + GOTO(out_err, err=-EINVAL); } #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) CDEBUG(D_SUPER, "sb %lx, &sb->u.generic_sbp: %lx\n", @@ -380,7 +348,6 @@ out_err: smfs_cleanup_smb(sb); return err; } - struct smfs_hook_ops *smfs_alloc_hook_ops(char *name, smfs_hook_func pre_hook, smfs_hook_func post_hook) { @@ -435,7 +402,6 @@ int smfs_register_hook_ops(struct smfs_super_info *smb, list_add(&smh_ops->smh_list, hlist); RETURN(0); } - struct smfs_hook_ops *smfs_unregister_hook_ops(struct smfs_super_info *smb, char *name) { diff --git a/lustre/smfs/smfs_llog.c b/lustre/smfs/smfs_llog.c index 5e6ffe0..cfecc3e 100644 --- a/lustre/smfs/smfs_llog.c +++ b/lustre/smfs/smfs_llog.c @@ -166,7 +166,7 @@ int smfs_llog_cleanup(struct super_block *sb) RETURN(rc); } -int smfs_llog_add_rec(struct smfs_super_info *sinfo, void *data, int data_size) +int smfs_llog_add_rec(struct smfs_super_info * sinfo, void *data, int data_size) { struct llog_rec_hdr rec; int rc = 0; diff --git a/lustre/smfs/super.c b/lustre/smfs/super.c index 0f03e0f..dd92c0b 100644 --- a/lustre/smfs/super.c +++ b/lustre/smfs/super.c @@ -46,8 +46,8 @@ #include "smfs_internal.h" #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -static struct super_block *smfs_read_super(struct super_block *sb, - void *data, int silent) +static struct super_block *smfs_read_super(struct super_block *sb, void *data, + int silent) { int err; diff --git a/lustre/smfs/symlink.c b/lustre/smfs/symlink.c index 69496e5..99e839f 100644 --- a/lustre/smfs/symlink.c +++ b/lustre/smfs/symlink.c @@ -81,12 +81,12 @@ exit: } struct inode_operations smfs_sym_iops = { - .readlink = smfs_readlink, - .follow_link = smfs_follow_link, - .setxattr = smfs_setxattr, /* BKL held */ - .getxattr = smfs_getxattr, /* BKL held */ - .listxattr = smfs_listxattr, /* BKL held */ - .removexattr = smfs_removexattr, /* BKL held */ + readlink: smfs_readlink, + follow_link: smfs_follow_link, + setxattr: smfs_setxattr, /* BKL held */ + getxattr: smfs_getxattr, /* BKL held */ + listxattr: smfs_listxattr, /* BKL held */ + removexattr: smfs_removexattr, /* BKL held */ }; struct file_operations smfs_sym_fops = { diff --git a/lustre/tests/cmobd.sh b/lustre/tests/cmobd.sh deleted file mode 100644 index 35d25f1..0000000 --- a/lustre/tests/cmobd.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash - -export PATH="$PATH:`dirname $0`/../utils" - -config=${1:-cmobd.xml} -LMC=${LMC:-lmc} -TMP=${TMP:-/tmp} - -CMOBD_MDS1=${CMOBD_MDS1:-"cmobd-mds1"} -CMOBD_MDS2=${CMOBD_MDS2:-"cmobd-mds2"} - -MASTER_LMV=${MASTER_LMV1:-master-lmv1} - -CACHE_MDS1=${CACHE_MDS1:-"cache-mds1"} -CACHE_MDS2=${CACHE_MDS2:-"cache-mds2"} -MASTER_MDS1=${MASTER_MDS1:-"master-mds1"} -MASTER_MDS2=${MASTER_MDS2:-"master-mds2"} - -MDS1_CACHE_DEV=$TMP/mds1-cache-localhost -MDS2_CACHE_DEV=$TMP/mds2-cache-localhost -MDS1_MASTER_DEV=$TMP/mds1-master-localhost -MDS2_MASTER_DEV=$TMP/mds2-master-localhost - -MDS_MOUNT_OPTS=${MDS_MOUNT_OPTS:-"kml"} -OST_MOUNT_OPTS=${OST_MOUNT_OPTS:-"kml"} - -MDSSIZE=${MDSSIZE:-100000} - -MASTER_LOV=${MASTER_LOV:-"master-lov1"} -MASTER_OST=${MASTER_OST:-"master-ost1"} -OST_MASTER_DEV=$TMP/ost1-master-localhost - -OSTSIZE=${OSTSIZE:-100000} - -STRIPECNT=${STRIPECNT:-1} -OSDTYPE=${OSDTYPE:-obdfilter} -OSTFAILOVER=${OSTFAILOVER:-} - -FSTYPE=${FSTYPE:-smfs} -BACKUP_FSTYPE=${BACKUP_FSTYPE:-ext3} - -NETTYPE=${NETTYPE:-tcp} -NIDTYPE=${NIDTYPE:-$NETTYPE} - -NODE=${NODE:-"localhost"} - -CLIENTS=${CLIENTS:-1} -MODE=${MODE:-lmv} - -rm -f $config - -h2tcp () { - case $1 in - client) echo '\*' ;; - *) echo $1 ;; - esac -} - -${LMC} -m $config --add net --node $NODE --nid `h2$NIDTYPE $NODE` \ ---nettype $NETTYPE || exit 1 - -${LMC} -m $config --add mds --node $NODE --mds $CACHE_MDS1 --fstype $FSTYPE \ ---backfstype $BACKUP_FSTYPE --backdev $MDS1_CACHE_DEV --dev $FSTYPE \ ---mountfsoptions $MDS_MOUNT_OPTS --size $MDSSIZE --format || exit 10 - -if test "x$CLIENTS" = "x2"; then - ${LMC} -m $config --add mds --node $NODE --mds $CACHE_MDS2 \ - --fstype $FSTYPE --backfstype $BACKUP_FSTYPE --backdev $MDS2_CACHE_DEV \ - --dev $FSTYPE --mountfsoptions $MDS_MOUNT_OPTS --size $MDSSIZE --format || exit 10 -fi - -if test "x$MODE" = "xmds"; then - ${LMC} -m $config --add mds --node $NODE --mds $MASTER_MDS1 \ - --fstype $BACKUP_FSTYPE --dev $MDS1_MASTER_DEV --size $MDSSIZE --format || exit 10 -else - ${LMC} -m $config --add lmv --lmv $MASTER_LMV || exit 12 - - ${LMC} -m $config --add mds --node $NODE --mds $MASTER_MDS1 \ - --fstype $BACKUP_FSTYPE --dev $MDS1_MASTER_DEV --size $MDSSIZE \ - --lmv $MASTER_LMV --format || exit 10 - - ${LMC} -m $config --add mds --node $NODE --mds $MASTER_MDS2 \ - --fstype $BACKUP_FSTYPE --dev $MDS2_MASTER_DEV --size $MDSSIZE \ - --lmv $MASTER_LMV --format || exit 10 -fi - -if test "x$MODE" = "xmds"; then - ${LMC} -m $config --add lov --lov $MASTER_LOV --mds $MASTER_MDS1 \ - --stripe_sz 65536 --stripe_cnt $STRIPECNT --stripe_pattern 0 || exit 20 -else - ${LMC} -m $config --add lov --lov $MASTER_LOV --lmv $MASTER_LMV \ - --stripe_sz 65536 --stripe_cnt $STRIPECNT --stripe_pattern 0 || exit 20 -fi - -${LMC} -m $config --add ost --ost $MASTER_OST --node $NODE --lov $MASTER_LOV \ ---fstype $BACKUP_FSTYPE --dev $OST_MASTER_DEV --size $OSTSIZE || exit 21 - -if test "x$MODE" = "xmds"; then - ${LMC} -m $config --add cmobd --node $NODE --cmobd $CMOBD_MDS1 \ - --master_obd $MASTER_MDS1 --cache_obd $CACHE_MDS1 || exit 23 -else - ${LMC} -m $config --add cmobd --node $NODE --cmobd $CMOBD_MDS1 \ - --master_obd $MASTER_LMV --cache_obd $CACHE_MDS1 || exit 23 -fi - -if test "x$CLIENTS" = "x2"; then - if test "x$MODE" = "xmds"; then - ${LMC} -m $config --add cmobd --node $NODE --cmobd $CMOBD_MDS2 \ - --master_obd $MASTER_MDS1 --cache_obd $CACHE_MDS2 || exit 23 - else - ${LMC} -m $config --add cmobd --node $NODE --cmobd $CMOBD_MDS2 \ - --master_obd $MASTER_LMV --cache_obd $CACHE_MDS2 || exit 23 - fi -fi - -${LMC} -m $config --add mtpt --node $NODE --path /mnt/lustre \ ---mds $CACHE_MDS1 --lov $MASTER_LOV || exit 30 - -if test "x$CLIENTS" = "x2"; then - ${LMC} -m $config --add mtpt --node $NODE --path /mnt/lustre1 \ - --mds $CACHE_MDS2 --lov $MASTER_LOV || exit 30 -fi diff --git a/lustre/tests/cobd.sh b/lustre/tests/cobd.sh index 728407d..983df93 100755 --- a/lustre/tests/cobd.sh +++ b/lustre/tests/cobd.sh @@ -26,7 +26,7 @@ ${LMC} --add ost --node localhost --obd obd1 --fstype $FSTYPE --obdtype obdecho # configure ost ${LMC} --add ost --node localhost --obd obd2 --fstype $FSTYPE --obdtype obdecho || exit 30 -${LMC} --add cobd --node localhost --master_obd obd1 --cache_obd obd2 +${LMC} --add cobd --node localhost --real_obd obd1 --cache_obd obd2 # create client config # ${LMC} -m $config --add mtpt --node localhost --path /mnt/lustre --mds mds1 --obd obd1 || exit 40 diff --git a/lustre/tests/cobd_test.sh b/lustre/tests/cobd_test.sh index 68da2b5..08b9de8 100644 --- a/lustre/tests/cobd_test.sh +++ b/lustre/tests/cobd_test.sh @@ -1,4 +1,5 @@ -export PATH="$PATH:./../utils:/r/sbin:/r/usr/bin" +#export PATH=`dirname $0`/../utils:/r/sbin/:/r/usr/bin/:$PATH +export PATH=./../utils:/r/sbin/:/r/usr/bin/:$PATH LCTL=${LCTL:-"lctl"} TMP=${TMP:-"/tmp"} @@ -8,11 +9,11 @@ MNTPATH=${MNTPATH:-"/mnt/lustre"} TARCMD=${TARCMD:-"tar"} UNTARCMD=${UNTARCMD:-"tar -zxvf"} CPCMD=${CPCMD:-"cp -f"} -CACHEMDS=${CACHEMDS:-$TMP/mds1-`hostname`} -REALMDS=${REALMDS:-$TMP/mds3-`hostname`} +CACHEMDS=${CACHEMDS:-$TMP/mds1-uml} +REALMDS=${REALMDS:-$TMP/mds2-uml} -CACHEOST=${CACHEOST:-$TMP/ost1-`hostname`} -REALOST=${REALOST:-$TMP/ost3-`hostname`} +CACHEOST=${CACHEOST:-$TMP/ost1-uml} +REALOST=${REALOST:-$TMP/ost2-uml} MDS_CMOBD_INDEX=${MDS_CMOBD_INDEX:-12} OST_CMOBD_INDEX=${OST_CMOBD_INDEX:-14} @@ -21,8 +22,8 @@ MDS_COBD_INDEX=${MDS_COBD_INDEX:-22} OST_COBD_INDEX=${OST_COBD_INDEX:-19} -if ! [ -e "$TARBALL" ]; then - echo "$TARBALL does not exist" +if ! [ -e "$TMP/$TARBALL" ]; then + echo "$TARBALL did not exist, please give a tar ball for test in your $TMP" fi show_filesystem() { @@ -60,12 +61,14 @@ EOF } cobd_cache_on() { + ${LCTL} << EOF device $OST_COBD_INDEX cache_on device $MDS_COBD_INDEX cache_on EOF + } cobd_cache_on echo "before test ...." @@ -73,9 +76,8 @@ show_filesystem $CACHEMDS $CACHEOST #first step cp the tar to cache dev and untar it echo "cp $TARBALL to lustre dir and untar ..." -${CPCMD} ${TARBALL} ${MNTPATH} || exit 1 -${UNTARCMD} ${MNTPATH}/`basename ${TARBALL}` -C ${MNTPATH} > /dev/null || exit 2 - +${CPCMD} $TMP/${TARBALL} ${MNTPATH} || exit 1 +${UNTARCMD} ${MNTPATH}/${TARBALL} -C ${MNTPATH} > /dev/null || exit 2 #show status of the filesystem echo after cp show the filsystem.... show_filesystem $CACHEMDS $CACHEOST @@ -90,7 +92,10 @@ echo .... done! #third step and write files to real dev mkdir -p $MNTPATH/new -$CPCMD -f $TARBALL $MNTPATH/new || exit 1 -$UNTARCMD $MNTPATH/new/`basename $TARBALL` -C $MNTPATH/new > /dev/null || exit 2 +$CPCMD -f $TMP/$TARBALL $MNTPATH/new || exit 1 +$UNTARCMD $MNTPATH/new/$TARBALL -C $MNTPATH/new > /dev/null || exit 2 show_filesystem $CACHEMDS $CACHEOST echo .... done! + + + diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 586e870..0d8cbb1 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -86,7 +86,7 @@ setup() { cleanup() { umount_client $MOUNT || return 200 - stop_mds || return 201 + stop_mds || return 201 stop_ost || return 202 # catch case where these return just fine, but modules are still not unloaded /sbin/lsmod | grep -q portals diff --git a/lustre/tests/local.sh b/lustre/tests/local.sh index 13886f9..f3d7d2e 100755 --- a/lustre/tests/local.sh +++ b/lustre/tests/local.sh @@ -11,7 +11,7 @@ MDSDEV=${MDSDEV:-$TMP/mds1-`hostname`} MDSSIZE=${MDSSIZE:-400000} FSTYPE=${FSTYPE:-ext3} -OST_FSTYPE=${OST_FSTYPE:-$FSTYPE} + MOUNT=${MOUNT:-/mnt/lustre} MOUNT2=${MOUNT2:-${MOUNT}2} NETTYPE=${NETTYPE:-tcp} @@ -57,8 +57,8 @@ ${LMC} --add mds --nspath /mnt/mds_ns --node localhost --mds mds1 \ ${LMC} -m $config --add lov --lov lov1 --mds mds1 --stripe_sz $STRIPE_BYTES \ --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0 || exit 20 -${LMC} --add ost --ost ost1 --nspath /mnt/ost_ns --node localhost --lov lov1 \ ---fstype $OST_FSTYPE --backfstype $OST_BACKFSTYPE --dev $OSTDEV \ +${LMC} --add ost --nspath /mnt/ost_ns --node localhost --lov lov1 \ +--fstype $FSTYPE --backfstype $OST_BACKFSTYPE --dev $OSTDEV \ --backdev $OST_BACKDEV $OST_MOUNT_OPTS --size $OSTSIZE $JARG || exit 30 # create client config diff --git a/lustre/tests/sanity-cmobd.sh b/lustre/tests/sanity-cmobd.sh deleted file mode 100644 index d357cfa..0000000 --- a/lustre/tests/sanity-cmobd.sh +++ /dev/null @@ -1,310 +0,0 @@ -#!/bin/bash -set -e - -ONLY=${ONLY:-"$*"} -# bug number for skipped test: -ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""} -# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! - -[ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT" - -SRCDIR=`dirname $0` -export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH - -TMP=${TMP:-/tmp} -FSTYPE=${FSTYPE:-ext3} - -CHECKSTAT=${CHECKSTAT:-"checkstat -v"} -CREATETEST=${CREATETEST:-createtest} -LFS=${LFS:-lfs} -LSTRIPE=${LSTRIPE:-"$LFS setstripe"} -LFIND=${LFIND:-"$LFS find"} -LVERIFY=${LVERIFY:-ll_dirstripe_verify} -LCTL=${LCTL:-lctl} -MCREATE=${MCREATE:-mcreate} -OPENFILE=${OPENFILE:-openfile} -OPENUNLINK=${OPENUNLINK:-openunlink} -TOEXCL=${TOEXCL:-toexcl} -TRUNCATE=${TRUNCATE:-truncate} -MUNLINK=${MUNLINK:-munlink} -SOCKETSERVER=${SOCKETSERVER:-socketserver} -SOCKETCLIENT=${SOCKETCLIENT:-socketclient} -IOPENTEST1=${IOPENTEST1:-iopentest1} -IOPENTEST2=${IOPENTEST2:-iopentest2} -PTLDEBUG=${PTLDEBUG:-0} -MODE=${MODE:mds} - -if [ $UID -ne 0 ]; then - RUNAS_ID="$UID" - RUNAS="" -else - RUNAS_ID=${RUNAS_ID:-500} - RUNAS=${RUNAS:-"runas -u $RUNAS_ID"} -fi - -export NAME=${NAME:-cmobd} - -SAVE_PWD=$PWD - -clean() { - echo -n "cln.." - sh llmountcleanup.sh > /dev/null || exit 20 - I_MOUNTED=no -} -CLEAN=${CLEAN:-clean} - -start() { - echo -n "mnt.." - sh llrmount.sh > /dev/null || exit 10 - I_MOUNTED=yes - echo "done" -} -START=${START:-start} - -log() { - echo "$*" - lctl mark "$*" 2> /dev/null || true -} - -trace() { - log "STARTING: $*" - strace -o $TMP/$1.strace -ttt $* - RC=$? - log "FINISHED: $*: rc $RC" - return 1 -} -TRACE=${TRACE:-""} - -check_kernel_version() { - VERSION_FILE=/proc/fs/lustre/kernel_version - WANT_VER=$1 - [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1 - GOT_VER=`cat $VERSION_FILE` - [ $GOT_VER -ge $WANT_VER ] && return 0 - log "test needs at least kernel version $WANT_VER, running $GOT_VER" - return 1 -} - -run_one() { - if ! mount | grep -q $DIR; then - $START - fi - echo $PTLDEBUG >/proc/sys/portals/debug - log "== test $1: $2" - export TESTNAME=test_$1 - test_$1 || error "test_$1: exit with rc=$?" - unset TESTNAME - pass - cd $SAVE_PWD - $CLEAN -} - -build_test_filter() { - for O in $ONLY; do - eval ONLY_${O}=true - done - for E in $EXCEPT $ALWAYS_EXCEPT; do - eval EXCEPT_${E}=true - done -} - -_basetest() { - echo $* -} - -basetest() { - IFS=abcdefghijklmnopqrstuvwxyz _basetest $1 -} - -run_test() { - base=`basetest $1` - if [ "$ONLY" ]; then - testname=ONLY_$1 - if [ ${!testname}x != x ]; then - run_one $1 "$2" - return $? - fi - testname=ONLY_$base - if [ ${!testname}x != x ]; then - run_one $1 "$2" - return $? - fi - echo -n "." - return 0 - fi - testname=EXCEPT_$1 - if [ ${!testname}x != x ]; then - echo "skipping excluded test $1" - return 0 - fi - testname=EXCEPT_$base - if [ ${!testname}x != x ]; then - echo "skipping excluded test $1 (base $base)" - return 0 - fi - run_one $1 "$2" - return $? -} - -[ "$SANITYLOG" ] && rm -f $SANITYLOG || true - -error() { - log "FAIL: $@" - if [ "$SANITYLOG" ]; then - echo "FAIL: $TESTNAME $@" >> $SANITYLOG - else - exit 1 - fi -} - -pass() { - echo PASS -} - -MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`" -if [ -z "$MOUNT" ]; then - sh llmount.sh - MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`" - [ -z "$MOUNT" ] && error "NAME=$NAME not mounted" - I_MOUNTED=yes -fi - -[ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once" - -DIR=${DIR:-$MOUNT} -[ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99 - -[ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo -[ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo -rm -rf $DIR/[Rdfs][1-9]* - -build_test_filter - -echo preparing for tests involving mounts -EXT2_DEV=${EXT2_DEV:-/tmp/SANITY.LOOP} -touch $EXT2_DEV -mke2fs -j -F $EXT2_DEV 8000 > /dev/null - -lsync() { - name=$1 - device=`$LCTL device_list | grep " $name " | awk '{print $1}'` - - [ -z $device ] && { - echo "Can't find device $name" - return 1 - } - -${LCTL} << EOF -device $device -lsync -EOF - return $? -} - -test_1a() { - rm -fr $DIR/1a0 > /dev/null - - echo "mkdir $DIR/1a0" - mkdir $DIR/1a0 || error - echo "cache flush on $NAME" - lsync $NAME >/dev/null || error - - echo "touch $DIR/1a0/f0" - touch $DIR/1a0/f0 || error - echo "cache flush on $NAME" - lsync $NAME >/dev/null || error - - echo "chmod +x $DIR/1a0/f0" - chmod +x $DIR/1a0/f0 || error - echo "cache flush on $NAME" - lsync $NAME >/dev/null || error - - echo "mv $DIR/1a0/f0 $DIR/1a0/f01" - mv $DIR/1a0/f0 $DIR/1a0/f01 || error - echo "cache flush on $NAME" - lsync $NAME >/dev/null || error - - echo "rm $DIR/1a0/f01" - rm $DIR/1a0/f01 || error - echo "cache flush on $NAME" - lsync $NAME >/dev/null || error - - echo "touch $DIR/1a0/f01" - touch $DIR/1a0/f01 || error - echo "cache flush on $NAME" - lsync $NAME >/dev/null || error - - echo "ln $DIR/1a0/f01 $DIR/1a0/f01h" - ln $DIR/1a0/f01 $DIR/1a0/f01h || error - echo "cache flush on $NAME" - lsync $NAME >/dev/null || error - - echo "ln -s $DIR/1a0/f01 $DIR/1a0/f01s" - ln -s $DIR/1a0/f01 $DIR/1a0/f01s || error - - rm -fr $DIR/1a0 > /dev/null - echo "cache flush on $NAME" - lsync $NAME >/dev/null || error -} -run_test 1a " WB test (lsync after each MD operation)=============" - -test_1b() { - echo "mkdir $DIR/1b0" - mkdir $DIR/1b0 || error - echo "touch $DIR/1b0/f0" - touch $DIR/1b0/f0 || error - echo "chmod +x $DIR/1b0/f0" - chmod +x $DIR/1b0/f0 || error - echo "mv $DIR/1b0/f0 $DIR/1b0/f01" - mv $DIR/1b0/f0 $DIR/1b0/f01 || error - echo "rm $DIR/1b0/f01" - rm $DIR/1b0/f01 || error - echo "touch $DIR/1b0/f01" - touch $DIR/1b0/f01 || error - echo "ln $DIR/1b0/f01 $DIR/1b0/f01h" - ln $DIR/1b0/f01 $DIR/1b0/f01h || error - echo "ln -s $DIR/1b0/f01 $DIR/1b0/f01s" - ln -s $DIR/1b0/f01 $DIR/1b0/f01s || error - - rm -fr $DIR/1b0 > /dev/null - echo "cache flush on $NAME" - lsync $NAME >/dev/null || error -} -run_test 1b " WB test (lsync after bunch of MD operarions)=============" - -test_2a() { - echo "mkdir $DIR/2a0" - mkdir $DIR/2a0 || error - echo "createmany -o $DIR/2a0/f 4000" - createmany -o $DIR/2a0/f 4000 - echo "cache flush on $NAME" - lsync $NAME >/dev/null || error -} - -test_2b() { - echo "find $DIR/2a0 -type f -exec rm -f {} \;" - find $DIR/2a0 -type f -exec rm -f {} \; - rmdir $DIR/2a0 || error - echo "cache flush on $NAME" - lsync $NAME >/dev/null || error -} - -[ "x$MODE" = "xlmv" ] && { -run_test 2a " WB test (flush createmany on master LMV) ======================" -run_test 2b " WB test (flush delmany on master LMV) =========================" -} - -TMPDIR=$OLDTMPDIR -TMP=$OLDTMP -HOME=$OLDHOME - -log "cleanup: ========================================================" -if [ "`mount | grep ^$NAME`" ]; then - rm -rf $DIR/[Rdfs][1-9]* - if [ "$I_MOUNTED" = "yes" ]; then - sh llmountcleanup.sh || error - fi -fi - -echo "=========================== finished ============================" -[ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 54ac543..b6d051c 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -7,8 +7,10 @@ set -e ONLY=${ONLY:-"$*"} -# bug number for skipped test: 2739 -ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"65a 65b 65c 65d 65e 65f"} +# bug number for skipped test: 2108 3637 3561 +RENAME_TESTS="24a 24b 24c 24d 24e 24f 24g 24h 24i 24j 24k 24l 24m 24n 24o 42a 42c 45 48a 48b 48c 48d 51b 51c 65a 65b 65c 65d 65e 65f" +ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"$RENAME_TESTS 58"} + # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT" @@ -793,7 +795,7 @@ test_27c() { mkdir $DIR/d27 fi $LSTRIPE $DIR/d27/f01 65536 0 2 || error "lstripe failed" - [ `$LFIND $DIR/d27/f01 --quiet | grep [^[:blank:]*] | wc -l` -eq 2 ] || + [ `$LFIND $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] || error "two-stripe file doesn't have two stripes" pass log "== test_27d: write to two stripe file file f01 ================" @@ -1660,17 +1662,18 @@ test_48d() { # bug 2350 #set -vx mkdir -p $DIR/d48d/dir cd $DIR/d48d/dir - $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed" - $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed" - $TRACE touch foo && error "'touch foo' worked after removing parent" - $TRACE mkdir foo && error "'mkdir foo' worked after removing parent" - $TRACE ls . && error "'ls .' worked after removing parent" - $TRACE ls .. && error "'ls ..' worked after removing parent" - $TRACE cd . && error "'cd .' worked after recreate parent" - $TRACE mkdir . && error "'mkdir .' worked after removing parent" - $TRACE rmdir . && error "'rmdir .' worked after removing parent" - $TRACE ln -s . foo && error "'ln -s .' worked after removing parent" - $TRACE cd .. && error "'cd ..' worked after removing parent" || true + $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed" + $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed" + $TRACE touch foo && error "'touch foo' worked after removing parent" + $TRACE mkdir foo && error "'mkdir foo' worked after removing parent" + $TRACE ls . && error "'ls .' worked after removing parent" + $TRACE ls .. && error "'ls ..' worked after removing parent" + $TRACE cd . && error "'cd .' worked after recreate parent" + $TRACE mkdir . && error "'mkdir .' worked after removing parent" + $TRACE rmdir . && error "'rmdir .' worked after removing parent" + $TRACE ln -s . foo && error "'ln -s .' worked after removing parent" + $TRACE cd .. && error "'cd ..' worked after removing parent" || true + } run_test 48d "Access removed parent subdir (should return errors)" @@ -1868,25 +1871,25 @@ test_56() { done # test lfs find with --recursive - FILENUM=`$LFIND --recursive $DIR/d56 | grep -v OBDS | grep -c obdidx` + FILENUM=`$LFIND --recursive $DIR/d56 | grep -c obdidx` [ $FILENUM -eq $NUMFILESx2 ] || error \ "lfs find --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2" - FILENUM=`$LFIND $DIR/d56 | grep -v OBDS | grep -c obdidx` + FILENUM=`$LFIND $DIR/d56 | grep -c obdidx` [ $FILENUM -eq $NUMFILES ] || error \ "lfs find $DIR/d56 without --recursive wrong: found $FILENUM, expected $NUMFILES" echo "lfs find --recursive passed." # test lfs find with file instead of dir - FILENUM=`$LFIND $DIR/d56/file1 | grep -v OBDS | grep -c obdidx` + FILENUM=`$LFIND $DIR/d56/file1 | grep -c obdidx` [ $FILENUM -eq 1 ] || error \ - "lfs find $DIR/d56/file1 wrong: found $FILENUM, expected 1" + "lfs find $DIR/d56/file1 wrong:found $FILENUM, expected 1" echo "lfs find file passed." #test lfs find with --verbose - [ `$LFIND --verbose $DIR/d56 | grep -v OBDS | grep -c lmm_magic` -eq $NUMFILES ] ||\ + [ `$LFIND --verbose $DIR/d56 | grep -c lmm_magic` -eq $NUMFILES ] ||\ error "lfs find --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info" - [ `$LFIND $DIR/d56 | grep -v OBDS | grep -c lmm_magic` -eq 0 ] || error \ + [ `$LFIND $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \ "lfs find $DIR/d56 without --verbose wrong: should not show lmm_magic info" echo "lfs find --verbose passed." @@ -1896,17 +1899,14 @@ test_56() { [ "$OSTCOUNT" -lt 2 ] && \ echo "skipping other lfs find --obd test" && return - FILENUM=`$LFIND --recursive $DIR/d56 | grep -v OBDS | grep obdidx | wc -l` - OBDUUID=`$LFIND --recursive $DIR/d56 | grep -A 1 OBDS | grep -v OBDS | awk '{print $3}'` - OBDIDX=`$LFIND --recursive $DIR/d56 | grep -A 1 OBDS | grep -v OBDS | awk '{print $1}'` - FOUND=`$LFIND --recursive --obd $OBDUUID $DIR/d56 | wc -l` - + FILENUM=`$LFIND --recursive $DIR/d56 | sed -n '/^[ ]*1[ ]/p' | wc -l` + OBDUUID=`$LFIND --recursive $DIR/d56 | sed -n '/^[ ]*1:/p' | awk '{print $2}'` + FOUND=`$LFIND -r --obd $OBDUUID $DIR/d56 | wc -l` [ $FOUND -eq $FILENUM ] || \ error "lfs find --obd wrong: found $FOUND, expected $FILENUM" - - [ `$LFIND -r -v --obd $OBDUUID $DIR/d56 | grep "^[[:blank:]]*$OBDIDX" | wc -l` ] || \ + [ `$LFIND -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' | \ + sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \ error "lfs find --obd wrong: should not show file on other obd" - echo "lfs find --obd passed." } run_test 56 "check lfs find ====================================" diff --git a/lustre/tests/uml_cobd.sh b/lustre/tests/uml_cobd.sh index 966ac1e..7e6ee93 100644 --- a/lustre/tests/uml_cobd.sh +++ b/lustre/tests/uml_cobd.sh @@ -12,20 +12,21 @@ COBD_OST=${COBD_OST:-"cobd2"} CMOBD_MDS=${CMOBD_MDS:-"cmobd1"} CMOBD_OST=${CMOBD_OST:-"cmobd2"} + CACHE_MDS=${CACHE_MDS:-"mds1"} -MASTER_MDS=${MASTER_MDS:-"mds2"} +REAL_MDS=${REAL_MDS:-"mds2"} MDS_CACHE_DEV=$TMP/mds1-`hostname` -MDS_MASTER_DEV=$TMP/mds2-`hostname` +MDS_REAL_DEV=$TMP/mds2-`hostname` MDS_DEV=$TMP/mds MDSSIZE=${MDSSIZE:-100000} CACHE_LOV=${CACHE_LOV:-"lov1"} -MASTER_LOV=${MASTER_LOV:-"lov2"} +REAL_LOV=${REAL_LOV:-"lov2"} CACHE_OST=${CACHE_OST:-"ost1"} -MASTER_OST=${MASTER_OST:-"ost2"} +REAL_OST=${REAL_OST:-"ost2"} OST_CACHE_DEV=$TMP/ost1-`hostname` -OST_MASTER_DEV=$TMP/ost2-`hostname` +OST_REAL_DEV=$TMP/ost2-`hostname` OST_DEV=$TMP/ost OSTSIZE=${OSTSIZE:-100000} @@ -40,10 +41,10 @@ BACKUP_FSTYPE=${BACKUP_FSTYPE:-ext3} NETTYPE=${NETTYPE:-tcp} NIDTYPE=${NIDTYPE:-$NETTYPE} -MDSNODE=${MDSNODE:-`hostname`} -OSTNODE=${OSTNODE:-`hostname`} -CLIENT=${CLIENT:-`hostname`} -NODE=${NODE:-`hostname`} +MDSNODE=${MDSNODE:-uml} +OSTNODE=${OSTNODE:-uml} +CLIENT=${CLIENT:-"uml"} +NODE=${NODE:-"uml"} MDS_MOUNT_OPTS=${MDS_MOUNT_OPTS:-"kml"} OST_MOUNT_OPTS=${OST_MOUNT_OPTS:-"kml"} @@ -64,20 +65,19 @@ ${LMC} -m $config --add net --node $NODE --nid `h2$NIDTYPE $NODE` --nettype $NET # configure mds server echo "adding cache MDS on: $MDSNODE" -${LMC} -m $config --format --add mds --node $MDSNODE --mds $CACHE_MDS --fstype $FSTYPE \ +${LMC} -m $config --add mds --format --node $MDSNODE --mds $CACHE_MDS --fstype $FSTYPE \ --backfstype $BACKUP_FSTYPE --dev $MDS_DEV --backdev $MDS_CACHE_DEV \ --mountfsoptions $MDS_MOUNT_OPTS --size $MDSSIZE ||exit 10 -echo "adding master MDS on: $MDSNODE" -${LMC} -m $config --format --add mds --node $MDSNODE --mds $MASTER_MDS --fstype $BACKUP_FSTYPE \ ---dev $MDS_MASTER_DEV --size $MDSSIZE ||exit 10 +echo "adding real MDS on: $MDSNODE" +${LMC} -m $config --add mds --format --node $MDSNODE --mds $REAL_MDS --fstype $BACKUP_FSTYPE \ +--dev $MDS_REAL_DEV --size $MDSSIZE ||exit 10 echo "add cache lov on: $MDSNODE" ${LMC} -m $config --add lov --lov $CACHE_LOV --mds $CACHE_MDS \ --stripe_sz 65536 --stripe_cnt $STRIPECNT --stripe_pattern 0 || exit 20 - -echo "add master lov on: $MDSNODE" -${LMC} -m $config --add lov --lov $MASTER_LOV --mds $MASTER_MDS \ +echo "add real lov on: $MDSNODE" +${LMC} -m $config --add lov --lov $REAL_LOV --mds $REAL_MDS \ --stripe_sz 65536 --stripe_cnt $STRIPECNT --stripe_pattern 0 || exit 20 echo "add cache ost on $OSTNODE" @@ -85,17 +85,17 @@ ${LMC} -m $config --add ost --node $NODE --lov $CACHE_LOV \ --fstype $FSTYPE --backfstype $BACKUP_FSTYPE --dev $OST_DEV \ --backdev $OST_CACHE_DEV --mountfsoptions $OST_MOUNT_OPTS --size $OSTSIZE || exit 21 -echo "add master ost on $OSTNODE" -${LMC} -m $config --add ost --node $NODE --lov $MASTER_LOV \ ---fstype $BACKUP_FSTYPE --dev $OST_MASTER_DEV --size $OSTSIZE || exit 21 +echo "add real ost on $OSTNODE" +${LMC} -m $config --add ost --node $NODE --lov $REAL_LOV \ +--fstype $BACKUP_FSTYPE --dev $OST_REAL_DEV --size $OSTSIZE || exit 21 echo "add mds lov: $COBD_MDS $COBD_OST" -${LMC} -m $config --add cobd --node $NODE --cobd $COBD_OST --master_obd $MASTER_LOV --cache_obd $CACHE_LOV || exit 22 -${LMC} -m $config --add cobd --node $NODE --cobd $COBD_MDS --master_obd $MASTER_MDS --cache_obd $CACHE_MDS || exit 22 +${LMC} -m $config --add cobd --node $NODE --cobd $COBD_OST --real_obd $REAL_LOV --cache_obd $CACHE_LOV || exit 22 +${LMC} -m $config --add cobd --node $NODE --cobd $COBD_MDS --real_obd $REAL_MDS --cache_obd $CACHE_MDS || exit 22 # create client config(s) echo "add cmobd: $CMOBD_MDS $CMOBD_OST" -${LMC} -m $config --add cmobd --node $NODE --cmobd $CMOBD_OST --master_obd $MASTER_LOV --cache_obd $CACHE_LOV || exit 23 -${LMC} -m $config --add cmobd --node $NODE --cmobd $CMOBD_MDS --master_obd $MASTER_MDS --cache_obd $CACHE_MDS || exit 23 +${LMC} -m $config --add cmobd --node $NODE --cmobd $CMOBD_MDS --master_dev $MDS_REAL_DEV --cache_dev $MDS_DEV || exit 23 +${LMC} -m $config --add cmobd --node $NODE --cmobd $CMOBD_OST --master_dev $OST_REAL_DEV --cache_dev $OST_DEV || exit 23 ${LMC} -m $config --add mtpt --node $NODE --path /mnt/lustre --mds $COBD_MDS --lov $COBD_OST || exit 30 diff --git a/lustre/utils/lconf b/lustre/utils/lconf index 53c032d..828db61 100755 --- a/lustre/utils/lconf +++ b/lustre/utils/lconf @@ -737,6 +737,17 @@ def do_find_file(base, mod): if module: return module +def find_module(src_dir, dev_dir, modname): + modbase = src_dir +'/'+ dev_dir +'/'+ modname + for modext in '.ko', '.o': + module = modbase + modext + try: + if os.access(module, os.R_OK): + return module + except OSError: + pass + return None + # is the path a block device? def is_block(path): s = () @@ -884,6 +895,8 @@ def find_assigned_loop(file): m = re.search(r'\((.*)\)', out[0]) if m and file == m.group(1): return dev + else: + break return '' # create file if necessary and assign the first free loop device @@ -892,9 +905,8 @@ def init_loop(file, size, fstype, journal_size, inode_size, if fstype == 'smfs': realfile = backfile realfstype = backfstype - - if is_block(realfile): - if reformat or (need_format(realfstype, realfile) and autoformat == 'yes'): + if is_block(backfile): + if reformat or (need_format(realfstype, backfile) and autoformat == 'yes'): mkfs(realfile, size, realfstype, journal_size, inode_size, mkfsoptions, isblock=0) return realfile else: @@ -903,21 +915,20 @@ def init_loop(file, size, fstype, journal_size, inode_size, dev = find_assigned_loop(realfile) if dev: - print 'WARNING: file ', realfile, 'already mapped to', dev + print 'WARNING file:', realfile, 'already mapped to', dev return dev - + if reformat or not os.access(realfile, os.R_OK | os.W_OK): if size < 8000: panic("size of loopback file '%s' must be larger than 8MB, but is set to %s" % (realfile, size)) (ret, out) = run("dd if=/dev/zero bs=1k count=0 seek=%d of=%s" %(size, realfile)) if ret: - panic("Unable to create backing store: ", realfile) + panic("Unable to create backing store:", realfile) mkfs(realfile, size, realfstype, journal_size, inode_size, mkfsoptions, isblock=0) loop = loop_base() - # find next free loop for n in xrange(0, MAX_LOOP_DEVICES): dev = loop + str(n) @@ -925,7 +936,6 @@ def init_loop(file, size, fstype, journal_size, inode_size, (stat, out) = run('losetup', dev) if stat: run('losetup', dev, realfile) - print "attach " + realfile + " <-> " + dev return dev else: print "out of loop devices" @@ -934,31 +944,19 @@ def init_loop(file, size, fstype, journal_size, inode_size, return '' # undo loop assignment -def clean_loop(dev, fstype, backfstype, backdev): - if fstype == 'smfs': - realfile = backdev - else: - realfile = dev - - if not is_block(realfile): - dev = find_assigned_loop(realfile) - if dev: - print "detach " + dev + " <-> " + realfile - ret, out = run('losetup -d', dev) - if ret: - log('unable to clean loop device:', dev, 'for file:', realfile) - logall(out) +def clean_loop(file): + dev = find_assigned_loop(file) + if dev: + ret, out = run('losetup -d', dev) + if ret: + log('unable to clean loop device:', dev, 'for file:', file) + logall(out) # determine if dev is formatted as a filesystem def need_format(fstype, dev): # FIXME don't know how to implement this return 0 -# finilizes passed device -def clean_dev(dev, fstype, backfstype, backdev): - if fstype == 'smfs' or not is_block(dev): - clean_loop(dev, fstype, backfstype, backdev) - # initialize a block device if needed def block_dev(dev, size, fstype, reformat, autoformat, journal_size, inode_size, mkfsoptions, backfstype, backdev): @@ -1068,6 +1066,19 @@ def sys_get_branch(): return "" +def mod_loaded(modname): + """Check if a module is already loaded. Look in /proc/modules for it.""" + try: + fp = open('/proc/modules') + lines = fp.readlines() + fp.close() + # please forgive my tired fingers for this one + ret = filter(lambda word, mod=modname: word == mod, + map(lambda line: string.split(line)[0], lines)) + return ret + except Exception, e: + return 0 + # XXX: instead of device_list, ask for $name and see what we get def is_prepared(name): """Return true if a device exists for the name""" @@ -1086,7 +1097,7 @@ def is_prepared(name): e.dump() return 0 -def network_is_prepared(): +def is_network_prepared(): """If the any device exists, then assume that all networking has been configured""" out = lctl.device_list() @@ -1106,153 +1117,55 @@ def fs_is_mounted(path): log(e) return 0 -def kmod_find(src_dir, dev_dir, modname): - modbase = src_dir +'/'+ dev_dir +'/'+ modname - for modext in '.ko', '.o': - module = modbase + modext - try: - if os.access(module, os.R_OK): - return module - except OSError: - pass - return None - -def kmod_info(modname): - """Returns reference count for passed module name.""" - try: - fp = open('/proc/modules') - lines = fp.readlines() - fp.close() - - # please forgive my tired fingers for this one - ret = filter(lambda word, mod = modname: word[0] == mod, - map(lambda line: string.split(line), lines)) - if not ret: - return '' - return ret[0] - except Exception, e: - return 0 class kmod: - """Presents kernel module""" - def __init__(self, src_dir, dev_dir, name): - self.src_dir = src_dir - self.dev_dir = dev_dir - self.name = name - - def load(self): - """Load module""" - log ('loading module:', self.name, 'srcdir', - self.src_dir, 'devdir', self.dev_dir) - if self.src_dir: - module = kmod_find(self.src_dir, self.dev_dir, - self.name) - if not module: - panic('module not found:', self.name) - (rc, out) = run('/sbin/insmod', module) - if rc: - raise CommandError('insmod', out, rc) - else: - (rc, out) = run('/sbin/modprobe', self.name) - if rc: - raise CommandError('modprobe', out, rc) - - def cleanup(self): - """Unload module""" - log('unloading module:', self.name) - (rc, out) = run('/sbin/rmmod', self.name) - if rc: - log('unable to unload module:', self.name + - "(" + self.refcount() + ")") - logall(out) - - def info(self): - """Returns module info if any.""" - return kmod_info(self.name) - - def loaded(self): - """Returns 1 if module is loaded. Otherwise 0 is returned.""" - if self.info(): - return 1 - else: - return 0 - - def refcount(self): - """Returns module refcount.""" - info = self.info() - if not info: - return '' - return info[2] - - def used(self): - """Returns 1 if module is used, otherwise 0 is returned.""" - info = self.info() - if not info: - return 0 - if len(info) > 3: - users = info[3] - if users and users != '(unused)' and users != '-': - return 1 - else: - return 0 - else: - return 0 - - def busy(self): - """Returns 1 if module is busy, otherwise 0 is returned.""" - if self.loaded() and (self.used() or self.refcount() != '0'): - return 1 - else: - return 0 - -class kmod_manager: """Manage kernel modules""" def __init__(self, lustre_dir, portals_dir): self.lustre_dir = lustre_dir self.portals_dir = portals_dir self.kmodule_list = [] - def find_module(self, modname): - """Find module by module name""" - for mod in self.kmodule_list: - if mod.name == modname: - return mod - return '' - def add_portals_module(self, dev_dir, modname): """Append a module to list of modules to load.""" - - mod = self.find_module(modname) - if not mod: - mod = kmod(self.portals_dir, dev_dir, modname) - self.kmodule_list.append(mod) + self.kmodule_list.append((self.portals_dir, dev_dir, modname)) def add_lustre_module(self, dev_dir, modname): """Append a module to list of modules to load.""" + self.kmodule_list.append((self.lustre_dir, dev_dir, modname)) - mod = self.find_module(modname) - if not mod: - mod = kmod(self.lustre_dir, dev_dir, modname) - self.kmodule_list.append(mod) - - def load_modules(self): + def load_module(self): """Load all the modules in the list in the order they appear.""" - for mod in self.kmodule_list: - if mod.loaded() and not config.noexec: + for src_dir, dev_dir, mod in self.kmodule_list: + if mod_loaded(mod) and not config.noexec: continue - mod.load() + log ('loading module:', mod, 'srcdir', src_dir, 'devdir', dev_dir) + if src_dir: + module = find_module(src_dir, dev_dir, mod) + if not module: + panic('module not found:', mod) + (rc, out) = run('/sbin/insmod', module) + if rc: + raise CommandError('insmod', out, rc) + else: + (rc, out) = run('/sbin/modprobe', mod) + if rc: + raise CommandError('modprobe', out, rc) - def cleanup_modules(self): + def cleanup_module(self): """Unload the modules in the list in reverse order.""" rev = self.kmodule_list rev.reverse() - for mod in rev: - if (not mod.loaded() or mod.busy()) and not config.noexec: + for src_dir, dev_dir, mod in rev: + if not mod_loaded(mod) and not config.noexec: continue # debug hack - if mod.name == 'portals' and config.dump: + if mod == 'portals' and config.dump: lctl.dump(config.dump) - mod.cleanup() + log('unloading module:', mod) + (rc, out) = run('/sbin/rmmod', mod) + if rc: + log('! unable to unload module:', mod) + logall(out) # ============================================================ # Classes to prepare and cleanup the various objects @@ -1268,7 +1181,7 @@ class Module: self.uuid = self.db.getUUID() self._server = None self._connected = 0 - self.kmod_manager = mod_manager + self.kmod = kmod(config.lustre, config.portals) def info(self, *args): msg = string.join(map(str,args)) @@ -1284,9 +1197,22 @@ class Module: e.dump() cleanup_error(e.rc) - def add_module(self, manager): - """Adds all needed modules in the order they appear.""" - return + def add_portals_module(self, dev_dir, modname): + """Append a module to list of modules to load.""" + self.kmod.add_portals_module(dev_dir, modname) + + def add_lustre_module(self, dev_dir, modname): + """Append a module to list of modules to load.""" + self.kmod.add_lustre_module(dev_dir, modname) + + def load_module(self): + """Load all the modules in the list in the order they appear.""" + self.kmod.load_module() + + def cleanup_module(self): + """Unload the modules in the list in reverse order.""" + if self.safe_to_clean(): + self.kmod.cleanup_module() def safe_to_clean(self): return 1 @@ -1320,15 +1246,14 @@ class Network(Module): panic("unable to set hostaddr for", self.net_type, self.hostaddr, self.cluster_id) debug("hostaddr:", self.hostaddr) - def add_module(self, manager): - manager.add_portals_module("libcfs", 'libcfs') - manager.add_portals_module("portals", 'portals') + self.add_portals_module("libcfs", 'libcfs') + self.add_portals_module("portals", 'portals') if node_needs_router(): - manager.add_portals_module("router", 'kptlrouter') + self.add_portals_module("router", 'kptlrouter') if self.net_type == 'tcp': - manager.add_portals_module("knals/socknal", 'ksocknal') + self.add_portals_module("knals/socknal", 'ksocknal') if self.net_type == 'elan': - manager.add_portals_module("knals/qswnal", 'kqswnal') + self.add_portals_module("knals/qswnal", 'kqswnal') if self.net_type == 'gm': self.add_portals_module("knals/gmnal", 'kgmnal') if self.net_type == 'openib': @@ -1338,7 +1263,7 @@ class Network(Module): return "NID_%s_UUID" %(nid,) def prepare(self): - if not config.record and network_is_prepared(): + if not config.record and is_network_prepared(): return self.info(self.net_type, self.nid, self.port) if not (config.record and self.generic_nid): @@ -1379,7 +1304,7 @@ class Network(Module): cleanup_error(e.rc) def safe_to_clean(self): - return not network_is_prepared() + return not is_network_prepared() def cleanup(self): self.info(self.net_type, self.nid, self.port) @@ -1422,7 +1347,7 @@ class RouteTable(Module): return Network(srvdb) def prepare(self): - if not config.record and network_is_prepared(): + if not config.record and is_network_prepared(): return self.info() for net_type, gw, gw_cluster_id, tgt_cluster_id, lo, hi in self.db.get_route_tbl(): @@ -1432,10 +1357,10 @@ class RouteTable(Module): lctl.connect(srv) def safe_to_clean(self): - return not network_is_prepared() + return not is_network_prepared() def cleanup(self): - if network_is_prepared(): + if is_network_prepared(): # the network is still being used, don't clean it up return for net_type, gw, gw_cluster_id, tgt_cluster_id, lo, hi in self.db.get_route_tbl(): @@ -1455,42 +1380,14 @@ class RouteTable(Module): e.dump() cleanup_error(e.rc) -class Management(Module): - def __init__(self, db): - Module.__init__(self, 'MGMT', db) - - def add_module(self, manager): - manager.add_lustre_module('lvfs', 'lvfs') - manager.add_lustre_module('obdclass', 'obdclass') - manager.add_lustre_module('ptlrpc', 'ptlrpc') - manager.add_lustre_module('mgmt', 'mgmt_svc') - - def prepare(self): - if not config.record and is_prepared(self.name): - return - self.info() - lctl.newdev("mgmt", self.name, self.uuid) - - def safe_to_clean(self): - return 1 - - def cleanup(self): - if is_prepared(self.name): - Module.cleanup(self) - - def correct_level(self, level, op=None): - return level - # This is only needed to load the modules; the LDLM device # is now created automatically. class LDLM(Module): def __init__(self,db): Module.__init__(self, 'LDLM', db) - - def add_module(self, manager): - manager.add_lustre_module('lvfs', 'lvfs') - manager.add_lustre_module('obdclass', 'obdclass') - manager.add_lustre_module('ptlrpc', 'ptlrpc') + self.add_lustre_module('lvfs', 'lvfs') + self.add_lustre_module('obdclass', 'obdclass') + self.add_lustre_module('ptlrpc', 'ptlrpc') def prepare(self): return @@ -1501,11 +1398,13 @@ class LDLM(Module): def correct_level(self, level, op=None): return level + class LOV(Module): def __init__(self, db, uuid, fs_name, name_override = None, config_only = None): Module.__init__(self, 'LOV', db) if name_override != None: self.name = "lov_%s" % name_override + self.add_lustre_module('lov', 'lov') self.mds_uuid = self.db.get_first_ref('mds') self.stripe_sz = self.db.get_val_int('stripesize', 1048576) self.stripe_off = self.db.get_val_int('stripeoffset', 0) @@ -1567,13 +1466,22 @@ class LOV(Module): if self.config_only: panic("Can't clean up config_only LOV ", self.name) - def add_module(self, manager): + def load_module(self): if self.config_only: panic("Can't load modules for config_only LOV ", self.name) for (osc, index, gen, active) in self.osclist: - osc.add_module(manager) + osc.load_module() + break + Module.load_module(self) + + def cleanup_module(self): + if self.config_only: + panic("Can't cleanup modules for config_only LOV ", self.name) + Module.cleanup_module(self) + for (osc, index, gen, active) in self.osclist: + if active: + osc.cleanup_module() break - manager.add_lustre_module('lov', 'lov') def correct_level(self, level, op=None): return level @@ -1583,12 +1491,12 @@ class LMV(Module): Module.__init__(self, 'LMV', db) if name_override != None: self.name = "lmv_%s" % name_override + self.add_lustre_module('lmv', 'lmv') self.devlist = self.db.get_refs('mds') self.mdclist = [] self.desc_uuid = self.uuid self.uuid = uuid self.fs_name = fs_name - for mds_uuid in self.devlist: mds = self.db.lookup(mds_uuid) if not mds: @@ -1602,8 +1510,6 @@ class LMV(Module): def prepare(self): if is_prepared(self.name): return - - self.info(self.name) for mdc in self.mdclist: try: # Only ignore connect failures with --force, which @@ -1621,11 +1527,17 @@ class LMV(Module): if is_prepared(self.name): Module.cleanup(self) - def add_module(self, manager): + def load_module(self): + for mdc in self.mdclist: + mdc.load_module() + break + Module.load_module(self) + + def cleanup_module(self): + Module.cleanup_module(self) for mdc in self.mdclist: - mdc.add_module(manager) + mdc.cleanup_module() break - manager.add_lustre_module('lmv', 'lmv') def correct_level(self, level, op=None): return level @@ -1642,135 +1554,128 @@ class MDSDEV(Module): self.nspath = self.db.get_val('nspath', '') self.mkfsoptions = self.db.get_val('mkfsoptions', '') self.mountfsoptions = self.db.get_val('mountfsoptions', '') - self.obdtype = self.db.get_val('obdtype', '') self.root_squash = self.db.get_val('root_squash', '') self.no_root_squash = self.db.get_val('no_root_squash', '') + self.cachetype = self.db.get_val('cachetype', '') # overwrite the orignal MDSDEV name and uuid with the MDS name and uuid target_uuid = self.db.get_first_ref('target') - self.mds = self.db.lookup(target_uuid) - self.name = self.mds.getName() - self.client_uuids = self.mds.get_refs('client') - - # LMV instance - self.lmv_uuid = "" + mds = self.db.lookup(target_uuid) + self.name = mds.getName() + self.filesystem_uuids = mds.get_refs('filesystem') + self.lmv_uuid = '' self.lmv = '' - - self.master_uuid = "" - self.master = '' - - # it is possible to have MDS with no clients. It is master MDS - # in configuration with CMOBD. - self.lmv_uuid = self.db.get_first_ref('lmv') - if self.lmv_uuid: - self.lmv = self.db.lookup(self.lmv_uuid) - if self.lmv: - self.client_uuids = self.lmv.get_refs('client') - self.master_uuid = self.lmv_uuid - + self.master_mds = "" + if not self.filesystem_uuids: + self.lmv_uuid = self.db.get_first_ref('lmv') + if not self.lmv_uuid: + panic("ALERT: can't find lvm uuid") + if self.lmv_uuid: + self.lmv = self.db.lookup(self.lmv_uuid) + if self.lmv: + self.filesystem_uuids = self.lmv.get_refs('filesystem') + self.master_mds = self.lmv_uuid # FIXME: if fstype not set, then determine based on kernel version self.format = self.db.get_val('autoformat', "no") - if self.mds.get_val('failover', 0): + if mds.get_val('failover', 0): self.failover_mds = 'f' else: self.failover_mds = 'n' - active_uuid = get_active_target(self.mds) + active_uuid = get_active_target(mds) if not active_uuid: panic("No target device found:", target_uuid) if active_uuid == self.uuid: self.active = 1 else: self.active = 0 - if self.active and config.group and config.group != self.mds.get_val('group'): + if self.active and config.group and config.group != mds.get_val('group'): self.active = 0 - # default inode inode for case when neither LOV either - # LMV is accessible. - self.inode_size = 256 - - inode_size = self.db.get_val_int('inodesize', 0) - if not inode_size == 0: - self.inode_size = inode_size - else: + self.inode_size = self.db.get_val_int('inodesize', 0) + if self.inode_size == 0: # find the LOV for this MDS - lovconfig_uuid = self.mds.get_first_ref('lovconfig') - if lovconfig_uuid or self.lmv: - if self.lmv: - lovconfig_uuid = self.lmv.get_first_ref('lovconfig') - lovconfig = self.lmv.lookup(lovconfig_uuid) - lov_uuid = lovconfig.get_first_ref('lov') - if not lov_uuid: - panic(self.mds.getName() + ": No LOV found for lovconfig ", - lovconfig.name) - else: - lovconfig = self.mds.lookup(lovconfig_uuid) - lov_uuid = lovconfig.get_first_ref('lov') - if not lov_uuid: - panic(self.mds.getName() + ": No LOV found for lovconfig ", - lovconfig.name) - - if self.lmv: - lovconfig_uuid = self.lmv.get_first_ref('lovconfig') - lovconfig = self.lmv.lookup(lovconfig_uuid) - lov_uuid = lovconfig.get_first_ref('lov') - - lov = LOV(self.db.lookup(lov_uuid), lov_uuid, 'FS_name', - config_only = 1) - - # default stripe count controls default inode_size + lovconfig_uuid = mds.get_first_ref('lovconfig') + if not lovconfig_uuid: + if not self.lmv_uuid: + panic("No LOV found for lovconfig ", lovconfig.name) + + if not self.lmv: + panic("No LMV initialized and not lovconfig_uuid found") + + lovconfig_uuid = self.lmv.get_first_ref('lovconfig') + lovconfig = self.lmv.lookup(lovconfig_uuid) + lov_uuid = lovconfig.get_first_ref('lov') + if not lov_uuid: + panic("No LOV found for lovconfig ", lovconfig.name) + else: + lovconfig = mds.lookup(lovconfig_uuid) + lov_uuid = lovconfig.get_first_ref('lov') + if not lov_uuid: + panic("No LOV found for lovconfig ", lovconfig.name) + + if self.lmv: + lovconfig_uuid = self.lmv.get_first_ref('lovconfig') + lovconfig = self.lmv.lookup(lovconfig_uuid) + lov_uuid = lovconfig.get_first_ref('lov') + + lov = LOV(self.db.lookup(lov_uuid), lov_uuid, 'FS_name', config_only = 1) + + # default stripe count controls default inode_size + if (lov.stripe_cnt > 0): stripe_count = lov.stripe_cnt - if stripe_count > 77: - self.inode_size = 4096 - elif stripe_count > 35: - self.inode_size = 2048 - elif stripe_count > 13: - self.inode_size = 1024 - elif stripe_count > 3: - self.inode_size = 512 - else: - self.inode_size = 256 + else: + stripe_count = len(lov.devlist) + + if stripe_count > 77: + self.inode_size = 4096 + elif stripe_count > 35: + self.inode_size = 2048 + elif stripe_count > 13: + self.inode_size = 1024 + elif stripe_count > 3: + self.inode_size = 512 + else: + self.inode_size = 256 self.target_dev_uuid = self.uuid self.uuid = target_uuid - # setup LMV - if self.master_uuid: + if self.master_mds: + client_uuid = generate_client_uuid(self.name) client_uuid = self.name + "_lmv_" + "UUID" - self.master = LMV(self.db.lookup(self.lmv_uuid), client_uuid, - self.name, self.name) - self.master_uuid = self.master.name + self.master = LMV(self.db.lookup(self.lmv_uuid), client_uuid, self.name, self.name) + self.master_mds = self.master.name - def add_module(self, manager): - if self.active: - manager.add_lustre_module('mdc', 'mdc') - manager.add_lustre_module('osc', 'osc') - manager.add_lustre_module('ost', 'ost') - manager.add_lustre_module('lov', 'lov') - manager.add_lustre_module('mds', 'mds') + # modules + self.add_lustre_module('mdc', 'mdc') + self.add_lustre_module('osc', 'osc') + self.add_lustre_module('lov', 'lov') + self.add_lustre_module('lmv', 'lmv') + self.add_lustre_module('ost', 'ost') + self.add_lustre_module('mds', 'mds') - if self.fstype == 'smfs': - manager.add_lustre_module('smfs', 'smfs') + if self.fstype == 'smfs': + self.add_lustre_module('smfs', 'smfs') - if self.fstype == 'ldiskfs': - manager.add_lustre_module('ldiskfs', 'ldiskfs') + if self.fstype == 'ldiskfs': + self.add_lustre_module('ldiskfs', 'ldiskfs') - if self.fstype: - manager.add_lustre_module('lvfs', 'fsfilt_%s' % (self.fstype)) + if self.fstype: + self.add_lustre_module('lvfs', 'fsfilt_%s' % (self.fstype)) - # if fstype is smfs, then we should also take care about backing - # store fs. - if self.fstype == 'smfs': - manager.add_lustre_module('lvfs', 'fsfilt_%s' % (self.backfstype)) - - for option in string.split(self.mountfsoptions, ','): - if option == 'snap': - if not self.fstype == 'smfs': - panic("mountoptions has 'snap', but fstype is not smfs.") - manager.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.fstype)) - manager.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.backfstype)) - - # add LMV modules - if self.master_uuid: - self.master.add_module(manager) + # if fstype is smfs, then we should also take care about backing + # store fs. + if self.fstype == 'smfs': + self.add_lustre_module('lvfs', 'fsfilt_%s' % (self.backfstype)) + + for options in string.split(self.mountfsoptions, ','): + if options == 'snap': + if not self.fstype == 'smfs': + panic("mountoptions with snap, but fstype is not smfs\n") + self.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.fstype)) + self.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.backfstype)) + def load_module(self): + if self.active: + Module.load_module(self) def prepare(self): if not config.record and is_prepared(self.name): @@ -1783,11 +1688,9 @@ class MDSDEV(Module): self.write_conf() self.info(self.devpath, self.fstype, self.size, self.format) run_acceptors() - # prepare LMV - if self.master_uuid: + if self.master_mds: self.master.prepare() - # never reformat here blkdev = block_dev(self.devpath, self.size, self.fstype, 0, self.format, self.journal_size, self.inode_size, @@ -1827,22 +1730,14 @@ class MDSDEV(Module): print 'MDS mount options: ' + mountfsoptions - if not self.master_uuid: - self.master_uuid = 'dumb' - - if not self.obdtype: - self.obdtype = 'dumb' - - if not self.client_uuids: - lctl.newdev("mds", self.name, self.uuid, - setup ="%s %s %s %s %s %s" %(realdev, self.fstype, - 'dumb', mountfsoptions, - self.master_uuid, self.obdtype)) - else: - lctl.newdev("mds", self.name, self.uuid, + if not self.master_mds: + self.master_mds = 'dumb' + if not self.cachetype: + self.cachetype = 'dumb' + lctl.newdev("mds", self.name, self.uuid, setup ="%s %s %s %s %s %s" %(realdev, self.fstype, self.name, mountfsoptions, - self.master_uuid, self.obdtype)) + self.master_mds, self.cachetype)) if development_mode(): procentry = "/proc/fs/lustre/mds/grp_hash_upcall" @@ -1871,9 +1766,6 @@ class MDSDEV(Module): lctl.root_squash(self.name, config.root_squash, nsnid) def write_conf(self): - if not self.client_uuids: - return 0 - do_cleanup = 0 if not is_prepared(self.name): self.info(self.devpath, self.fstype, self.format) @@ -1914,12 +1806,9 @@ class MDSDEV(Module): blkdev) else: realdev = blkdev - - print 'MDS mount options: ' + mountfsoptions + + print 'MDS mount options: ' + mountfsoptions - if not self.obdtype: - self.obdtype = 'dumb' - # As mount options are passed by 4th param to config tool, we need # to pass something in 3rd param. But we do not want this 3rd param # be counted as a profile name for reading log on MDS setup, thus, @@ -1928,18 +1817,29 @@ class MDSDEV(Module): # like pass empty string and check it in config tool and pass null # as 4th param. lctl.newdev("mds", self.name, self.uuid, - setup ="%s %s %s %s %s %s" %(realdev, self.fstype, - 'dumb', mountfsoptions, - 'dumb', self.obdtype)) + setup ="%s %s %s %s" %(realdev, self.fstype, + 'dumb', mountfsoptions)) do_cleanup = 1 - # record logs for all MDS clients - for obd_uuid in self.client_uuids: - log("recording client:", obd_uuid) + # record logs for the MDS lov + for uuid in self.filesystem_uuids: + log("recording clients for filesystem:", uuid) + fs = self.db.lookup(uuid) + # this is ugly, should be organized nice later. + target_uuid = self.db.get_first_ref('target') + mds = self.db.lookup(target_uuid) + + lovconfig_uuid = mds.get_first_ref('lovconfig') + if lovconfig_uuid: + lovconfig = mds.lookup(lovconfig_uuid) + obd_uuid = lovconfig.get_first_ref('lov') + else: + obd_uuid = fs.get_first_ref('obd') + client_uuid = generate_client_uuid(self.name) - client = VOSC(self.db.lookup(obd_uuid), client_uuid, - self.name, self.name) + client = VOSC(self.db.lookup(obd_uuid), client_uuid, self.name, + self.name) config.record = 1 lctl.clear_log(self.name, self.name) lctl.record(self.name, self.name) @@ -2004,9 +1904,11 @@ class MDSDEV(Module): e.dump() cleanup_error(e.rc) Module.cleanup(self) - - clean_dev(self.devpath, self.fstype, self.backfstype, - self.backdevpath) + + if self.fstype == 'smfs': + clean_loop(self.backdevpath) + else: + clean_loop(self.devpath) def msd_remaining(self): out = lctl.device_list() @@ -2019,7 +1921,7 @@ class MDSDEV(Module): def safe_to_clean_modules(self): return not self.msd_remaining() - + def cleanup(self): if not self.active: debug(self.uuid, "not active") @@ -2035,7 +1937,7 @@ class MDSDEV(Module): cleanup_error(e.rc) Module.cleanup(self) # cleanup LMV - if self.master_uuid: + if self.master_mds: self.master.cleanup() if not self.msd_remaining() and is_prepared('MDT'): try: @@ -2046,11 +1948,13 @@ class MDSDEV(Module): e.dump() cleanup_error(e.rc) - clean_dev(self.devpath, self.fstype, self.backfstype, - self.backdevpath) + if self.fstype == 'smfs': + clean_loop(self.backdevpath) + else: + clean_loop(self.devpath) def correct_level(self, level, op=None): - #if self.master_uuid: + #if self.master_mds: # level = level + 2 return level @@ -2089,29 +1993,30 @@ class OSD(Module): self.target_dev_uuid = self.uuid self.uuid = target_uuid - - def add_module(self, manager): - if self.active: - manager.add_lustre_module('ost', 'ost') - - if self.fstype == 'smfs': - manager.add_lustre_module('smfs', 'smfs') - - if self.fstype == 'ldiskfs': - manager.add_lustre_module('ldiskfs', 'ldiskfs') - if self.fstype: - manager.add_lustre_module('lvfs' , 'fsfilt_%s' % (self.fstype)) - if self.fstype == 'smfs': - manager.add_lustre_module('lvfs' , 'fsfilt_%s' % (self.backfstype)) + # modules + self.add_lustre_module('ost', 'ost') + if self.fstype == 'smfs': + self.add_lustre_module('smfs', 'smfs') + # FIXME: should we default to ext3 here? + if self.fstype == 'ldiskfs': + self.add_lustre_module('ldiskfs', 'ldiskfs') + if self.fstype: + self.add_lustre_module('lvfs' , 'fsfilt_%s' % (self.fstype)) + if self.fstype == 'smfs': + self.add_lustre_module('lvfs' , 'fsfilt_%s' % (self.backfstype)) + + for options in self.mountfsoptions: + if options == 'snap': + if not self.fstype == 'smfs': + panic("mountoptions with snap, but fstype is not smfs\n") + self.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.fstype)) + self.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.backfstype)) - for option in self.mountfsoptions: - if option == 'snap': - if not self.fstype == 'smfs': - panic("mountoptions with snap, but fstype is not smfs\n") - manager.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.fstype)) - manager.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.backfstype)) + self.add_lustre_module(self.osdtype, self.osdtype) - manager.add_lustre_module(self.osdtype, self.osdtype) + def load_module(self): + if self.active: + Module.load_module(self) # need to check /proc/mounts and /etc/mtab before # formatting anything. @@ -2205,8 +2110,10 @@ class OSD(Module): e.dump() cleanup_error(e.rc) if not self.osdtype == 'obdecho': - clean_dev(self.devpath, self.fstype, self.backfstype, - self.backdevpath) + if self.fstype == 'smfs': + clean_loop(self.backdevpath) + else: + clean_loop(self.devpath) def correct_level(self, level, op=None): return level @@ -2217,8 +2124,6 @@ class Client(Module): module_dir=None): self.target_name = tgtdb.getName() self.target_uuid = tgtdb.getUUID() - self.module_dir = module_dir - self.module = module self.db = tgtdb self.active = 1 self.backup_targets = [] @@ -2227,7 +2132,7 @@ class Client(Module): if not self.tgt_dev_uuid: panic("No target device found for target(1):", self.target_name) - self.kmod_manager = kmod_manager(config.lustre, config.portals) + self.kmod = kmod(config.lustre, config.portals) self._server = None self._connected = 0 @@ -2243,21 +2148,17 @@ class Client(Module): self.lookup_backup_targets() self.fs_name = fs_name - if not self.module_dir: - self.module_dir = module - - def add_module(self, manager): - manager.add_lustre_module(self.module_dir, self.module) + if not module_dir: + module_dir = module + self.add_lustre_module(module_dir, module) def lookup_server(self, srv_uuid): """ Lookup a server's network information """ self._server_nets = get_ost_net(self.db, srv_uuid) if len(self._server_nets) == 0: panic ("Unable to find a server for:", srv_uuid) - def get_name(self): return self.name - def get_servers(self): return self._server_nets def lookup_backup_targets(self): @@ -2367,51 +2268,89 @@ class OSC(Client): def permits_inactive(self): return 1 -def mgmtcli_name_for_uuid(uuid): - return 'MGMTCLI_%s' % uuid +class VLOV(Module): + def __init__(self, db, uuid, fs_name, name_override = None, config_only = None): + Module.__init__(self, 'VLOV', db) + if name_override != None: + self.name = "lov_%s" % name_override + self.add_lustre_module('lov', 'lov') + self.stripe_sz = 65536 + self.stripe_off = 0 + self.pattern = 0 + self.stripe_cnt = 1 + self.desc_uuid = self.uuid + self.uuid = generate_client_uuid(self.name) + self.fs_name = fs_name + self.osc = get_osc(db, self.uuid, fs_name) + if not self.osc: + panic('osc not found:', self.uuid) + if config_only: + self.config_only = 1 + return + self.config_only = None + def get_uuid(self): + return self.uuid + def get_name(self): + return self.name + def prepare(self): + if not config.record and is_prepared(self.name): + return + lctl.lov_setup(self.name, self.uuid, self.desc_uuid, self.stripe_cnt, + self.stripe_sz, self.stripe_off, self.pattern) + target_uuid = self.osc.target_uuid + try: + self.osc.active = 1 + self.osc.prepare(ignore_connect_failure=0) + except CommandError, e: + print "Error preparing OSC %s\n" % osc.uuid + raise e + lctl.lov_add_obd(self.name, self.uuid, target_uuid, 0, 1) + + def cleanup(self): + target_uuid = self.osc.target_uuid + self.osc.cleanup() + if is_prepared(self.name): + Module.cleanup(self) + if self.config_only: + panic("Can't clean up config_only LOV ", self.name) + + def load_module(self): + if self.config_only: + panic("Can't load modules for config_only LOV ", self.name) + self.osc.load_module() + Module.load_module(self) + + def cleanup_module(self): + if self.config_only: + panic("Can't cleanup modules for config_only LOV ", self.name) + Module.cleanup_module(self) + self.osc.cleanup_module() -class ManagementClient(Client): - def __init__(self, db, uuid): - Client.__init__(self, db, uuid, 'mgmt_cli', '', - self_name = mgmtcli_name_for_uuid(db.getUUID()), - module_dir = 'mgmt') + def correct_level(self, level, op=None): + return level class CMOBD(Module): - def __init__(self, db): + def __init__(self,db): Module.__init__(self, 'CMOBD', db) self.name = self.db.getName(); self.uuid = generate_client_uuid(self.name) self.master_uuid = self.db.get_first_ref('masterobd') self.cache_uuid = self.db.get_first_ref('cacheobd') - + self.add_lustre_module('cmobd', 'cmobd') master_obd = self.db.lookup(self.master_uuid) if not master_obd: panic('master obd not found:', self.master_uuid) - cache_obd = self.db.lookup(self.cache_uuid) if not cache_obd: panic('cache obd not found:', self.cache_uuid) - - master_class = master_obd.get_class() - cache_class = cache_obd.get_class() - - if master_class == 'ost' or master_class == 'lov': - self.master = LOV(master_obd, self.master_uuid, self.name, - "%s_master" % (self.name)); - self.cache = LOV(cache_obd, self.cache_uuid, self.name, - "%s_cache" % (self.name)); - if master_class == 'mds': + + if master_obd.get_class() == 'ost': + self.client_uuid = generate_client_uuid(self.name) + self.master= VLOV(master_obd, self.client_uuid, self.name, + "%s_master" % (self.name)) + self.master_uuid = self.master.get_uuid() + else: self.master = get_mdc(db, self.name, self.master_uuid) - if cache_class == 'mds': - self.cache = get_mdc(db, self.name, self.cache_uuid) - - if master_class == 'lmv': - self.master = LMV(master_obd, self.master_uuid, self.name, - "%s_master" % (self.name)); - if cache_class == 'lmv': - self.cache = LMV(cache_obd, self.cache_uuid, self.name, - "%s_cache" % (self.name)); - # need to check /proc/mounts and /etc/mtab before # formatting anything. # FIXME: check if device is already formatted. @@ -2424,97 +2363,78 @@ class CMOBD(Module): setup ="%s %s" %(self.master_uuid, self.cache_uuid)) - def get_uuid(self): - return self.uuid - def get_name(self): - return self.name - def get_master_name(self): - return self.master.name - def get_cache_name(self): - return self.cache.name - def cleanup(self): if is_prepared(self.name): Module.cleanup(self) self.master.cleanup() - def add_module(self, manager): - manager.add_lustre_module('cmobd', 'cmobd') - self.master.add_module(manager) + def load_module(self): + self.master.load_module() + Module.load_module(self) + def cleanup_module(self): + Module.cleanup_module(self) + self.master.cleanup_module() + def correct_level(self, level, op=None): return level class COBD(Module): - def __init__(self, db, uuid, name): + def __init__(self, db, uuid, name, type, name_override = None): Module.__init__(self, 'COBD', db) self.name = self.db.getName(); self.uuid = generate_client_uuid(self.name) - self.master_uuid = self.db.get_first_ref('masterobd') + self.real_uuid = self.db.get_first_ref('realobd') self.cache_uuid = self.db.get_first_ref('cacheobd') - - master_obd = self.db.lookup(self.master_uuid) - if not master_obd: - panic('master obd not found:', self.master_uuid) - + self.add_lustre_module('cobd', 'cobd') + real_obd = self.db.lookup(self.real_uuid) + if not real_obd: + panic('real obd not found:', self.real_uuid) cache_obd = self.db.lookup(self.cache_uuid) if not cache_obd: panic('cache obd not found:', self.cache_uuid) - - master_class = master_obd.get_class() - cache_class = cache_obd.get_class() - - if master_class == 'ost' or master_class == 'lov': - self.master = LOV(master_obd, self.master_uuid, name, - "%s_master" % (self.name)); + if type == 'obd': + self.real = LOV(real_obd, self.real_uuid, name, + "%s_real" % (self.name)); self.cache = LOV(cache_obd, self.cache_uuid, name, - "%s_cache" % (self.name)); - if master_class == 'mds': - self.master = get_mdc(db, name, self.master_uuid) - if cache_class == 'mds': - self.cache = get_mdc(db, name, self.cache_uuid) - - if master_class == 'lmv': - self.master = LMV(master_obd, self.master_uuid, self.name, - "%s_master" % (self.name)); - if cache_class == 'lmv': - self.cache = LMV(cache_obd, self.cache_uuid, self.name, - "%s_cache" % (self.name)); - + "%s_cache" % (self.name)); + else: + self.real = get_mdc(db, name, self.real_uuid) + self.cache = get_mdc(db, name, self.cache_uuid) # need to check /proc/mounts and /etc/mtab before # formatting anything. # FIXME: check if device is already formatted. def get_uuid(self): return self.uuid - def get_name(self): return self.name - - def get_master_name(self): - return self.master.name - + def get_real_name(self): + return self.real.name def get_cache_name(self): return self.cache.name - def prepare(self): - self.master.prepare() + self.real.prepare() self.cache.prepare() if not config.record and is_prepared(self.name): return - self.info(self.master_uuid, self.cache_uuid) + self.info(self.real_uuid, self.cache_uuid) lctl.newdev("cobd", self.name, self.uuid, - setup ="%s %s" %(self.master.name, + setup ="%s %s" %(self.real.name, self.cache.name)) def cleanup(self): if is_prepared(self.name): Module.cleanup(self) - self.master.cleanup() + self.real.cleanup() self.cache.cleanup() - def add_module(self, manager): - manager.add_lustre_module('cobd', 'cobd') - self.master.add_module(manager) + def load_module(self): + self.real.load_module() + Module.load_module(self) + + def cleanup_module(self): + Module.cleanup_module(self) + self.real.cleanup_module() # virtual interface for OSC and LOV class VOSC(Module): @@ -2524,27 +2444,23 @@ class VOSC(Module): self.osc = LOV(db, client_uuid, name, name_override) self.type = 'lov' elif db.get_class() == 'cobd': - self.osc = COBD(db, client_uuid, name) + self.osc = COBD(db, client_uuid, name, 'obd') self.type = 'cobd' else: self.osc = OSC(db, client_uuid, name) self.type = 'osc' - def get_uuid(self): return self.osc.get_uuid() - def get_name(self): return self.osc.get_name() - def prepare(self): self.osc.prepare() - def cleanup(self): self.osc.cleanup() - - def add_module(self, manager): - self.osc.add_module(manager) - + def load_module(self): + self.osc.load_module() + def cleanup_module(self): + self.osc.cleanup_module() def correct_level(self, level, op=None): return self.osc.correct_level(level, op) @@ -2555,31 +2471,28 @@ class VMDC(Module): if db.get_class() == 'lmv': self.mdc = LMV(db, client_uuid, name) elif db.get_class() == 'cobd': - self.mdc = COBD(db, client_uuid, name) + self.mdc = COBD(db, client_uuid, name, 'mds') else: self.mdc = MDC(db, client_uuid, name) - def get_uuid(self): return self.mdc.uuid - def get_name(self): return self.mdc.name - def prepare(self): self.mdc.prepare() - def cleanup(self): self.mdc.cleanup() - - def add_module(self, manager): - self.mdc.add_module(manager) - + def load_module(self): + self.mdc.load_module() + def cleanup_module(self): + self.mdc.cleanup_module() def correct_level(self, level, op=None): return self.mdc.correct_level(level, op) class ECHO_CLIENT(Module): def __init__(self,db): Module.__init__(self, 'ECHO_CLIENT', db) + self.add_lustre_module('obdecho', 'obdecho') self.obd_uuid = self.db.get_first_ref('obd') obd = self.db.lookup(self.obd_uuid) self.uuid = generate_client_uuid(self.name) @@ -2600,9 +2513,13 @@ class ECHO_CLIENT(Module): Module.cleanup(self) self.osc.cleanup() - def add_module(self, manager): - self.osc.add_module(manager) - manager.add_lustre_module('obdecho', 'obdecho') + def load_module(self): + self.osc.load_module() + Module.load_module(self) + + def cleanup_module(self): + Module.cleanup_module(self) + self.osc.cleanup_module() def correct_level(self, level, op=None): return level @@ -2643,7 +2560,6 @@ class Mountpoint(Module): if not self.mds_uuid: self.mds_uuid = fs.get_first_ref('mds') self.obd_uuid = fs.get_first_ref('obd') - self.mgmt_uuid = fs.get_first_ref('mgmt') client_uuid = generate_client_uuid(self.name) ost = self.db.lookup(self.obd_uuid) @@ -2654,22 +2570,18 @@ class Mountpoint(Module): if not mds: panic("no mds: ", self.mds_uuid) + self.add_lustre_module('mdc', 'mdc') + self.add_lustre_module('lmv', 'lmv') + self.add_lustre_module('llite', 'llite') + self.vosc = VOSC(ost, client_uuid, self.name) self.vmdc = VMDC(mds, client_uuid, self.name) - - if self.mgmt_uuid: - self.mgmtcli = ManagementClient(db.lookup(self.mgmt_uuid), - client_uuid) - else: - self.mgmtcli = None def prepare(self): if not config.record and fs_is_mounted(self.path): log(self.path, "already mounted.") return run_acceptors() - if self.mgmtcli: - self.mgmtcli.prepare() self.vosc.prepare() self.vmdc.prepare() vmdc_name = self.vmdc.get_name() @@ -2721,19 +2633,14 @@ class Mountpoint(Module): self.vmdc.cleanup() self.vosc.cleanup() - if self.mgmtcli: - self.mgmtcli.cleanup() - def add_module(self, manager): - manager.add_lustre_module('mdc', 'mdc') - - if self.mgmtcli: - self.mgmtcli.add_module(manager) - - self.vosc.add_module(manager) - self.vmdc.add_module(manager) + def load_module(self): + self.vosc.load_module() + Module.load_module(self) - manager.add_lustre_module('llite', 'llite') + def cleanup_module(self): + Module.cleanup_module(self) + self.vosc.cleanup_module() def correct_level(self, level, op=None): return level @@ -3135,36 +3042,17 @@ def doSetup(services): for n in nlist: n[1].prepare() -def doLoadModules(services): +def doModules(services): if config.nomod: return - - # adding all needed modules from all services for s in services: n = newService(s[1]) - n.add_module(mod_manager) - - # loading all registered modules - mod_manager.load_modules() - -def doUnloadModules(services): - if config.nomod: - return - - # adding all needed modules from all services - for s in services: - n = newService(s[1]) - if n.safe_to_clean_modules(): - n.add_module(mod_manager) - - # unloading all registered modules - mod_manager.cleanup_modules() + n.load_module() def doCleanup(services): if config.nosetup: return slist = [] - for s in services: n = newService(s[1]) n.level = s[0] @@ -3175,11 +3063,19 @@ def doCleanup(services): nlist.append((nl, n[1])) nlist.sort() nlist.reverse() - for n in nlist: if n[1].safe_to_clean(): n[1].cleanup() +def doUnloadModules(services): + if config.nomod: + return + services.reverse() + for s in services: + n = newService(s[1]) + if n.safe_to_clean_modules(): + n.cleanup_module() + # # Load profile for def doHost(lustreDB, hosts): @@ -3209,7 +3105,7 @@ def doHost(lustreDB, hosts): prof_list = node_db.get_refs('profile') if config.write_conf: - for_each_profile(node_db, prof_list, doLoadModules) + for_each_profile(node_db, prof_list, doModules) sys_make_devices() for_each_profile(node_db, prof_list, doWriteconf) for_each_profile(node_db, prof_list, doUnloadModules) @@ -3252,7 +3148,7 @@ def doHost(lustreDB, hosts): sys_set_netmem_max('/proc/sys/net/core/rmem_max', MAXTCPBUF) sys_set_netmem_max('/proc/sys/net/core/wmem_max', MAXTCPBUF) - for_each_profile(node_db, prof_list, doLoadModules) + for_each_profile(node_db, prof_list, doModules) sys_set_debug_path() sys_set_ptldebug(ptldebug) @@ -3556,7 +3452,7 @@ lconf_options = [ ] def main(): - global lctl, config, toplustreDB, CONFIG_FILE, mod_manager + global lctl, config, toplustreDB, CONFIG_FILE # in the upcall this is set to SIG_IGN signal.signal(signal.SIGCHLD, signal.SIG_DFL) @@ -3663,9 +3559,6 @@ def main(): lctl.clear_log(config.record_device, config.record_log) lctl.record(config.record_device, config.record_log) - # init module manager - mod_manager = kmod_manager(config.lustre, config.portals) - doHost(lustreDB, node_list) if not config.record: diff --git a/lustre/utils/lmc b/lustre/utils/lmc index d2d02a6b..3fea4e2 100755 --- a/lustre/utils/lmc +++ b/lustre/utils/lmc @@ -164,13 +164,13 @@ Object creation command summary: --add cobd --node node_name - --master_obd obd_name + --real_obd obd_name --cache_obd obd_name --add cmobd --node node_name - --master_obd obd_name - --cache_obd obd_name + --master_dev obd_name + --cache_dev obd_name --commit - Close a configuration version, and start a new one """ @@ -252,19 +252,22 @@ lmc_options = [ ('stripe_cnt', "Specify the number of OSTs each file should be striped on.", PARAM, 0), ('stripe_pattern', "Specify the stripe pattern. RAID 0 is the only one currently supported.", PARAM, 0), - # cobd and cmobd - ('master_obd', "Specify the master device for the cache obd system.", PARAM), + # cobd + + ('real_obd', "Specify the real device for the cache obd system.", PARAM), ('cache_obd', "Specify the cache device for the cache obd system.", PARAM), ('cobd', "Specify COBD name", PARAM), # cmobd - ('cmobd', "Specify CMOBD name", PARAM, ""), + ('master_dev', "Specify the master device for the cmobd system.", PARAM), + ('cache_dev', "Specify the cache device for the cmobd obd system.", PARAM), + ('cmobd', "Specify COBD name", PARAM), ('mgmt', "Specify management/monitoring service name.", PARAM, ""), # lmv - ('lmv', "Specify LMV name.", PARAM, ""), + ('lmv', "Specify LMV name.", PARAM,""), ] def error(*args): @@ -436,7 +439,7 @@ class GenConfig: osd.setAttribute('osdtype', osdtype) osd.appendChild(self.ref("target", ost_uuid)) osd.appendChild(self.ref("node", node_uuid)) - osd.appendChild(self.dev(devname)) + osd.appendChild(self.dev(devname)) if fstype: self.addElement(osd, "fstype", fstype) @@ -461,15 +464,15 @@ class GenConfig: self.addElement(osd, "nspath", nspath) return osd - def cobd(self, name, uuid, master_uuid, cache_uuid): + def cobd(self, name, uuid, real_uuid, cache_uuid): cobd = self.newService("cobd", name, uuid) - cobd.appendChild(self.ref("masterobd",master_uuid)) + cobd.appendChild(self.ref("realobd",real_uuid)) cobd.appendChild(self.ref("cacheobd",cache_uuid)) return cobd - def cmobd(self, name, uuid, master_uuid, cache_uuid): + def cmobd(self, name, uuid, real_uuid, cache_uuid): cmobd = self.newService("cmobd", name, uuid) - cmobd.appendChild(self.ref("masterobd",master_uuid)) + cmobd.appendChild(self.ref("masterobd",real_uuid)) cmobd.appendChild(self.ref("cacheobd",cache_uuid)) return cmobd @@ -511,7 +514,7 @@ class GenConfig: def mds(self, name, uuid, mdd_uuid, group="", lmv=""): mds = self.newService("mds", name, uuid) - mds.appendChild(self.ref("active", mdd_uuid)) + mds.appendChild(self.ref("active",mdd_uuid)) if group: self.addElement(mds, "group", group) return mds @@ -523,13 +526,13 @@ class GenConfig: mdd = self.newService("mdsdev", name, uuid) self.addElement(mdd, "fstype", fstype) if backfstype: - self.addElement(mdd, "backfstype", backfstype) + self.addElement(mdd, "backfstype", backfstype) dev = self.addElement(mdd, "devpath", devname) if backdevname: self.addElement(mdd, "backdevpath", backdevname) self.addElement(mdd, "autoformat", format) if dev_size: - self.addElement(mdd, "devsize", "%s" % (dev_size)) + self.addElement(mdd, "devsize", "%s" % (dev_size)) if journal_size: self.addElement(mdd, "journalsize", "%s" % (journal_size)) if inode_size: @@ -546,7 +549,7 @@ class GenConfig: self.addElement(mdd, "no_root_squash", no_root_squash) mdd.appendChild(self.ref("node", node_uuid)) mdd.appendChild(self.ref("target", mds_uuid)) - mdd.appendChild(self.dev(devname)) + mdd.appendChild(self.dev(devname)) if lmv_uuid: mdd.appendChild(self.ref("lmv", lmv_uuid)) @@ -814,6 +817,40 @@ def node_add_profile(gen, node, ref, uuid): profile.appendChild(gen.ref(ref, uuid)) return 1 +# ensure that uuid is not already in the profile +# return true if uuid is added +def node_found_target_by_dev(gen, lustre, node, devname): + refname = "%s_ref" % "profile" + ret = node.getElementsByTagName(refname) + if not ret: + error('node has no profile ref:', node) + prof_uuid = ret[0].getAttribute('uuidref') + profile = lookup(node.parentNode, prof_uuid) + if not profile: + error("no profile found:", prof_uuid) + + osd_list = lustre.getElementsByTagName('osd') + + for osd in osd_list: + obd_dev = osd.getElementsByTagName('dev') + if obd_dev and obd_dev[0].getAttribute('dev') == devname: + for ost in lustre.getElementsByTagName('ost'): + active_ret = ost.getElementsByTagName('active_ref') + if active_ret[0].getAttribute('uuidref') == osd.getAttribute('uuid'): + return ost.getAttribute('uuid') + + mdsdev_list = lustre.getElementsByTagName('mdsdev') + + for mdsdev in mdsdev_list: + obd_dev = mdsdev.getElementsByTagName('dev') + if obd_dev and obd_dev[0].getAttribute('dev') == devname: + for mds in lustre.getElementsByTagName('mds'): + active_ret = mds.getElementsByTagName('active_ref') + if active_ret[0].getAttribute('uuidref') == mdsdev.getAttribute('uuid'): + return mds.getAttribute('uuid') + + return "" + def get_attr(dom_node, attr, default=""): v = dom_node.getAttribute(attr) if v: @@ -862,6 +899,7 @@ def do_add_node(gen, lustre, options, node_name): return node + def add_node(gen, lustre, options): """ create a node with a network config """ @@ -872,6 +910,7 @@ def add_node(gen, lustre, options): return do_add_node(gen, lustre, options, node_name) + def add_net(gen, lustre, options): """ create a node with a network config """ @@ -902,6 +941,7 @@ def add_net(gen, lustre, options): hostaddr, port)) node_add_profile(gen, node, "network", net_uuid) + def add_route(gen, lustre, options): """ create a node with a network config """ @@ -931,6 +971,7 @@ def add_route(gen, lustre, options): rtbl.appendChild(gen.route(gw_net_type, gw, gw_cluster_id, tgt_cluster_id, lo, hi)) + def add_mds(gen, lustre, options): node_name = get_option(options, 'node') mds_name = get_option(options, 'mds') @@ -994,6 +1035,7 @@ def add_mds(gen, lustre, options): root_squash, no_root_squash) lustre.appendChild(mdd) + def add_mgmt(gen, lustre, options): node_name = get_option(options, 'node') node_uuid = name2uuid(lustre, node_name, 'node') @@ -1012,9 +1054,6 @@ def add_mgmt(gen, lustre, options): node_add_profile(gen, node, 'mgmt', mgmt_uuid) def add_ost(gen, lustre, options): - # FIXME-UMKA: here we should have mds ref and add - # this ost uuid to its "client" tag - node_name = get_option(options, 'node') lovname = get_option(options, 'lov') osdtype = get_option(options, 'osdtype') @@ -1074,6 +1113,7 @@ def add_ost(gen, lustre, options): if options.failover: ost.setAttribute('failover', "1") + osd = gen.osd(osdname, osd_uuid, fstype, osdtype, devname, get_format_flag(options), ost_uuid, node_uuid, size, journal_size, inode_size, nspath, mkfsoptions, @@ -1133,64 +1173,18 @@ def add_cmobd(gen, lustre, options): name = get_option(options, 'cmobd') uuid = new_uuid(name) - master_name = get_option(options, 'master_obd') - cache_name = get_option(options, 'cache_obd') - - master_uuid = name2uuid(lustre, master_name, tag='lov', fatal=0) - cache_uuid = name2uuid(lustre, cache_name, tag='lov', fatal=0) - - if not master_uuid or not cache_uuid: - if not master_uuid: - master_uuid = name2uuid(lustre, master_name, tag='ost', fatal=0) - if not cache_uuid: - cache_uuid = name2uuid(lustre, cache_name, tag='ost', fatal=0) - - if not master_uuid or not cache_uuid: - if not master_uuid: - master_uuid = name2uuid(lustre, master_name, tag='lmv', fatal=0) - if not cache_uuid: - cache_uuid = name2uuid(lustre, cache_name, tag='lmv', fatal=0) - - if not master_uuid or not cache_uuid: - if not master_uuid: - master_uuid = name2uuid(lustre, master_name, tag='mds', fatal=0) - if not cache_uuid: - cache_uuid = name2uuid(lustre, cache_name, tag='mds', fatal=0) - - if not master_uuid: - panic("add_cmobd", "cannot find master_uuid by name '" + - master_name + "'") - if not cache_uuid: - panic("add_cmobd", "cannot find cache_uuid by name '" + - cache_name + "'") + real_name = get_option(options, 'master_dev') + cache_name = get_option(options, 'cache_dev') node = findByName(lustre, node_name, "node") node_add_profile(gen, node, "cmobd", uuid) - - master_node = lookup(lustre, master_uuid) - cache_node = lookup(lustre, cache_uuid) - if not master_node: - panic("cmobd_add", "cannot find master node by its uuid " + - master_uuid); - if not cache_node: - panic("cmobd_add", "cannot find cache node by its uuid " + - cache_uuid); - - active = master_node.getElementsByTagName('active_ref') - if active: - active_uuid = active[0].getAttribute('uuidref') - active_node = lookup(lustre, active_uuid) - if not active_node.getElementsByTagName('obdtype'): - gen.addElement(active_node, 'obdtype', 'master') - - active = cache_node.getElementsByTagName('active_ref') - if active: - active_uuid = active[0].getAttribute('uuidref') - active_node = lookup(lustre, active_uuid) - if not active_node.getElementsByTagName('obdtype'): - gen.addElement(active_node, 'obdtype', 'cache') - - cmobd = gen.cmobd(name, uuid, master_uuid, cache_uuid) + real_uuid = node_found_target_by_dev(gen, lustre, node, real_name) + cache_uuid = node_found_target_by_dev(gen, lustre, node, cache_name) + if not real_uuid: + panic("add_cmobd", "can not find real_uuid") + if not cache_uuid: + panic("add_cmobd", "can not find cache_uuid") + cmobd = gen.cmobd(name, uuid, real_uuid, cache_uuid) lustre.appendChild(cmobd) def add_cobd(gen, lustre, options): @@ -1198,24 +1192,23 @@ def add_cobd(gen, lustre, options): name = get_option(options, 'cobd') uuid = new_uuid(name) - master_name = get_option(options, 'master_obd') + real_name = get_option(options, 'real_obd') cache_name = get_option(options, 'cache_obd') - master_uuid = name2uuid(lustre, master_name, tag='lov', fatal=0) + real_uuid = name2uuid(lustre, real_name, tag='lov', fatal=0) cache_uuid = name2uuid(lustre, cache_name, tag='lov', fatal=0) - if master_uuid: - node = lookup(lustre, master_uuid) + if real_uuid: + node = lookup(lustre, real_uuid) rets = node.getElementsByTagName('lov_tgt') for ret in rets: ost_uuid = ret.getAttribute('uuidref') ost_node = lookup(lustre, ost_uuid) - active = ost_node.getElementsByTagName('active_ref') - if active: - osd_uuid = active[0].getAttribute('uuidref') + ret = ost_node.getElementsByTagName('active_ref') + if ret: + osd_uuid = ret[0].getAttribute('uuidref') osd_node = lookup(lustre, osd_uuid) - if not osd_node.getElementsByTagName('obdtype'): - gen.addElement(osd_node, 'obdtype', 'master') + gen.addElement(osd_node, 'cachetype', 'master') if cache_uuid: node = lookup(lustre, cache_uuid) @@ -1223,35 +1216,32 @@ def add_cobd(gen, lustre, options): for ret in rets: ost_uuid = ret.getAttribute('uuidref') ost_node = lookup(lustre, ost_uuid) - active = ost_node.getElementsByTagName('active_ref') - if active: - osd_uuid = active[0].getAttribute('uuidref') + ret = ost_node.getElementsByTagName('active_ref') + if ret: + osd_uuid = ret[0].getAttribute('uuidref') osd_node = lookup(lustre, osd_uuid) - if not osd_node.getElementsByTagName('obdtype'): - gen.addElement(osd_node, 'obdtype', 'cache') + gen.addElement(osd_node, 'cachetype', 'cache') - if not master_uuid or not cache_uuid: - master_uuid = name2uuid(lustre,master_name, tag='mds') + if not real_uuid or not cache_uuid: + real_uuid = name2uuid(lustre,real_name, tag='mds') cache_uuid = name2uuid(lustre,cache_name, tag='mds') - if master_uuid: - mds_node = lookup(lustre, master_uuid) + if real_uuid: + mds_node = lookup(lustre, real_uuid) ret = mds_node.getElementsByTagName('active_ref') if ret: mdsdev_uuid = ret[0].getAttribute('uuidref') mdsdev_node = lookup(lustre, mdsdev_uuid) - if not mdsdev_node.getElementsByTagName('obdtype'): - gen.addElement(mdsdev_node, 'obdtype', 'master') + gen.addElement(mdsdev_node, 'cachetype', 'master') if cache_uuid: mds_node = lookup(lustre, cache_uuid) ret = mds_node.getElementsByTagName('active_ref') if ret: mdsdev_uuid = ret[0].getAttribute('uuidref') mdsdev_node = lookup(lustre, mdsdev_uuid) - if not mdsdev_node.getElementsByTagName('obdtype'): - gen.addElement(mdsdev_node, 'obdtype', 'cache') + gen.addElement(mdsdev_node, 'cachetype', 'cache') node = findByName(lustre, node_name, "node") - cobd = gen.cobd(name, uuid, master_uuid, cache_uuid) + cobd = gen.cobd(name, uuid, real_uuid, cache_uuid) lustre.appendChild(cobd) @@ -1284,8 +1274,9 @@ def add_lov(gen, lustre, options): warning("name:", lov_orig, "already used. using:", name) mds_name = get_option(options, 'mds') - if not mds_name and not lmv_name: - error("LOV: MDS or LMV must be specified."); + if not mds_name: + if not lmv_name: + error("LOV: MDS or LMV must be specified."); stripe_sz = get_option_int(options, 'stripe_sz') stripe_cnt = get_option_int(options, 'stripe_cnt') @@ -1296,7 +1287,7 @@ def add_lov(gen, lustre, options): if ret: error("LOV: ", name, " already exists.") - if lmv_name: + if not mds_name: mds_uuid = name2uuid(lustre, lmv_name, 'lmv') else: mds_uuid = name2uuid(lustre, mds_name, 'mds') @@ -1310,13 +1301,9 @@ def add_lov(gen, lustre, options): if mds_name: mds = findByName(lustre, mds_name, "mds") mds.appendChild(gen.ref("lovconfig", lovconfig_uuid)) - mds.appendChild(gen.ref("client", uuid)) - if lmv_name: lmv = findByName(lustre, lmv_name, "lmv") lmv.appendChild(gen.ref("lovconfig", lovconfig_uuid)) - lmv.appendChild(gen.ref("client", uuid)) - lovconfig = gen.lovconfig(lovconfig_name, lovconfig_uuid, uuid) lustre.appendChild(lovconfig) @@ -1363,10 +1350,20 @@ def add_lmv(gen, lustre, options): def new_filesystem(gen, lustre, mds_uuid, obd_uuid, mgmt_uuid): fs_name = new_name("FS_fsname") fs_uuid = new_uuid(fs_name) - - obd = lookup(lustre, mds_uuid) - obd.appendChild(gen.ref("client", obd_uuid)) - + cobd = lookup(lustre, mds_uuid) + #SHOULD appendChild filesystem to real mds not cobd + ret = cobd.getElementsByTagName("cacheobd_ref") + if ret: + cacheobd_uuid = ret[0].getAttribute('uuidref') + cacheobd = lookup(lustre, cacheobd_uuid) + cacheobd.appendChild(gen.ref("filesystem", fs_uuid)) + ret = cobd.getElementsByTagName("realobd_ref") + if ret: + realobd_uuid = ret[0].getAttribute('uuidref') + realobd = lookup(lustre, realobd_uuid) + realobd.appendChild(gen.ref("filesystem", fs_uuid)) + else: + cobd.appendChild(gen.ref("filesystem", fs_uuid)) fs = gen.filesystem(fs_name, fs_uuid, mds_uuid, obd_uuid, mgmt_uuid) lustre.appendChild(fs) return fs_uuid @@ -1376,22 +1373,17 @@ def get_fs_uuid(gen, lustre, mds_name, obd_name, mgmt_name): if not mds_uuid: mds_uuid = name2uuid(lustre, mds_name, tag='lmv', fatal=0) if not mds_uuid: - mds_uuid = name2uuid(lustre, mds_name, tag='cobd', fatal=1) - - obd_uuid = name2uuid(lustre, obd_name, tag='ost', fatal=0) - if not obd_uuid: - obd_uuid = name2uuid(lustre, obd_name, tag='lov', fatal=0) - if not obd_uuid: - obd_uuid = name2uuid(lustre, obd_name, tag='cobd', fatal=1) + mds_uuid = name2uuid(lustre, mds_name, tag='cobd', fatal=1) + obd_uuid = name2uuid(lustre, obd_name, tag='lov', fatal=0) + if obd_uuid == '': + obd_uuid = name2uuid(lustre, obd_name, tag='cobd') if mgmt_name: mgmt_uuid = name2uuid(lustre, mgmt_name, tag='mgmt', fatal=1) else: mgmt_uuid = '' - fs_uuid = lookup_filesystem(lustre, mds_uuid, obd_uuid) if not fs_uuid: - fs_uuid = new_filesystem(gen, lustre, mds_uuid, - obd_uuid, mgmt_uuid) + fs_uuid = new_filesystem(gen, lustre, mds_uuid, obd_uuid, mgmt_uuid) return fs_uuid def add_mtpt(gen, lustre, options): @@ -1463,7 +1455,7 @@ class OptionError (exceptions.Exception): def get_option(options, tag): """Look for tag in options hash and return the value if set. If not - set, then if return default if it is set, otherwise exception.""" + set, then if return default it is set, otherwise exception.""" if options.__getattr__(tag) != None: return options.__getattr__(tag) else: diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index 9565aaa..ca17073 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -53,7 +53,7 @@ #include "parser.h" #include -static char *lcfg_devname; +static char * lcfg_devname; void lcfg_set_devname(char *name) { diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 3313169..2cf74f9a 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -2386,10 +2386,9 @@ int jt_obd_reint_sync(int argc, char **argv) IOC_PACK(argv[0], data); rc = l_ioctl(OBD_DEV_ID, OBD_IOC_CMOBD_SYNC, buf); - if (rc) { - fprintf(stderr, "OBD_IOC_CMOBD_SYNC failed: %s\n", - strerror(errno)); - } + if (rc) + fprintf(stderr, "OBD_IOC_CMOBD_SYNC failed: rc=%d\n", + rc); return rc; } @@ -2405,10 +2404,9 @@ int jt_obd_cache_on(int argc, char **argv) IOC_PACK(argv[0], data); rc = l_ioctl(OBD_DEV_ID, OBD_IOC_COBD_CON, buf); - if (rc) { - fprintf(stderr, "OBD_IOC_COBD_CON failed: %s\n", - strerror(errno)); - } + if (rc) + fprintf(stderr, "OBD_IOC_CMOBD_SYNC failed: rc=%d\n", + rc); return rc; } @@ -2422,10 +2420,9 @@ int jt_obd_cache_off(int argc, char **argv) return CMD_HELP; IOC_PACK(argv[0], data); rc = l_ioctl(OBD_DEV_ID, OBD_IOC_COBD_COFF, buf); - if (rc) { - fprintf(stderr, "OBD_IOC_COBD_COFF failed: %s\n", - strerror(errno)); - } + if (rc) + fprintf(stderr, "OBD_IOC_CMOBD_SYNC failed: rc=%d\n", + rc); return rc; } int jt_obd_snap_add(int argc, char **argv) @@ -2451,11 +2448,9 @@ int jt_obd_snap_add(int argc, char **argv) rc = l_ioctl(SMFS_DEV_ID, OBD_IOC_SMFS_SNAP_ADD, buf); unregister_ioc_dev(SMFS_DEV_ID); - if (rc) { - fprintf(stderr, "OBD_IOC_SNAP_ADD failed: rc=%s\n", - strerror(errno)); - } + if (rc) + fprintf(stderr, "OBD_IOC_SNAP_ADD failed: rc=%d\n", rc); return rc; } static void signal_server(int sig) @@ -2464,8 +2459,7 @@ static void signal_server(int sig) do_disconnect("sigint", 1); exit(1); } else - fprintf(stderr, "%s: got signal %d\n", - jt_cmdname("sigint"), sig); + fprintf(stderr, "%s: got signal %d\n", jt_cmdname("sigint"), sig); } int obd_initialize(int argc, char **argv) diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 89f2ec0..3101832 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -117,7 +117,6 @@ check_obdo(void) CHECK_MEMBER(obdo, o_misc); CHECK_MEMBER(obdo, o_easize); CHECK_MEMBER(obdo, o_mds); - CHECK_MEMBER(obdo, o_mds); CHECK_MEMBER(obdo, o_padding); CHECK_MEMBER(obdo, o_inline); @@ -232,13 +231,13 @@ check_ost_body(void) } void -check_lustre_stc(void) +check_ll_fid(void) { BLANK_LINE(); - CHECK_STRUCT(lustre_stc); - CHECK_MEMBER(lustre_stc, u.e3s.l3s_ino); - CHECK_MEMBER(lustre_stc, u.e3s.l3s_gen); - CHECK_MEMBER(lustre_stc, u.e3s.l3s_type); + CHECK_STRUCT(ll_fid); + CHECK_MEMBER(ll_fid, id); + CHECK_MEMBER(ll_fid, generation); + CHECK_MEMBER(ll_fid, f_type); } void @@ -255,12 +254,13 @@ check_mds_body(void) { BLANK_LINE(); CHECK_STRUCT(mds_body); - CHECK_MEMBER(mds_body, id1); - CHECK_MEMBER(mds_body, id2); + CHECK_MEMBER(mds_body, fid1); + CHECK_MEMBER(mds_body, fid2); CHECK_MEMBER(mds_body, handle); CHECK_MEMBER(mds_body, size); CHECK_MEMBER(mds_body, blocks); CHECK_MEMBER(mds_body, io_epoch); + CHECK_MEMBER(mds_body, ino); CHECK_MEMBER(mds_body, valid); CHECK_MEMBER(mds_body, mode); CHECK_MEMBER(mds_body, uid); @@ -271,7 +271,9 @@ check_mds_body(void) CHECK_MEMBER(mds_body, flags); CHECK_MEMBER(mds_body, rdev); CHECK_MEMBER(mds_body, nlink); + CHECK_MEMBER(mds_body, generation); CHECK_MEMBER(mds_body, eadatasize); + CHECK_MEMBER(mds_body, mds); CHECK_VALUE(FMODE_READ); CHECK_VALUE(FMODE_WRITE); @@ -293,7 +295,7 @@ check_mds_rec_setattr(void) CHECK_STRUCT(mds_rec_setattr); CHECK_MEMBER(mds_rec_setattr, sa_opcode); CHECK_MEMBER(mds_rec_setattr, sa_valid); - CHECK_MEMBER(mds_rec_setattr, sa_id); + CHECK_MEMBER(mds_rec_setattr, sa_fid); CHECK_MEMBER(mds_rec_setattr, sa_mode); CHECK_MEMBER(mds_rec_setattr, sa_uid); CHECK_MEMBER(mds_rec_setattr, sa_gid); @@ -313,8 +315,8 @@ check_mds_rec_create(void) CHECK_MEMBER(mds_rec_create, cr_flags); CHECK_MEMBER(mds_rec_create, cr_mode); CHECK_MEMBER(mds_rec_create, cr_padding); - CHECK_MEMBER(mds_rec_create, cr_id); - CHECK_MEMBER(mds_rec_create, cr_replayid); + CHECK_MEMBER(mds_rec_create, cr_fid); + CHECK_MEMBER(mds_rec_create, cr_replayfid); CHECK_MEMBER(mds_rec_create, cr_time); CHECK_MEMBER(mds_rec_create, cr_rdev); } @@ -326,8 +328,8 @@ check_mds_rec_link(void) CHECK_STRUCT(mds_rec_link); CHECK_MEMBER(mds_rec_link, lk_opcode); CHECK_MEMBER(mds_rec_link, lk_padding); - CHECK_MEMBER(mds_rec_link, lk_id1); - CHECK_MEMBER(mds_rec_link, lk_id2); + CHECK_MEMBER(mds_rec_link, lk_fid1); + CHECK_MEMBER(mds_rec_link, lk_fid2); CHECK_MEMBER(mds_rec_link, lk_time); } @@ -338,8 +340,8 @@ check_mds_rec_unlink(void) CHECK_STRUCT(mds_rec_unlink); CHECK_MEMBER(mds_rec_unlink, ul_opcode); CHECK_MEMBER(mds_rec_unlink, ul_mode); - CHECK_MEMBER(mds_rec_unlink, ul_id1); - CHECK_MEMBER(mds_rec_unlink, ul_id2); + CHECK_MEMBER(mds_rec_unlink, ul_fid1); + CHECK_MEMBER(mds_rec_unlink, ul_fid2); CHECK_MEMBER(mds_rec_unlink, ul_time); } @@ -350,8 +352,8 @@ check_mds_rec_rename(void) CHECK_STRUCT(mds_rec_rename); CHECK_MEMBER(mds_rec_rename, rn_opcode); CHECK_MEMBER(mds_rec_rename, rn_padding); - CHECK_MEMBER(mds_rec_rename, rn_id1); - CHECK_MEMBER(mds_rec_rename, rn_id2); + CHECK_MEMBER(mds_rec_rename, rn_fid1); + CHECK_MEMBER(mds_rec_rename, rn_fid2); CHECK_MEMBER(mds_rec_rename, rn_time); } @@ -556,7 +558,7 @@ check_llog_create_rec(void) BLANK_LINE(); CHECK_STRUCT(llog_create_rec); CHECK_MEMBER(llog_create_rec, lcr_hdr); - CHECK_MEMBER(llog_create_rec, lcr_id); + CHECK_MEMBER(llog_create_rec, lcr_fid); CHECK_MEMBER(llog_create_rec, lcr_oid); CHECK_MEMBER(llog_create_rec, lcr_ogen); } @@ -589,7 +591,7 @@ check_llog_size_change_rec(void) BLANK_LINE(); CHECK_STRUCT(llog_size_change_rec); CHECK_MEMBER(llog_size_change_rec, lsc_hdr); - CHECK_MEMBER(llog_size_change_rec, lsc_id); + CHECK_MEMBER(llog_size_change_rec, lsc_fid); CHECK_MEMBER(llog_size_change_rec, lsc_io_epoch); CHECK_MEMBER(llog_size_change_rec, lsc_tail); } @@ -855,7 +857,7 @@ main(int argc, char **argv) check_obd_ioobj(); check_niobuf_remote(); check_ost_body(); - check_lustre_stc(); + check_ll_fid(); check_mds_status_req(); check_mds_body(); check_mds_rec_setattr(); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 3563b8a..c8994ec 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -24,4 +24,1393 @@ int main() void lustre_assert_wire_constants(void) { + /* Wire protocol assertions generated by 'wirecheck' + * running on Linux build 2.4.24-cmd2 #1 SMP Tue Sep 14 10:34:54 MDT 2004 i686 i686 i386 GNU/ + * with gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) */ + + + /* Constants... */ + LASSERTF(PTLRPC_MSG_MAGIC == 0x0BD00BD0," found %lld\n", + (long long)PTLRPC_MSG_MAGIC); + LASSERTF(PTLRPC_MSG_VERSION == 0x00000003," found %lld\n", + (long long)PTLRPC_MSG_VERSION); + LASSERTF(PTL_RPC_MSG_REQUEST == 4711, " found %lld\n", + (long long)PTL_RPC_MSG_REQUEST); + LASSERTF(PTL_RPC_MSG_ERR == 4712, " found %lld\n", + (long long)PTL_RPC_MSG_ERR); + LASSERTF(PTL_RPC_MSG_REPLY == 4713, " found %lld\n", + (long long)PTL_RPC_MSG_REPLY); + LASSERTF(MSG_LAST_REPLAY == 1, " found %lld\n", + (long long)MSG_LAST_REPLAY); + LASSERTF(MSG_RESENT == 2, " found %lld\n", + (long long)MSG_RESENT); + LASSERTF(MSG_REPLAY == 4, " found %lld\n", + (long long)MSG_REPLAY); + LASSERTF(MSG_CONNECT_RECOVERING == 1, " found %lld\n", + (long long)MSG_CONNECT_RECOVERING); + LASSERTF(MSG_CONNECT_RECONNECT == 2, " found %lld\n", + (long long)MSG_CONNECT_RECONNECT); + LASSERTF(MSG_CONNECT_REPLAYABLE == 4, " found %lld\n", + (long long)MSG_CONNECT_REPLAYABLE); + LASSERTF(OST_REPLY == 0, " found %lld\n", + (long long)OST_REPLY); + LASSERTF(OST_GETATTR == 1, " found %lld\n", + (long long)OST_GETATTR); + LASSERTF(OST_SETATTR == 2, " found %lld\n", + (long long)OST_SETATTR); + LASSERTF(OST_READ == 3, " found %lld\n", + (long long)OST_READ); + LASSERTF(OST_WRITE == 4, " found %lld\n", + (long long)OST_WRITE); + LASSERTF(OST_CREATE == 5, " found %lld\n", + (long long)OST_CREATE); + LASSERTF(OST_DESTROY == 6, " found %lld\n", + (long long)OST_DESTROY); + LASSERTF(OST_GET_INFO == 7, " found %lld\n", + (long long)OST_GET_INFO); + LASSERTF(OST_CONNECT == 8, " found %lld\n", + (long long)OST_CONNECT); + LASSERTF(OST_DISCONNECT == 9, " found %lld\n", + (long long)OST_DISCONNECT); + LASSERTF(OST_PUNCH == 10, " found %lld\n", + (long long)OST_PUNCH); + LASSERTF(OST_OPEN == 11, " found %lld\n", + (long long)OST_OPEN); + LASSERTF(OST_CLOSE == 12, " found %lld\n", + (long long)OST_CLOSE); + LASSERTF(OST_STATFS == 13, " found %lld\n", + (long long)OST_STATFS); + LASSERTF(OST_SAN_READ == 14, " found %lld\n", + (long long)OST_SAN_READ); + LASSERTF(OST_SAN_WRITE == 15, " found %lld\n", + (long long)OST_SAN_WRITE); + LASSERTF(OST_SYNC == 16, " found %lld\n", + (long long)OST_SYNC); + LASSERTF(OST_LAST_OPC == 18, " found %lld\n", + (long long)OST_LAST_OPC); + LASSERTF(OBD_OBJECT_EOF == 0xffffffffffffffffULL," found %lld\n", + (long long)OBD_OBJECT_EOF); + LASSERTF(OST_REQ_HAS_OA1 == 1, " found %lld\n", + (long long)OST_REQ_HAS_OA1); + LASSERTF(MDS_GETATTR == 33, " found %lld\n", + (long long)MDS_GETATTR); + LASSERTF(MDS_GETATTR_LOCK == 34, " found %lld\n", + (long long)MDS_GETATTR_LOCK); + LASSERTF(MDS_CLOSE == 35, " found %lld\n", + (long long)MDS_CLOSE); + LASSERTF(MDS_REINT == 36, " found %lld\n", + (long long)MDS_REINT); + LASSERTF(MDS_READPAGE == 37, " found %lld\n", + (long long)MDS_READPAGE); + LASSERTF(MDS_CONNECT == 38, " found %lld\n", + (long long)MDS_CONNECT); + LASSERTF(MDS_DISCONNECT == 39, " found %lld\n", + (long long)MDS_DISCONNECT); + LASSERTF(MDS_GETSTATUS == 40, " found %lld\n", + (long long)MDS_GETSTATUS); + LASSERTF(MDS_STATFS == 41, " found %lld\n", + (long long)MDS_STATFS); + LASSERTF(MDS_PIN == 42, " found %lld\n", + (long long)MDS_PIN); + LASSERTF(MDS_UNPIN == 43, " found %lld\n", + (long long)MDS_UNPIN); + LASSERTF(MDS_SYNC == 44, " found %lld\n", + (long long)MDS_SYNC); + LASSERTF(MDS_DONE_WRITING == 45, " found %lld\n", + (long long)MDS_DONE_WRITING); + LASSERTF(MDS_LAST_OPC == 46, " found %lld\n", + (long long)MDS_LAST_OPC); + LASSERTF(REINT_SETATTR == 1, " found %lld\n", + (long long)REINT_SETATTR); + LASSERTF(REINT_CREATE == 2, " found %lld\n", + (long long)REINT_CREATE); + LASSERTF(REINT_LINK == 3, " found %lld\n", + (long long)REINT_LINK); + LASSERTF(REINT_UNLINK == 4, " found %lld\n", + (long long)REINT_UNLINK); + LASSERTF(REINT_RENAME == 5, " found %lld\n", + (long long)REINT_RENAME); + LASSERTF(REINT_OPEN == 6, " found %lld\n", + (long long)REINT_OPEN); + LASSERTF(REINT_MAX == 8, " found %lld\n", + (long long)REINT_MAX); + LASSERTF(DISP_IT_EXECD == 1, " found %lld\n", + (long long)DISP_IT_EXECD); + LASSERTF(DISP_LOOKUP_EXECD == 2, " found %lld\n", + (long long)DISP_LOOKUP_EXECD); + LASSERTF(DISP_LOOKUP_NEG == 4, " found %lld\n", + (long long)DISP_LOOKUP_NEG); + LASSERTF(DISP_LOOKUP_POS == 8, " found %lld\n", + (long long)DISP_LOOKUP_POS); + LASSERTF(DISP_OPEN_CREATE == 16, " found %lld\n", + (long long)DISP_OPEN_CREATE); + LASSERTF(DISP_OPEN_OPEN == 32, " found %lld\n", + (long long)DISP_OPEN_OPEN); + LASSERTF(MDS_STATUS_CONN == 1, " found %lld\n", + (long long)MDS_STATUS_CONN); + LASSERTF(MDS_STATUS_LOV == 2, " found %lld\n", + (long long)MDS_STATUS_LOV); + LASSERTF(MDS_OPEN_HAS_EA == 1073741824, " found %lld\n", + (long long)MDS_OPEN_HAS_EA); + LASSERTF(LDLM_ENQUEUE == 101, " found %lld\n", + (long long)LDLM_ENQUEUE); + LASSERTF(LDLM_CONVERT == 102, " found %lld\n", + (long long)LDLM_CONVERT); + LASSERTF(LDLM_CANCEL == 103, " found %lld\n", + (long long)LDLM_CANCEL); + LASSERTF(LDLM_BL_CALLBACK == 104, " found %lld\n", + (long long)LDLM_BL_CALLBACK); + LASSERTF(LDLM_CP_CALLBACK == 105, " found %lld\n", + (long long)LDLM_CP_CALLBACK); + LASSERTF(LDLM_LAST_OPC == 107, " found %lld\n", + (long long)LDLM_LAST_OPC); + LASSERTF(LCK_EX == 1, " found %lld\n", + (long long)LCK_EX); + LASSERTF(LCK_PW == 2, " found %lld\n", + (long long)LCK_PW); + LASSERTF(LCK_PR == 4, " found %lld\n", + (long long)LCK_PR); + LASSERTF(LCK_CW == 8, " found %lld\n", + (long long)LCK_CW); + LASSERTF(LCK_CR == 16, " found %lld\n", + (long long)LCK_CR); + LASSERTF(LCK_NL == 32, " found %lld\n", + (long long)LCK_NL); + LASSERTF(PTLBD_QUERY == 200, " found %lld\n", + (long long)PTLBD_QUERY); + LASSERTF(PTLBD_READ == 201, " found %lld\n", + (long long)PTLBD_READ); + LASSERTF(PTLBD_WRITE == 202, " found %lld\n", + (long long)PTLBD_WRITE); + LASSERTF(PTLBD_FLUSH == 203, " found %lld\n", + (long long)PTLBD_FLUSH); + LASSERTF(PTLBD_CONNECT == 204, " found %lld\n", + (long long)PTLBD_CONNECT); + LASSERTF(PTLBD_DISCONNECT == 205, " found %lld\n", + (long long)PTLBD_DISCONNECT); + LASSERTF(PTLBD_LAST_OPC == 206, " found %lld\n", + (long long)PTLBD_LAST_OPC); + LASSERTF(MGMT_CONNECT == 250, " found %lld\n", + (long long)MGMT_CONNECT); + LASSERTF(MGMT_DISCONNECT == 251, " found %lld\n", + (long long)MGMT_DISCONNECT); + LASSERTF(MGMT_EXCEPTION == 252, " found %lld\n", + (long long)MGMT_EXCEPTION); + LASSERTF(OBD_PING == 400, " found %lld\n", + (long long)OBD_PING); + LASSERTF(OBD_LOG_CANCEL == 401, " found %lld\n", + (long long)OBD_LOG_CANCEL); + LASSERTF(OBD_LAST_OPC == 402, " found %lld\n", + (long long)OBD_LAST_OPC); + /* Sizes and Offsets */ + + + /* Checks for struct lustre_handle */ + LASSERTF((int)sizeof(struct lustre_handle) == 8, " found %lld\n", + (long long)(int)sizeof(struct lustre_handle)); + LASSERTF((int)offsetof(struct lustre_handle, cookie) == 0, " found %lld\n", + (long long)(int)offsetof(struct lustre_handle, cookie)); + LASSERTF((int)sizeof(((struct lustre_handle *)0)->cookie) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lustre_handle *)0)->cookie)); + + /* Checks for struct lustre_msg */ + LASSERTF((int)sizeof(struct lustre_msg) == 64, " found %lld\n", + (long long)(int)sizeof(struct lustre_msg)); + LASSERTF((int)offsetof(struct lustre_msg, handle) == 0, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, handle)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->handle) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->handle)); + LASSERTF((int)offsetof(struct lustre_msg, magic) == 8, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, magic)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->magic) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->magic)); + LASSERTF((int)offsetof(struct lustre_msg, type) == 12, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, type)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->type) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->type)); + LASSERTF((int)offsetof(struct lustre_msg, version) == 16, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, version)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->version) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->version)); + LASSERTF((int)offsetof(struct lustre_msg, opc) == 20, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, opc)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->opc) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->opc)); + LASSERTF((int)offsetof(struct lustre_msg, last_xid) == 24, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, last_xid)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->last_xid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->last_xid)); + LASSERTF((int)offsetof(struct lustre_msg, last_committed) == 32, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, last_committed)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->last_committed) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->last_committed)); + LASSERTF((int)offsetof(struct lustre_msg, transno) == 40, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, transno)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->transno) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->transno)); + LASSERTF((int)offsetof(struct lustre_msg, status) == 48, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, status)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->status) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->status)); + LASSERTF((int)offsetof(struct lustre_msg, flags) == 52, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, flags)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->flags)); + LASSERTF((int)offsetof(struct lustre_msg, bufcount) == 60, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, bufcount)); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->bufcount) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->bufcount)); + LASSERTF((int)offsetof(struct lustre_msg, buflens[7]) == 92, " found %lld\n", + (long long)(int)offsetof(struct lustre_msg, buflens[7])); + LASSERTF((int)sizeof(((struct lustre_msg *)0)->buflens[7]) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lustre_msg *)0)->buflens[7])); + + /* Checks for struct obdo */ + LASSERTF((int)sizeof(struct obdo) == 176, " found %lld\n", + (long long)(int)sizeof(struct obdo)); + LASSERTF((int)offsetof(struct obdo, o_id) == 0, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_id)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_id) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_id)); + LASSERTF((int)offsetof(struct obdo, o_gr) == 8, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_gr)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_gr) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_gr)); + LASSERTF((int)offsetof(struct obdo, o_atime) == 32, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_atime)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_atime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_atime)); + LASSERTF((int)offsetof(struct obdo, o_mtime) == 24, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_mtime)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_mtime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_mtime)); + LASSERTF((int)offsetof(struct obdo, o_ctime) == 40, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_ctime)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_ctime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_ctime)); + LASSERTF((int)offsetof(struct obdo, o_size) == 16, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_size)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_size) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_size)); + LASSERTF((int)offsetof(struct obdo, o_blocks) == 48, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_blocks)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_blocks) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_blocks)); + LASSERTF((int)offsetof(struct obdo, o_grant) == 56, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_grant)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_grant) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_grant)); + LASSERTF((int)offsetof(struct obdo, o_blksize) == 64, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_blksize)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_blksize) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_blksize)); + LASSERTF((int)offsetof(struct obdo, o_mode) == 68, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_mode)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_mode)); + LASSERTF((int)offsetof(struct obdo, o_uid) == 72, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_uid)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_uid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_uid)); + LASSERTF((int)offsetof(struct obdo, o_gid) == 76, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_gid)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_gid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_gid)); + LASSERTF((int)offsetof(struct obdo, o_flags) == 80, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_flags)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_flags)); + LASSERTF((int)offsetof(struct obdo, o_nlink) == 84, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_nlink)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_nlink) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_nlink)); + LASSERTF((int)offsetof(struct obdo, o_generation) == 88, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_generation)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_generation) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_generation)); + LASSERTF((int)offsetof(struct obdo, o_valid) == 92, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_valid)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_valid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_valid)); + LASSERTF((int)offsetof(struct obdo, o_misc) == 96, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_misc)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_misc) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_misc)); + LASSERTF((int)offsetof(struct obdo, o_easize) == 100, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_easize)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_easize) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_easize)); + LASSERTF((int)offsetof(struct obdo, o_mds) == 104, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_mds)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_mds) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_mds)); + LASSERTF((int)offsetof(struct obdo, o_padding) == 108, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_padding)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_padding) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_padding)); + LASSERTF((int)offsetof(struct obdo, o_inline) == 112, " found %lld\n", + (long long)(int)offsetof(struct obdo, o_inline)); + LASSERTF((int)sizeof(((struct obdo *)0)->o_inline) == 64, " found %lld\n", + (long long)(int)sizeof(((struct obdo *)0)->o_inline)); + LASSERTF(OBD_MD_FLID == 1, " found %lld\n", + (long long)OBD_MD_FLID); + LASSERTF(OBD_MD_FLATIME == 2, " found %lld\n", + (long long)OBD_MD_FLATIME); + LASSERTF(OBD_MD_FLMTIME == 4, " found %lld\n", + (long long)OBD_MD_FLMTIME); + LASSERTF(OBD_MD_FLCTIME == 8, " found %lld\n", + (long long)OBD_MD_FLCTIME); + LASSERTF(OBD_MD_FLSIZE == 16, " found %lld\n", + (long long)OBD_MD_FLSIZE); + LASSERTF(OBD_MD_FLBLOCKS == 32, " found %lld\n", + (long long)OBD_MD_FLBLOCKS); + LASSERTF(OBD_MD_FLBLKSZ == 64, " found %lld\n", + (long long)OBD_MD_FLBLKSZ); + LASSERTF(OBD_MD_FLMODE == 128, " found %lld\n", + (long long)OBD_MD_FLMODE); + LASSERTF(OBD_MD_FLTYPE == 256, " found %lld\n", + (long long)OBD_MD_FLTYPE); + LASSERTF(OBD_MD_FLUID == 512, " found %lld\n", + (long long)OBD_MD_FLUID); + LASSERTF(OBD_MD_FLGID == 1024, " found %lld\n", + (long long)OBD_MD_FLGID); + LASSERTF(OBD_MD_FLFLAGS == 2048, " found %lld\n", + (long long)OBD_MD_FLFLAGS); + LASSERTF(OBD_MD_FLNLINK == 8192, " found %lld\n", + (long long)OBD_MD_FLNLINK); + LASSERTF(OBD_MD_FLGENER == 16384, " found %lld\n", + (long long)OBD_MD_FLGENER); + LASSERTF(OBD_MD_FLINLINE == 32768, " found %lld\n", + (long long)OBD_MD_FLINLINE); + LASSERTF(OBD_MD_FLRDEV == 65536, " found %lld\n", + (long long)OBD_MD_FLRDEV); + LASSERTF(OBD_MD_FLEASIZE == 131072, " found %lld\n", + (long long)OBD_MD_FLEASIZE); + LASSERTF(OBD_MD_LINKNAME == 262144, " found %lld\n", + (long long)OBD_MD_LINKNAME); + LASSERTF(OBD_MD_FLHANDLE == 524288, " found %lld\n", + (long long)OBD_MD_FLHANDLE); + LASSERTF(OBD_MD_FLCKSUM == 1048576, " found %lld\n", + (long long)OBD_MD_FLCKSUM); + LASSERTF(OBD_MD_FLQOS == 2097152, " found %lld\n", + (long long)OBD_MD_FLQOS); + LASSERTF(OBD_MD_FLOSCOPQ == 4194304, " found %lld\n", + (long long)OBD_MD_FLOSCOPQ); + LASSERTF(OBD_MD_FLCOOKIE == 8388608, " found %lld\n", + (long long)OBD_MD_FLCOOKIE); + LASSERTF(OBD_MD_FLGROUP == 16777216, " found %lld\n", + (long long)OBD_MD_FLGROUP); + LASSERTF(OBD_FL_INLINEDATA == 1, " found %lld\n", + (long long)OBD_FL_INLINEDATA); + LASSERTF(OBD_FL_OBDMDEXISTS == 2, " found %lld\n", + (long long)OBD_FL_OBDMDEXISTS); + LASSERTF(OBD_FL_DELORPHAN == 4, " found %lld\n", + (long long)OBD_FL_DELORPHAN); + LASSERTF(OBD_FL_NORPC == 8, " found %lld\n", + (long long)OBD_FL_NORPC); + LASSERTF(OBD_FL_IDONLY == 16, " found %lld\n", + (long long)OBD_FL_IDONLY); + LASSERTF(OBD_FL_RECREATE_OBJS == 32, " found %lld\n", + (long long)OBD_FL_RECREATE_OBJS); + + /* Checks for struct lov_mds_md_v1 */ + LASSERTF((int)sizeof(struct lov_mds_md_v1) == 32, " found %lld\n", + (long long)(int)sizeof(struct lov_mds_md_v1)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_magic) == 0, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_magic)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_magic) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_magic)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_pattern) == 4, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_pattern)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_pattern) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_pattern)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_object_id) == 8, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_object_id)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_id) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_id)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_object_gr) == 16, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_object_gr)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_gr) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_gr)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_stripe_size) == 24, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_stripe_size)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_size) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_size)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_stripe_count) == 28, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_stripe_count)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_count) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_count)); + LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_objects) == 32, " found %lld\n", + (long long)(int)offsetof(struct lov_mds_md_v1, lmm_objects)); + LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects) == 0, " found %lld\n", + (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects)); + + /* Checks for struct lov_ost_data_v1 */ + LASSERTF((int)sizeof(struct lov_ost_data_v1) == 24, " found %lld\n", + (long long)(int)sizeof(struct lov_ost_data_v1)); + LASSERTF((int)offsetof(struct lov_ost_data_v1, l_object_id) == 0, " found %lld\n", + (long long)(int)offsetof(struct lov_ost_data_v1, l_object_id)); + LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_id) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_id)); + LASSERTF((int)offsetof(struct lov_ost_data_v1, l_object_gr) == 8, " found %lld\n", + (long long)(int)offsetof(struct lov_ost_data_v1, l_object_gr)); + LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_gr) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_gr)); + LASSERTF((int)offsetof(struct lov_ost_data_v1, l_ost_gen) == 16, " found %lld\n", + (long long)(int)offsetof(struct lov_ost_data_v1, l_ost_gen)); + LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_gen) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_gen)); + LASSERTF((int)offsetof(struct lov_ost_data_v1, l_ost_idx) == 20, " found %lld\n", + (long long)(int)offsetof(struct lov_ost_data_v1, l_ost_idx)); + LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_idx) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_idx)); + LASSERTF(LOV_MAGIC_V0 == 198183888, " found %lld\n", + (long long)LOV_MAGIC_V0); + LASSERTF(LOV_MAGIC_V1 == 198249424, " found %lld\n", + (long long)LOV_MAGIC_V1); + LASSERTF(LOV_PATTERN_RAID0 == 1, " found %lld\n", + (long long)LOV_PATTERN_RAID0); + LASSERTF(LOV_PATTERN_RAID1 == 2, " found %lld\n", + (long long)LOV_PATTERN_RAID1); + + /* Checks for struct obd_statfs */ + LASSERTF((int)sizeof(struct obd_statfs) == 144, " found %lld\n", + (long long)(int)sizeof(struct obd_statfs)); + LASSERTF((int)offsetof(struct obd_statfs, os_type) == 0, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_type)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_type) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_type)); + LASSERTF((int)offsetof(struct obd_statfs, os_blocks) == 8, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_blocks)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_blocks) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_blocks)); + LASSERTF((int)offsetof(struct obd_statfs, os_bfree) == 16, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_bfree)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_bfree) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_bfree)); + LASSERTF((int)offsetof(struct obd_statfs, os_bavail) == 24, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_bavail)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_bavail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_bavail)); + LASSERTF((int)offsetof(struct obd_statfs, os_ffree) == 40, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_ffree)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_ffree) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_ffree)); + LASSERTF((int)offsetof(struct obd_statfs, os_fsid) == 48, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_fsid)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_fsid) == 40, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_fsid)); + LASSERTF((int)offsetof(struct obd_statfs, os_bsize) == 88, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_bsize)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_bsize) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_bsize)); + LASSERTF((int)offsetof(struct obd_statfs, os_namelen) == 92, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_namelen)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_namelen) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_namelen)); + LASSERTF((int)offsetof(struct obd_statfs, os_spare) == 104, " found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_spare)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_spare) == 40, " found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_spare)); + + /* Checks for struct obd_ioobj */ + LASSERTF((int)sizeof(struct obd_ioobj) == 24, " found %lld\n", + (long long)(int)sizeof(struct obd_ioobj)); + LASSERTF((int)offsetof(struct obd_ioobj, ioo_id) == 0, " found %lld\n", + (long long)(int)offsetof(struct obd_ioobj, ioo_id)); + LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_id) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_id)); + LASSERTF((int)offsetof(struct obd_ioobj, ioo_gr) == 8, " found %lld\n", + (long long)(int)offsetof(struct obd_ioobj, ioo_gr)); + LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_gr) == 8, " found %lld\n", + (long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_gr)); + LASSERTF((int)offsetof(struct obd_ioobj, ioo_type) == 16, " found %lld\n", + (long long)(int)offsetof(struct obd_ioobj, ioo_type)); + LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_type) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_type)); + LASSERTF((int)offsetof(struct obd_ioobj, ioo_bufcnt) == 20, " found %lld\n", + (long long)(int)offsetof(struct obd_ioobj, ioo_bufcnt)); + LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt) == 4, " found %lld\n", + (long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt)); + + /* Checks for struct niobuf_remote */ + LASSERTF((int)sizeof(struct niobuf_remote) == 16, " found %lld\n", + (long long)(int)sizeof(struct niobuf_remote)); + LASSERTF((int)offsetof(struct niobuf_remote, offset) == 0, " found %lld\n", + (long long)(int)offsetof(struct niobuf_remote, offset)); + LASSERTF((int)sizeof(((struct niobuf_remote *)0)->offset) == 8, " found %lld\n", + (long long)(int)sizeof(((struct niobuf_remote *)0)->offset)); + LASSERTF((int)offsetof(struct niobuf_remote, len) == 8, " found %lld\n", + (long long)(int)offsetof(struct niobuf_remote, len)); + LASSERTF((int)sizeof(((struct niobuf_remote *)0)->len) == 4, " found %lld\n", + (long long)(int)sizeof(((struct niobuf_remote *)0)->len)); + LASSERTF((int)offsetof(struct niobuf_remote, flags) == 12, " found %lld\n", + (long long)(int)offsetof(struct niobuf_remote, flags)); + LASSERTF((int)sizeof(((struct niobuf_remote *)0)->flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct niobuf_remote *)0)->flags)); + LASSERTF(OBD_BRW_READ == 1, " found %lld\n", + (long long)OBD_BRW_READ); + LASSERTF(OBD_BRW_WRITE == 2, " found %lld\n", + (long long)OBD_BRW_WRITE); + LASSERTF(OBD_BRW_SYNC == 8, " found %lld\n", + (long long)OBD_BRW_SYNC); + LASSERTF(OBD_BRW_FROM_GRANT == 32, " found %lld\n", + (long long)OBD_BRW_FROM_GRANT); + + /* Checks for struct ost_body */ + LASSERTF((int)sizeof(struct ost_body) == 176, " found %lld\n", + (long long)(int)sizeof(struct ost_body)); + LASSERTF((int)offsetof(struct ost_body, oa) == 0, " found %lld\n", + (long long)(int)offsetof(struct ost_body, oa)); + LASSERTF((int)sizeof(((struct ost_body *)0)->oa) == 176, " found %lld\n", + (long long)(int)sizeof(((struct ost_body *)0)->oa)); + + /* Checks for struct ll_fid */ + LASSERTF((int)sizeof(struct ll_fid) == 24, " found %lld\n", + (long long)(int)sizeof(struct ll_fid)); + LASSERTF((int)offsetof(struct ll_fid, id) == 0, " found %lld\n", + (long long)(int)offsetof(struct ll_fid, id)); + LASSERTF((int)sizeof(((struct ll_fid *)0)->id) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ll_fid *)0)->id)); + LASSERTF((int)offsetof(struct ll_fid, generation) == 8, " found %lld\n", + (long long)(int)offsetof(struct ll_fid, generation)); + LASSERTF((int)sizeof(((struct ll_fid *)0)->generation) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ll_fid *)0)->generation)); + LASSERTF((int)offsetof(struct ll_fid, f_type) == 12, " found %lld\n", + (long long)(int)offsetof(struct ll_fid, f_type)); + LASSERTF((int)sizeof(((struct ll_fid *)0)->f_type) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ll_fid *)0)->f_type)); + + /* Checks for struct mds_status_req */ + LASSERTF((int)sizeof(struct mds_status_req) == 8, " found %lld\n", + (long long)(int)sizeof(struct mds_status_req)); + LASSERTF((int)offsetof(struct mds_status_req, flags) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_status_req, flags)); + LASSERTF((int)sizeof(((struct mds_status_req *)0)->flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_status_req *)0)->flags)); + LASSERTF((int)offsetof(struct mds_status_req, repbuf) == 4, " found %lld\n", + (long long)(int)offsetof(struct mds_status_req, repbuf)); + LASSERTF((int)sizeof(((struct mds_status_req *)0)->repbuf) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_status_req *)0)->repbuf)); + + /* Checks for struct mds_body */ + LASSERTF((int)sizeof(struct mds_body) == 136, " found %lld\n", + (long long)(int)sizeof(struct mds_body)); + LASSERTF((int)offsetof(struct mds_body, fid1) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_body, fid1)); + LASSERTF((int)sizeof(((struct mds_body *)0)->fid1) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->fid1)); + LASSERTF((int)offsetof(struct mds_body, fid2) == 24, " found %lld\n", + (long long)(int)offsetof(struct mds_body, fid2)); + LASSERTF((int)sizeof(((struct mds_body *)0)->fid2) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->fid2)); + LASSERTF((int)offsetof(struct mds_body, handle) == 48, " found %lld\n", + (long long)(int)offsetof(struct mds_body, handle)); + LASSERTF((int)sizeof(((struct mds_body *)0)->handle) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->handle)); + LASSERTF((int)offsetof(struct mds_body, size) == 56, " found %lld\n", + (long long)(int)offsetof(struct mds_body, size)); + LASSERTF((int)sizeof(((struct mds_body *)0)->size) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->size)); + LASSERTF((int)offsetof(struct mds_body, blocks) == 64, " found %lld\n", + (long long)(int)offsetof(struct mds_body, blocks)); + LASSERTF((int)sizeof(((struct mds_body *)0)->blocks) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->blocks)); + LASSERTF((int)offsetof(struct mds_body, io_epoch) == 72, " found %lld\n", + (long long)(int)offsetof(struct mds_body, io_epoch)); + LASSERTF((int)sizeof(((struct mds_body *)0)->io_epoch) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->io_epoch)); + LASSERTF((int)offsetof(struct mds_body, ino) == 80, " found %lld\n", + (long long)(int)offsetof(struct mds_body, ino)); + LASSERTF((int)sizeof(((struct mds_body *)0)->ino) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->ino)); + LASSERTF((int)offsetof(struct mds_body, valid) == 84, " found %lld\n", + (long long)(int)offsetof(struct mds_body, valid)); + LASSERTF((int)sizeof(((struct mds_body *)0)->valid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->valid)); + LASSERTF((int)offsetof(struct mds_body, mode) == 88, " found %lld\n", + (long long)(int)offsetof(struct mds_body, mode)); + LASSERTF((int)sizeof(((struct mds_body *)0)->mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->mode)); + LASSERTF((int)offsetof(struct mds_body, uid) == 92, " found %lld\n", + (long long)(int)offsetof(struct mds_body, uid)); + LASSERTF((int)sizeof(((struct mds_body *)0)->uid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->uid)); + LASSERTF((int)offsetof(struct mds_body, gid) == 96, " found %lld\n", + (long long)(int)offsetof(struct mds_body, gid)); + LASSERTF((int)sizeof(((struct mds_body *)0)->gid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->gid)); + LASSERTF((int)offsetof(struct mds_body, mtime) == 100, " found %lld\n", + (long long)(int)offsetof(struct mds_body, mtime)); + LASSERTF((int)sizeof(((struct mds_body *)0)->mtime) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->mtime)); + LASSERTF((int)offsetof(struct mds_body, ctime) == 104, " found %lld\n", + (long long)(int)offsetof(struct mds_body, ctime)); + LASSERTF((int)sizeof(((struct mds_body *)0)->ctime) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->ctime)); + LASSERTF((int)offsetof(struct mds_body, atime) == 108, " found %lld\n", + (long long)(int)offsetof(struct mds_body, atime)); + LASSERTF((int)sizeof(((struct mds_body *)0)->atime) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->atime)); + LASSERTF((int)offsetof(struct mds_body, flags) == 112, " found %lld\n", + (long long)(int)offsetof(struct mds_body, flags)); + LASSERTF((int)sizeof(((struct mds_body *)0)->flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->flags)); + LASSERTF((int)offsetof(struct mds_body, rdev) == 116, " found %lld\n", + (long long)(int)offsetof(struct mds_body, rdev)); + LASSERTF((int)sizeof(((struct mds_body *)0)->rdev) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->rdev)); + LASSERTF((int)offsetof(struct mds_body, nlink) == 120, " found %lld\n", + (long long)(int)offsetof(struct mds_body, nlink)); + LASSERTF((int)sizeof(((struct mds_body *)0)->nlink) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->nlink)); + LASSERTF((int)offsetof(struct mds_body, generation) == 124, " found %lld\n", + (long long)(int)offsetof(struct mds_body, generation)); + LASSERTF((int)sizeof(((struct mds_body *)0)->generation) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->generation)); + LASSERTF((int)offsetof(struct mds_body, eadatasize) == 128, " found %lld\n", + (long long)(int)offsetof(struct mds_body, eadatasize)); + LASSERTF((int)sizeof(((struct mds_body *)0)->eadatasize) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->eadatasize)); + LASSERTF((int)offsetof(struct mds_body, mds) == 132, " found %lld\n", + (long long)(int)offsetof(struct mds_body, mds)); + LASSERTF((int)sizeof(((struct mds_body *)0)->mds) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_body *)0)->mds)); + LASSERTF(FMODE_READ == 1, " found %lld\n", + (long long)FMODE_READ); + LASSERTF(FMODE_WRITE == 2, " found %lld\n", + (long long)FMODE_WRITE); + LASSERTF(FMODE_EXEC == 4, " found %lld\n", + (long long)FMODE_EXEC); + LASSERTF(MDS_OPEN_CREAT == 64, " found %lld\n", + (long long)MDS_OPEN_CREAT); + LASSERTF(MDS_OPEN_EXCL == 128, " found %lld\n", + (long long)MDS_OPEN_EXCL); + LASSERTF(MDS_OPEN_TRUNC == 512, " found %lld\n", + (long long)MDS_OPEN_TRUNC); + LASSERTF(MDS_OPEN_APPEND == 1024, " found %lld\n", + (long long)MDS_OPEN_APPEND); + LASSERTF(MDS_OPEN_SYNC == 4096, " found %lld\n", + (long long)MDS_OPEN_SYNC); + LASSERTF(MDS_OPEN_DIRECTORY == 65536, " found %lld\n", + (long long)MDS_OPEN_DIRECTORY); + LASSERTF(MDS_OPEN_DELAY_CREATE == 16777216, " found %lld\n", + (long long)MDS_OPEN_DELAY_CREATE); + LASSERTF(MDS_OPEN_HAS_EA == 1073741824, " found %lld\n", + (long long)MDS_OPEN_HAS_EA); + + /* Checks for struct mds_rec_setattr */ + LASSERTF((int)sizeof(struct mds_rec_setattr) == 80, " found %lld\n", + (long long)(int)sizeof(struct mds_rec_setattr)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_opcode) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_opcode)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_opcode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_opcode)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_valid) == 4, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_valid)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_valid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_valid)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_fid) == 8, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_fid)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_fid) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_fid)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_mode) == 32, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_mode)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_mode)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_uid) == 36, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_uid)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_uid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_uid)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_gid) == 40, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_gid)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_gid) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_gid)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_attr_flags) == 44, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_attr_flags)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_attr_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_attr_flags)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_size) == 48, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_size)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_size) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_size)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_atime) == 56, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_atime)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_atime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_atime)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_mtime) == 64, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_mtime)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_mtime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_mtime)); + LASSERTF((int)offsetof(struct mds_rec_setattr, sa_ctime) == 72, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_setattr, sa_ctime)); + LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_ctime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_ctime)); + + /* Checks for struct mds_rec_create */ + LASSERTF((int)sizeof(struct mds_rec_create) == 80, " found %lld\n", + (long long)(int)sizeof(struct mds_rec_create)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_opcode) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_opcode)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_opcode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_opcode)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_flags) == 4, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_flags)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_flags)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_mode) == 8, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_mode)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_mode)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_padding) == 12, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_padding)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_padding) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_padding)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_fid) == 16, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_fid)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_fid) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_fid)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_replayfid) == 40, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_replayfid)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_replayfid) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_replayfid)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_time) == 64, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_time)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_time) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_time)); + LASSERTF((int)offsetof(struct mds_rec_create, cr_rdev) == 72, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_create, cr_rdev)); + LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_rdev) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_create *)0)->cr_rdev)); + + /* Checks for struct mds_rec_link */ + LASSERTF((int)sizeof(struct mds_rec_link) == 64, " found %lld\n", + (long long)(int)sizeof(struct mds_rec_link)); + LASSERTF((int)offsetof(struct mds_rec_link, lk_opcode) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_link, lk_opcode)); + LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_opcode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_link *)0)->lk_opcode)); + LASSERTF((int)offsetof(struct mds_rec_link, lk_padding) == 4, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_link, lk_padding)); + LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_padding) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_link *)0)->lk_padding)); + LASSERTF((int)offsetof(struct mds_rec_link, lk_fid1) == 8, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_link, lk_fid1)); + LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_fid1) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_link *)0)->lk_fid1)); + LASSERTF((int)offsetof(struct mds_rec_link, lk_fid2) == 32, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_link, lk_fid2)); + LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_fid2) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_link *)0)->lk_fid2)); + LASSERTF((int)offsetof(struct mds_rec_link, lk_time) == 56, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_link, lk_time)); + LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_time) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_link *)0)->lk_time)); + + /* Checks for struct mds_rec_unlink */ + LASSERTF((int)sizeof(struct mds_rec_unlink) == 64, " found %lld\n", + (long long)(int)sizeof(struct mds_rec_unlink)); + LASSERTF((int)offsetof(struct mds_rec_unlink, ul_opcode) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_unlink, ul_opcode)); + LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_opcode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_opcode)); + LASSERTF((int)offsetof(struct mds_rec_unlink, ul_mode) == 4, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_unlink, ul_mode)); + LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_mode)); + LASSERTF((int)offsetof(struct mds_rec_unlink, ul_fid1) == 8, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_unlink, ul_fid1)); + LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_fid1) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_fid1)); + LASSERTF((int)offsetof(struct mds_rec_unlink, ul_fid2) == 32, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_unlink, ul_fid2)); + LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_fid2) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_fid2)); + LASSERTF((int)offsetof(struct mds_rec_unlink, ul_time) == 56, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_unlink, ul_time)); + LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_time) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_time)); + + /* Checks for struct mds_rec_rename */ + LASSERTF((int)sizeof(struct mds_rec_rename) == 64, " found %lld\n", + (long long)(int)sizeof(struct mds_rec_rename)); + LASSERTF((int)offsetof(struct mds_rec_rename, rn_opcode) == 0, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_rename, rn_opcode)); + LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_opcode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_opcode)); + LASSERTF((int)offsetof(struct mds_rec_rename, rn_padding) == 4, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_rename, rn_padding)); + LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_padding) == 4, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_padding)); + LASSERTF((int)offsetof(struct mds_rec_rename, rn_fid1) == 8, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_rename, rn_fid1)); + LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_fid1) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_fid1)); + LASSERTF((int)offsetof(struct mds_rec_rename, rn_fid2) == 32, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_rename, rn_fid2)); + LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_fid2) == 24, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_fid2)); + LASSERTF((int)offsetof(struct mds_rec_rename, rn_time) == 56, " found %lld\n", + (long long)(int)offsetof(struct mds_rec_rename, rn_time)); + LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_time) == 8, " found %lld\n", + (long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_time)); + + /* Checks for struct lov_desc */ + LASSERTF((int)sizeof(struct lov_desc) == 72, " found %lld\n", + (long long)(int)sizeof(struct lov_desc)); + LASSERTF((int)offsetof(struct lov_desc, ld_tgt_count) == 0, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_tgt_count)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_tgt_count) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_tgt_count)); + LASSERTF((int)offsetof(struct lov_desc, ld_active_tgt_count) == 4, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_active_tgt_count)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_active_tgt_count) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_active_tgt_count)); + LASSERTF((int)offsetof(struct lov_desc, ld_default_stripe_count) == 8, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_default_stripe_count)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_default_stripe_count) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_default_stripe_count)); + LASSERTF((int)offsetof(struct lov_desc, ld_pattern) == 12, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_pattern)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_pattern) == 4, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_pattern)); + LASSERTF((int)offsetof(struct lov_desc, ld_default_stripe_size) == 16, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_default_stripe_size)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_default_stripe_size) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_default_stripe_size)); + LASSERTF((int)offsetof(struct lov_desc, ld_default_stripe_offset) == 24, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_default_stripe_offset)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_default_stripe_offset) == 8, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_default_stripe_offset)); + LASSERTF((int)offsetof(struct lov_desc, ld_uuid) == 32, " found %lld\n", + (long long)(int)offsetof(struct lov_desc, ld_uuid)); + LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_uuid) == 40, " found %lld\n", + (long long)(int)sizeof(((struct lov_desc *)0)->ld_uuid)); + + /* Checks for struct ldlm_res_id */ + LASSERTF((int)sizeof(struct ldlm_res_id) == 32, " found %lld\n", + (long long)(int)sizeof(struct ldlm_res_id)); + LASSERTF((int)offsetof(struct ldlm_res_id, name[4]) == 32, " found %lld\n", + (long long)(int)offsetof(struct ldlm_res_id, name[4])); + LASSERTF((int)sizeof(((struct ldlm_res_id *)0)->name[4]) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_res_id *)0)->name[4])); + + /* Checks for struct ldlm_extent */ + LASSERTF((int)sizeof(struct ldlm_extent) == 24, " found %lld\n", + (long long)(int)sizeof(struct ldlm_extent)); + LASSERTF((int)offsetof(struct ldlm_extent, start) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_extent, start)); + LASSERTF((int)sizeof(((struct ldlm_extent *)0)->start) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_extent *)0)->start)); + LASSERTF((int)offsetof(struct ldlm_extent, end) == 8, " found %lld\n", + (long long)(int)offsetof(struct ldlm_extent, end)); + LASSERTF((int)sizeof(((struct ldlm_extent *)0)->end) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_extent *)0)->end)); + LASSERTF((int)offsetof(struct ldlm_extent, gid) == 16, " found %lld\n", + (long long)(int)offsetof(struct ldlm_extent, gid)); + LASSERTF((int)sizeof(((struct ldlm_extent *)0)->gid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_extent *)0)->gid)); + + /* Checks for struct ldlm_flock */ + LASSERTF((int)sizeof(struct ldlm_flock) == 40, " found %lld\n", + (long long)(int)sizeof(struct ldlm_flock)); + LASSERTF((int)offsetof(struct ldlm_flock, start) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_flock, start)); + LASSERTF((int)sizeof(((struct ldlm_flock *)0)->start) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_flock *)0)->start)); + LASSERTF((int)offsetof(struct ldlm_flock, end) == 8, " found %lld\n", + (long long)(int)offsetof(struct ldlm_flock, end)); + LASSERTF((int)sizeof(((struct ldlm_flock *)0)->end) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_flock *)0)->end)); + LASSERTF((int)offsetof(struct ldlm_flock, pid) == 16, " found %lld\n", + (long long)(int)offsetof(struct ldlm_flock, pid)); + LASSERTF((int)sizeof(((struct ldlm_flock *)0)->pid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_flock *)0)->pid)); + LASSERTF((int)offsetof(struct ldlm_flock, blocking_pid) == 24, " found %lld\n", + (long long)(int)offsetof(struct ldlm_flock, blocking_pid)); + LASSERTF((int)sizeof(((struct ldlm_flock *)0)->blocking_pid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_flock *)0)->blocking_pid)); + LASSERTF((int)offsetof(struct ldlm_flock, blocking_export) == 32, " found %lld\n", + (long long)(int)offsetof(struct ldlm_flock, blocking_export)); + LASSERTF((int)sizeof(((struct ldlm_flock *)0)->blocking_export) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_flock *)0)->blocking_export)); + + /* Checks for struct ldlm_intent */ + LASSERTF((int)sizeof(struct ldlm_intent) == 8, " found %lld\n", + (long long)(int)sizeof(struct ldlm_intent)); + LASSERTF((int)offsetof(struct ldlm_intent, opc) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_intent, opc)); + LASSERTF((int)sizeof(((struct ldlm_intent *)0)->opc) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_intent *)0)->opc)); + + /* Checks for struct ldlm_resource_desc */ + LASSERTF((int)sizeof(struct ldlm_resource_desc) == 40, " found %lld\n", + (long long)(int)sizeof(struct ldlm_resource_desc)); + LASSERTF((int)offsetof(struct ldlm_resource_desc, lr_type) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_resource_desc, lr_type)); + LASSERTF((int)sizeof(((struct ldlm_resource_desc *)0)->lr_type) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_resource_desc *)0)->lr_type)); + LASSERTF((int)offsetof(struct ldlm_resource_desc, lr_name) == 8, " found %lld\n", + (long long)(int)offsetof(struct ldlm_resource_desc, lr_name)); + LASSERTF((int)sizeof(((struct ldlm_resource_desc *)0)->lr_name) == 32, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_resource_desc *)0)->lr_name)); + + /* Checks for struct ldlm_lock_desc */ + LASSERTF((int)sizeof(struct ldlm_lock_desc) == 88, " found %lld\n", + (long long)(int)sizeof(struct ldlm_lock_desc)); + LASSERTF((int)offsetof(struct ldlm_lock_desc, l_resource) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_lock_desc, l_resource)); + LASSERTF((int)sizeof(((struct ldlm_lock_desc *)0)->l_resource) == 40, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_lock_desc *)0)->l_resource)); + LASSERTF((int)offsetof(struct ldlm_lock_desc, l_req_mode) == 40, " found %lld\n", + (long long)(int)offsetof(struct ldlm_lock_desc, l_req_mode)); + LASSERTF((int)sizeof(((struct ldlm_lock_desc *)0)->l_req_mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_lock_desc *)0)->l_req_mode)); + LASSERTF((int)offsetof(struct ldlm_lock_desc, l_granted_mode) == 44, " found %lld\n", + (long long)(int)offsetof(struct ldlm_lock_desc, l_granted_mode)); + LASSERTF((int)sizeof(((struct ldlm_lock_desc *)0)->l_granted_mode) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_lock_desc *)0)->l_granted_mode)); + LASSERTF((int)offsetof(struct ldlm_lock_desc, l_policy_data) == 48, " found %lld\n", + (long long)(int)offsetof(struct ldlm_lock_desc, l_policy_data)); + LASSERTF((int)sizeof(((struct ldlm_lock_desc *)0)->l_policy_data) == 40, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_lock_desc *)0)->l_policy_data)); + + /* Checks for struct ldlm_request */ + LASSERTF((int)sizeof(struct ldlm_request) == 112, " found %lld\n", + (long long)(int)sizeof(struct ldlm_request)); + LASSERTF((int)offsetof(struct ldlm_request, lock_flags) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_request, lock_flags)); + LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_request *)0)->lock_flags)); + LASSERTF((int)offsetof(struct ldlm_request, lock_desc) == 8, " found %lld\n", + (long long)(int)offsetof(struct ldlm_request, lock_desc)); + LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_desc) == 88, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_request *)0)->lock_desc)); + LASSERTF((int)offsetof(struct ldlm_request, lock_handle1) == 96, " found %lld\n", + (long long)(int)offsetof(struct ldlm_request, lock_handle1)); + LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_handle1) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_request *)0)->lock_handle1)); + LASSERTF((int)offsetof(struct ldlm_request, lock_handle2) == 104, " found %lld\n", + (long long)(int)offsetof(struct ldlm_request, lock_handle2)); + LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_handle2) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_request *)0)->lock_handle2)); + + /* Checks for struct ldlm_reply */ + LASSERTF((int)sizeof(struct ldlm_reply) == 120, " found %lld\n", + (long long)(int)sizeof(struct ldlm_reply)); + LASSERTF((int)offsetof(struct ldlm_reply, lock_flags) == 0, " found %lld\n", + (long long)(int)offsetof(struct ldlm_reply, lock_flags)); + LASSERTF((int)sizeof(((struct ldlm_reply *)0)->lock_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_reply *)0)->lock_flags)); + LASSERTF((int)offsetof(struct ldlm_request, lock_desc) == 8, " found %lld\n", + (long long)(int)offsetof(struct ldlm_request, lock_desc)); + LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_desc) == 88, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_request *)0)->lock_desc)); + LASSERTF((int)offsetof(struct ldlm_reply, lock_handle) == 96, " found %lld\n", + (long long)(int)offsetof(struct ldlm_reply, lock_handle)); + LASSERTF((int)sizeof(((struct ldlm_reply *)0)->lock_handle) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_reply *)0)->lock_handle)); + LASSERTF((int)offsetof(struct ldlm_reply, lock_policy_res1) == 104, " found %lld\n", + (long long)(int)offsetof(struct ldlm_reply, lock_policy_res1)); + LASSERTF((int)sizeof(((struct ldlm_reply *)0)->lock_policy_res1) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_reply *)0)->lock_policy_res1)); + LASSERTF((int)offsetof(struct ldlm_reply, lock_policy_res2) == 112, " found %lld\n", + (long long)(int)offsetof(struct ldlm_reply, lock_policy_res2)); + LASSERTF((int)sizeof(((struct ldlm_reply *)0)->lock_policy_res2) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ldlm_reply *)0)->lock_policy_res2)); + + /* Checks for struct ost_lvb */ + LASSERTF((int)sizeof(struct ost_lvb) == 40, " found %lld\n", + (long long)(int)sizeof(struct ost_lvb)); + LASSERTF((int)offsetof(struct ost_lvb, lvb_size) == 0, " found %lld\n", + (long long)(int)offsetof(struct ost_lvb, lvb_size)); + LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_size) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ost_lvb *)0)->lvb_size)); + LASSERTF((int)offsetof(struct ost_lvb, lvb_mtime) == 8, " found %lld\n", + (long long)(int)offsetof(struct ost_lvb, lvb_mtime)); + LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_mtime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ost_lvb *)0)->lvb_mtime)); + LASSERTF((int)offsetof(struct ost_lvb, lvb_atime) == 16, " found %lld\n", + (long long)(int)offsetof(struct ost_lvb, lvb_atime)); + LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_atime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ost_lvb *)0)->lvb_atime)); + LASSERTF((int)offsetof(struct ost_lvb, lvb_ctime) == 24, " found %lld\n", + (long long)(int)offsetof(struct ost_lvb, lvb_ctime)); + LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_ctime) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ost_lvb *)0)->lvb_ctime)); + LASSERTF((int)offsetof(struct ost_lvb, lvb_blocks) == 32, " found %lld\n", + (long long)(int)offsetof(struct ost_lvb, lvb_blocks)); + LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_blocks) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ost_lvb *)0)->lvb_blocks)); + + /* Checks for struct ptlbd_op */ + LASSERTF((int)sizeof(struct ptlbd_op) == 12, " found %lld\n", + (long long)(int)sizeof(struct ptlbd_op)); + LASSERTF((int)offsetof(struct ptlbd_op, op_cmd) == 0, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_op, op_cmd)); + LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op_cmd) == 2, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_op *)0)->op_cmd)); + LASSERTF((int)offsetof(struct ptlbd_op, op_lun) == 2, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_op, op_lun)); + LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op_lun) == 2, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_op *)0)->op_lun)); + LASSERTF((int)offsetof(struct ptlbd_op, op_niob_cnt) == 4, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_op, op_niob_cnt)); + LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op_niob_cnt) == 2, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_op *)0)->op_niob_cnt)); + LASSERTF((int)offsetof(struct ptlbd_op, op__padding) == 6, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_op, op__padding)); + LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op__padding) == 2, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_op *)0)->op__padding)); + LASSERTF((int)offsetof(struct ptlbd_op, op_block_cnt) == 8, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_op, op_block_cnt)); + LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op_block_cnt) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_op *)0)->op_block_cnt)); + + /* Checks for struct ptlbd_niob */ + LASSERTF((int)sizeof(struct ptlbd_niob) == 24, " found %lld\n", + (long long)(int)sizeof(struct ptlbd_niob)); + LASSERTF((int)offsetof(struct ptlbd_niob, n_xid) == 0, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_niob, n_xid)); + LASSERTF((int)sizeof(((struct ptlbd_niob *)0)->n_xid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_niob *)0)->n_xid)); + LASSERTF((int)offsetof(struct ptlbd_niob, n_block_nr) == 8, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_niob, n_block_nr)); + LASSERTF((int)sizeof(((struct ptlbd_niob *)0)->n_block_nr) == 8, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_niob *)0)->n_block_nr)); + LASSERTF((int)offsetof(struct ptlbd_niob, n_offset) == 16, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_niob, n_offset)); + LASSERTF((int)sizeof(((struct ptlbd_niob *)0)->n_offset) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_niob *)0)->n_offset)); + LASSERTF((int)offsetof(struct ptlbd_niob, n_length) == 20, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_niob, n_length)); + LASSERTF((int)sizeof(((struct ptlbd_niob *)0)->n_length) == 4, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_niob *)0)->n_length)); + + /* Checks for struct ptlbd_rsp */ + LASSERTF((int)sizeof(struct ptlbd_rsp) == 4, " found %lld\n", + (long long)(int)sizeof(struct ptlbd_rsp)); + LASSERTF((int)offsetof(struct ptlbd_rsp, r_status) == 0, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_rsp, r_status)); + LASSERTF((int)sizeof(((struct ptlbd_rsp *)0)->r_status) == 2, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_rsp *)0)->r_status)); + LASSERTF((int)offsetof(struct ptlbd_rsp, r_error_cnt) == 2, " found %lld\n", + (long long)(int)offsetof(struct ptlbd_rsp, r_error_cnt)); + LASSERTF((int)sizeof(((struct ptlbd_rsp *)0)->r_error_cnt) == 2, " found %lld\n", + (long long)(int)sizeof(((struct ptlbd_rsp *)0)->r_error_cnt)); + + /* Checks for struct llog_logid */ + LASSERTF((int)sizeof(struct llog_logid) == 20, " found %lld\n", + (long long)(int)sizeof(struct llog_logid)); + LASSERTF((int)offsetof(struct llog_logid, lgl_oid) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_logid, lgl_oid)); + LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_oid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_logid *)0)->lgl_oid)); + LASSERTF((int)offsetof(struct llog_logid, lgl_ogr) == 8, " found %lld\n", + (long long)(int)offsetof(struct llog_logid, lgl_ogr)); + LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_ogr) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_logid *)0)->lgl_ogr)); + LASSERTF((int)offsetof(struct llog_logid, lgl_ogen) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_logid, lgl_ogen)); + LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_ogen) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_logid *)0)->lgl_ogen)); + LASSERTF(OST_SZ_REC == 274730752, " found %lld\n", + (long long)OST_SZ_REC); + LASSERTF(OST_RAID1_REC == 274731008, " found %lld\n", + (long long)OST_RAID1_REC); + LASSERTF(MDS_UNLINK_REC == 274801668, " found %lld\n", + (long long)MDS_UNLINK_REC); + LASSERTF(OBD_CFG_REC == 274857984, " found %lld\n", + (long long)OBD_CFG_REC); + LASSERTF(PTL_CFG_REC == 274923520, " found %lld\n", + (long long)PTL_CFG_REC); + LASSERTF(LLOG_GEN_REC == 274989056, " found %lld\n", + (long long)LLOG_GEN_REC); + LASSERTF(LLOG_HDR_MAGIC == 275010873, " found %lld\n", + (long long)LLOG_HDR_MAGIC); + LASSERTF(LLOG_LOGID_MAGIC == 275010875, " found %lld\n", + (long long)LLOG_LOGID_MAGIC); + + /* Checks for struct llog_catid */ + LASSERTF((int)sizeof(struct llog_catid) == 32, " found %lld\n", + (long long)(int)sizeof(struct llog_catid)); + LASSERTF((int)offsetof(struct llog_catid, lci_logid) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_catid, lci_logid)); + LASSERTF((int)sizeof(((struct llog_catid *)0)->lci_logid) == 20, " found %lld\n", + (long long)(int)sizeof(((struct llog_catid *)0)->lci_logid)); + + /* Checks for struct llog_rec_hdr */ + LASSERTF((int)sizeof(struct llog_rec_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(struct llog_rec_hdr)); + LASSERTF((int)offsetof(struct llog_rec_hdr, lrh_len) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_rec_hdr, lrh_len)); + LASSERTF((int)sizeof(((struct llog_rec_hdr *)0)->lrh_len) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_rec_hdr *)0)->lrh_len)); + LASSERTF((int)offsetof(struct llog_rec_hdr, lrh_index) == 4, " found %lld\n", + (long long)(int)offsetof(struct llog_rec_hdr, lrh_index)); + LASSERTF((int)sizeof(((struct llog_rec_hdr *)0)->lrh_index) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_rec_hdr *)0)->lrh_index)); + LASSERTF((int)offsetof(struct llog_rec_hdr, lrh_type) == 8, " found %lld\n", + (long long)(int)offsetof(struct llog_rec_hdr, lrh_type)); + LASSERTF((int)sizeof(((struct llog_rec_hdr *)0)->lrh_type) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_rec_hdr *)0)->lrh_type)); + + /* Checks for struct llog_rec_tail */ + LASSERTF((int)sizeof(struct llog_rec_tail) == 8, " found %lld\n", + (long long)(int)sizeof(struct llog_rec_tail)); + LASSERTF((int)offsetof(struct llog_rec_tail, lrt_len) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_rec_tail, lrt_len)); + LASSERTF((int)sizeof(((struct llog_rec_tail *)0)->lrt_len) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_rec_tail *)0)->lrt_len)); + LASSERTF((int)offsetof(struct llog_rec_tail, lrt_index) == 4, " found %lld\n", + (long long)(int)offsetof(struct llog_rec_tail, lrt_index)); + LASSERTF((int)sizeof(((struct llog_rec_tail *)0)->lrt_index) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_rec_tail *)0)->lrt_index)); + + /* Checks for struct llog_logid_rec */ + LASSERTF((int)sizeof(struct llog_logid_rec) == 64, " found %lld\n", + (long long)(int)sizeof(struct llog_logid_rec)); + LASSERTF((int)offsetof(struct llog_logid_rec, lid_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_logid_rec, lid_hdr)); + LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_hdr)); + LASSERTF((int)offsetof(struct llog_logid_rec, lid_id) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_logid_rec, lid_id)); + LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_id) == 20, " found %lld\n", + (long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_id)); + LASSERTF((int)offsetof(struct llog_logid_rec, lid_tail) == 56, " found %lld\n", + (long long)(int)offsetof(struct llog_logid_rec, lid_tail)); + LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_tail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_tail)); + + /* Checks for struct llog_create_rec */ + LASSERTF((int)sizeof(struct llog_create_rec) == 64, " found %lld\n", + (long long)(int)sizeof(struct llog_create_rec)); + LASSERTF((int)offsetof(struct llog_create_rec, lcr_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_create_rec, lcr_hdr)); + LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_hdr)); + LASSERTF((int)offsetof(struct llog_create_rec, lcr_fid) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_create_rec, lcr_fid)); + LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_fid) == 24, " found %lld\n", + (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_fid)); + LASSERTF((int)offsetof(struct llog_create_rec, lcr_oid) == 40, " found %lld\n", + (long long)(int)offsetof(struct llog_create_rec, lcr_oid)); + LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_oid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_oid)); + LASSERTF((int)offsetof(struct llog_create_rec, lcr_ogen) == 48, " found %lld\n", + (long long)(int)offsetof(struct llog_create_rec, lcr_ogen)); + LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_ogen) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_ogen)); + + /* Checks for struct llog_orphan_rec */ + LASSERTF((int)sizeof(struct llog_orphan_rec) == 40, " found %lld\n", + (long long)(int)sizeof(struct llog_orphan_rec)); + LASSERTF((int)offsetof(struct llog_orphan_rec, lor_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_orphan_rec, lor_hdr)); + LASSERTF((int)sizeof(((struct llog_orphan_rec *)0)->lor_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_orphan_rec *)0)->lor_hdr)); + LASSERTF((int)offsetof(struct llog_orphan_rec, lor_oid) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_orphan_rec, lor_oid)); + LASSERTF((int)sizeof(((struct llog_orphan_rec *)0)->lor_oid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_orphan_rec *)0)->lor_oid)); + LASSERTF((int)offsetof(struct llog_orphan_rec, lor_ogen) == 24, " found %lld\n", + (long long)(int)offsetof(struct llog_orphan_rec, lor_ogen)); + LASSERTF((int)sizeof(((struct llog_orphan_rec *)0)->lor_ogen) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_orphan_rec *)0)->lor_ogen)); + LASSERTF((int)offsetof(struct llog_orphan_rec, lor_tail) == 32, " found %lld\n", + (long long)(int)offsetof(struct llog_orphan_rec, lor_tail)); + LASSERTF((int)sizeof(((struct llog_orphan_rec *)0)->lor_tail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_orphan_rec *)0)->lor_tail)); + + /* Checks for struct llog_unlink_rec */ + LASSERTF((int)sizeof(struct llog_unlink_rec) == 40, " found %lld\n", + (long long)(int)sizeof(struct llog_unlink_rec)); + LASSERTF((int)offsetof(struct llog_unlink_rec, lur_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_unlink_rec, lur_hdr)); + LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_hdr)); + LASSERTF((int)offsetof(struct llog_unlink_rec, lur_oid) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_unlink_rec, lur_oid)); + LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_oid) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_oid)); + LASSERTF((int)offsetof(struct llog_unlink_rec, lur_ogen) == 24, " found %lld\n", + (long long)(int)offsetof(struct llog_unlink_rec, lur_ogen)); + LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_ogen) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_ogen)); + LASSERTF((int)offsetof(struct llog_unlink_rec, lur_tail) == 32, " found %lld\n", + (long long)(int)offsetof(struct llog_unlink_rec, lur_tail)); + LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_tail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_tail)); + + /* Checks for struct llog_size_change_rec */ + LASSERTF((int)sizeof(struct llog_size_change_rec) == 56, " found %lld\n", + (long long)(int)sizeof(struct llog_size_change_rec)); + LASSERTF((int)offsetof(struct llog_size_change_rec, lsc_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_size_change_rec, lsc_hdr)); + LASSERTF((int)sizeof(((struct llog_size_change_rec *)0)->lsc_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_size_change_rec *)0)->lsc_hdr)); + LASSERTF((int)offsetof(struct llog_size_change_rec, lsc_fid) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_size_change_rec, lsc_fid)); + LASSERTF((int)sizeof(((struct llog_size_change_rec *)0)->lsc_fid) == 24, " found %lld\n", + (long long)(int)sizeof(((struct llog_size_change_rec *)0)->lsc_fid)); + LASSERTF((int)offsetof(struct llog_size_change_rec, lsc_io_epoch) == 40, " found %lld\n", + (long long)(int)offsetof(struct llog_size_change_rec, lsc_io_epoch)); + LASSERTF((int)sizeof(((struct llog_size_change_rec *)0)->lsc_io_epoch) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_size_change_rec *)0)->lsc_io_epoch)); + LASSERTF((int)offsetof(struct llog_size_change_rec, lsc_tail) == 48, " found %lld\n", + (long long)(int)offsetof(struct llog_size_change_rec, lsc_tail)); + LASSERTF((int)sizeof(((struct llog_size_change_rec *)0)->lsc_tail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_size_change_rec *)0)->lsc_tail)); + + /* Checks for struct llog_gen */ + LASSERTF((int)sizeof(struct llog_gen) == 16, " found %lld\n", + (long long)(int)sizeof(struct llog_gen)); + LASSERTF((int)offsetof(struct llog_gen, mnt_cnt) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_gen, mnt_cnt)); + LASSERTF((int)sizeof(((struct llog_gen *)0)->mnt_cnt) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_gen *)0)->mnt_cnt)); + LASSERTF((int)offsetof(struct llog_gen, conn_cnt) == 8, " found %lld\n", + (long long)(int)offsetof(struct llog_gen, conn_cnt)); + LASSERTF((int)sizeof(((struct llog_gen *)0)->conn_cnt) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_gen *)0)->conn_cnt)); + + /* Checks for struct llog_gen_rec */ + LASSERTF((int)sizeof(struct llog_gen_rec) == 40, " found %lld\n", + (long long)(int)sizeof(struct llog_gen_rec)); + LASSERTF((int)offsetof(struct llog_gen_rec, lgr_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_gen_rec, lgr_hdr)); + LASSERTF((int)sizeof(((struct llog_gen_rec *)0)->lgr_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_gen_rec *)0)->lgr_hdr)); + LASSERTF((int)offsetof(struct llog_gen_rec, lgr_gen) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_gen_rec, lgr_gen)); + LASSERTF((int)sizeof(((struct llog_gen_rec *)0)->lgr_gen) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_gen_rec *)0)->lgr_gen)); + LASSERTF((int)offsetof(struct llog_gen_rec, lgr_tail) == 32, " found %lld\n", + (long long)(int)offsetof(struct llog_gen_rec, lgr_tail)); + LASSERTF((int)sizeof(((struct llog_gen_rec *)0)->lgr_tail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_gen_rec *)0)->lgr_tail)); + + /* Checks for struct llog_log_hdr */ + LASSERTF((int)sizeof(struct llog_log_hdr) == 8192, " found %lld\n", + (long long)(int)sizeof(struct llog_log_hdr)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_hdr) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_hdr)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_hdr) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_hdr)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_timestamp) == 16, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_timestamp)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_timestamp) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_timestamp)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_count) == 24, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_count)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_count) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_count)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_bitmap_offset) == 28, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_bitmap_offset)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap_offset) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap_offset)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_size) == 32, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_size)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_size) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_size)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_flags) == 36, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_flags)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_flags)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_cat_idx) == 40, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_cat_idx)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_cat_idx) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_cat_idx)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_tgtuuid) == 44, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_tgtuuid)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_tgtuuid) == 40, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_tgtuuid)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_bitmap) == 88, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_bitmap)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap) == 8096, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap)); + LASSERTF((int)offsetof(struct llog_log_hdr, llh_tail) == 8184, " found %lld\n", + (long long)(int)offsetof(struct llog_log_hdr, llh_tail)); + LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_tail) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_tail)); + + /* Checks for struct llog_cookie */ + LASSERTF((int)sizeof(struct llog_cookie) == 32, " found %lld\n", + (long long)(int)sizeof(struct llog_cookie)); + LASSERTF((int)offsetof(struct llog_cookie, lgc_lgl) == 0, " found %lld\n", + (long long)(int)offsetof(struct llog_cookie, lgc_lgl)); + LASSERTF((int)sizeof(((struct llog_cookie *)0)->lgc_lgl) == 20, " found %lld\n", + (long long)(int)sizeof(((struct llog_cookie *)0)->lgc_lgl)); + LASSERTF((int)offsetof(struct llog_cookie, lgc_subsys) == 20, " found %lld\n", + (long long)(int)offsetof(struct llog_cookie, lgc_subsys)); + LASSERTF((int)sizeof(((struct llog_cookie *)0)->lgc_subsys) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_cookie *)0)->lgc_subsys)); + LASSERTF((int)offsetof(struct llog_cookie, lgc_index) == 24, " found %lld\n", + (long long)(int)offsetof(struct llog_cookie, lgc_index)); + LASSERTF((int)sizeof(((struct llog_cookie *)0)->lgc_index) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llog_cookie *)0)->lgc_index)); + + /* Checks for struct llogd_body */ + LASSERTF((int)sizeof(struct llogd_body) == 48, " found %lld\n", + (long long)(int)sizeof(struct llogd_body)); + LASSERTF((int)offsetof(struct llogd_body, lgd_logid) == 0, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_logid)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_logid) == 20, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_logid)); + LASSERTF((int)offsetof(struct llogd_body, lgd_ctxt_idx) == 20, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_ctxt_idx)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_ctxt_idx) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_ctxt_idx)); + LASSERTF((int)offsetof(struct llogd_body, lgd_llh_flags) == 24, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_llh_flags)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_llh_flags) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_llh_flags)); + LASSERTF((int)offsetof(struct llogd_body, lgd_index) == 28, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_index)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_index) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_index)); + LASSERTF((int)offsetof(struct llogd_body, lgd_saved_index) == 32, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_saved_index)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_saved_index) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_saved_index)); + LASSERTF((int)offsetof(struct llogd_body, lgd_len) == 36, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_len)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_len) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_len)); + LASSERTF((int)offsetof(struct llogd_body, lgd_cur_offset) == 40, " found %lld\n", + (long long)(int)offsetof(struct llogd_body, lgd_cur_offset)); + LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_cur_offset) == 8, " found %lld\n", + (long long)(int)sizeof(((struct llogd_body *)0)->lgd_cur_offset)); + LASSERTF(LLOG_ORIGIN_HANDLE_OPEN == 501, " found %lld\n", + (long long)LLOG_ORIGIN_HANDLE_OPEN); + LASSERTF(LLOG_ORIGIN_HANDLE_NEXT_BLOCK == 502, " found %lld\n", + (long long)LLOG_ORIGIN_HANDLE_NEXT_BLOCK); + LASSERTF(LLOG_ORIGIN_HANDLE_READ_HEADER == 503, " found %lld\n", + (long long)LLOG_ORIGIN_HANDLE_READ_HEADER); + LASSERTF(LLOG_ORIGIN_HANDLE_WRITE_REC == 504, " found %lld\n", + (long long)LLOG_ORIGIN_HANDLE_WRITE_REC); + LASSERTF(LLOG_ORIGIN_HANDLE_CLOSE == 505, " found %lld\n", + (long long)LLOG_ORIGIN_HANDLE_CLOSE); + LASSERTF(LLOG_ORIGIN_CONNECT == 506, " found %lld\n", + (long long)LLOG_ORIGIN_CONNECT); + LASSERTF(LLOG_CATINFO == 507, " found %lld\n", + (long long)LLOG_CATINFO); + + /* Checks for struct llogd_conn_body */ + LASSERTF((int)sizeof(struct llogd_conn_body) == 40, " found %lld\n", + (long long)(int)sizeof(struct llogd_conn_body)); + LASSERTF((int)offsetof(struct llogd_conn_body, lgdc_gen) == 0, " found %lld\n", + (long long)(int)offsetof(struct llogd_conn_body, lgdc_gen)); + LASSERTF((int)sizeof(((struct llogd_conn_body *)0)->lgdc_gen) == 16, " found %lld\n", + (long long)(int)sizeof(((struct llogd_conn_body *)0)->lgdc_gen)); + LASSERTF((int)offsetof(struct llogd_conn_body, lgdc_logid) == 16, " found %lld\n", + (long long)(int)offsetof(struct llogd_conn_body, lgdc_logid)); + LASSERTF((int)sizeof(((struct llogd_conn_body *)0)->lgdc_logid) == 20, " found %lld\n", + (long long)(int)sizeof(((struct llogd_conn_body *)0)->lgdc_logid)); + LASSERTF((int)offsetof(struct llogd_conn_body, lgdc_ctxt_idx) == 36, " found %lld\n", + (long long)(int)offsetof(struct llogd_conn_body, lgdc_ctxt_idx)); + LASSERTF((int)sizeof(((struct llogd_conn_body *)0)->lgdc_ctxt_idx) == 4, " found %lld\n", + (long long)(int)sizeof(((struct llogd_conn_body *)0)->lgdc_ctxt_idx)); } + -- 1.8.3.1