From 9d4b898b1c1c7c318fda5f0c345ed726c774c06a Mon Sep 17 00:00:00 2001 From: yury Date: Sun, 24 Oct 2004 16:12:35 +0000 Subject: [PATCH] - landing of b_fid after merge with b_hd_cleanup_merge. --- 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_oss_reint.c => cm_oss_reint.c} | 71 +- lustre/cmobd/{cmobd_reint.c => cm_reint.c} | 63 +- lustre/cmobd/{cmobd_write.c => cm_write.c} | 78 +- lustre/cmobd/cmobd_internal.h | 28 - lustre/cmobd/cmobd_mds_reint.c | 184 --- 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, 7089 insertions(+), 7356 deletions(-) delete mode 100644 lustre/cmobd/cache_manager_obd.c create mode 100644 lustre/cmobd/cm_internal.h create mode 100644 lustre/cmobd/cm_mds_reint.c create mode 100644 lustre/cmobd/cm_obd.c rename lustre/cmobd/{cmobd_oss_reint.c => cm_oss_reint.c} (82%) rename lustre/cmobd/{cmobd_reint.c => cm_reint.c} (70%) rename lustre/cmobd/{cmobd_write.c => cm_write.c} (91%) delete mode 100644 lustre/cmobd/cmobd_internal.h delete mode 100644 lustre/cmobd/cmobd_mds_reint.c create mode 100644 lustre/kernel_patches/patches/ext3-dentry-fid.patch create mode 100644 lustre/tests/cmobd.sh create mode 100644 lustre/tests/sanity-cmobd.sh diff --git a/lnet/include/linux/kp30.h b/lnet/include/linux/kp30.h index db63a08..de642bd 100644 --- a/lnet/include/linux/kp30.h +++ b/lnet/include/linux/kp30.h @@ -728,4 +728,13 @@ 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 d1a5c44..17d5a11 100644 --- a/lnet/include/linux/libcfs.h +++ b/lnet/include/linux/libcfs.h @@ -145,6 +145,13 @@ 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 438edc6..d25d201 100644 --- a/lnet/klnds/qswlnd/qswlnd.h +++ b/lnet/klnds/qswlnd/qswlnd.h @@ -79,6 +79,7 @@ #include #include #include +#include #define KQSW_CHECKSUM 0 #if KQSW_CHECKSUM diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c index 1bde59f..0e109cb 100644 --- a/lnet/utils/portals.c +++ b/lnet/utils/portals.c @@ -37,10 +37,8 @@ #include #ifdef __CYGWIN__ - #include - -#endif /* __CYGWIN__ */ +#endif #include #include @@ -54,12 +52,7 @@ unsigned int portal_printk; static unsigned int g_nal = 0; -static int g_socket_txmem = 0; -static int g_socket_rxmem = 0; -static int g_socket_nonagle = 1; - -typedef struct -{ +typedef struct { char *name; int num; } name2num_t; diff --git a/lustre/cmobd/Makefile.in b/lustre/cmobd/Makefile.in index 8c16488..51c1902 100644 --- a/lustre/cmobd/Makefile.in +++ b/lustre/cmobd/Makefile.in @@ -1,4 +1,4 @@ MODULES := cmobd -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 +cmobd-objs := cm_obd.o cm_reint.o cm_write.o +cmobd-objs += cm_oss_reint.o cm_mds_reint.o lproc_cm.o @INCLUDE_RULES@ diff --git a/lustre/cmobd/Makefile.mk b/lustre/cmobd/Makefile.mk index bcc81ec..4fc7cf2 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 := cache_manager_obd.o cmobd_reint.o cmobd_write.o \ - cmobd_oss_reint.o cmobd_mds_reint.o lproc_cm.o +cmobd-objs := cm_obd.o cm_reint.o cm_write.o \ + cm_oss_reint.o cm_mds_reint.o lproc_cm.o diff --git a/lustre/cmobd/autoMakefile.am b/lustre/cmobd/autoMakefile.am index 35dd6ef..59d6abb 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) cmobd_internal.h +DIST_SOURCES = $(cmobd-objs:%.o=%.c) cm_internal.h diff --git a/lustre/cmobd/cache_manager_obd.c b/lustre/cmobd/cache_manager_obd.c deleted file mode 100644 index 92d850f..0000000 --- a/lustre/cmobd/cache_manager_obd.c +++ /dev/null @@ -1,215 +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 "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 new file mode 100644 index 0000000..5d32eb6 --- /dev/null +++ b/lustre/cmobd/cm_internal.h @@ -0,0 +1,33 @@ +/* -*- 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 new file mode 100644 index 0000000..d77acf2 --- /dev/null +++ b/lustre/cmobd/cm_mds_reint.c @@ -0,0 +1,377 @@ +/* -*- 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 new file mode 100644 index 0000000..5d6592d --- /dev/null +++ b/lustre/cmobd/cm_obd.c @@ -0,0 +1,319 @@ +/* -*- 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_oss_reint.c b/lustre/cmobd/cm_oss_reint.c similarity index 82% rename from lustre/cmobd/cmobd_oss_reint.c rename to lustre/cmobd/cm_oss_reint.c index 41d5369..aec0557 100644 --- a/lustre/cmobd/cmobd_oss_reint.c +++ b/lustre/cmobd/cm_oss_reint.c @@ -33,12 +33,15 @@ #include #include -#include "cmobd_internal.h" +#include "cm_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 smfs_rec_unpack(struct smfs_proc_args *args, char *record, char **pbuf, - int *opcode); + +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); /* helper functions for cmobd to construct pseudo lsm */ int cmobd_dummy_lsm(struct lov_stripe_md **lsmp, int stripe_cnt, @@ -72,11 +75,11 @@ void cmobd_free_lsm(struct lov_stripe_md **lsmp) } /* reintegration functions */ -int cmobd_reint_setattr(struct obd_device *obd, void *rec) +static int cmobd_setattr_reint(struct obd_device *obd, void *rec) { - 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 cm_obd *cmobd = &obd->u.cm; + struct lov_obd *lov = &cmobd->master_obd->u.lov; + struct obd_export *exp = cmobd->master_exp; struct lov_stripe_md *lsm; struct obdo *oa = (struct obdo*)rec; int rc; @@ -94,11 +97,11 @@ out: RETURN(rc); } -int cmobd_reint_create(struct obd_device *obd, void *rec) +static int cmobd_create_reint(struct obd_device *obd, void *rec) { - 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 cm_obd *cmobd = &obd->u.cm; + struct lov_obd *lov = &cmobd->master_obd->u.lov; + struct obd_export *exp = cmobd->master_exp; struct lov_stripe_md *lsm; struct obd_trans_info oti = { 0 }; struct obdo *oa=(struct obdo*)rec; @@ -109,14 +112,14 @@ int cmobd_reint_create(struct obd_device *obd, void *rec) (__u32)lov->desc.ld_default_stripe_size); if (rc) GOTO(out, rc); - if (cmobd->cm_master_group != oa->o_gr) { + if (cmobd->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->cm_master_group = oa->o_gr; + cmobd->master_group = oa->o_gr; } rc = obd_create(exp, oa, &lsm, &oti); @@ -199,9 +202,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 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 cm_obd *cmobd = &obd->u.cm; + struct obd_device *cache = cmobd->cache_obd; + struct lov_obd *lov = &cmobd->master_obd->u.lov; struct ldlm_res_id res_id; ldlm_policy_data_t policy; struct lustre_handle lockh_src = { 0 }; @@ -230,7 +233,7 @@ static int cmobd_write_extents(struct obd_device *obd, struct obdo *oa, if (rc) GOTO(out_lock, rc); - rc = obd_enqueue(cmobd->cm_master_exp, lsm, LDLM_EXTENT, &policy, + rc = obd_enqueue(cmobd->master_exp, lsm, LDLM_EXTENT, &policy, LCK_PW, &flags, master_blocking_ast, ldlm_completion_ast, NULL, NULL, 0, NULL, &lockh_dst); @@ -239,12 +242,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->cm_master_exp, lsm, LCK_PW, &lockh_dst); + rc = obd_cancel(cmobd->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->cm_master_exp, lsm, 0, NULL); + rc = obd_cancel_unused(cmobd->master_exp, lsm, 0, NULL); if (err) rc = err; out_lsm: @@ -253,10 +256,11 @@ out_lock: ldlm_lock_decref(&lockh_src, LCK_PR); RETURN(rc); } -int cmobd_reint_write(struct obd_device *obd, void *rec) + +static int cmobd_write_reint(struct obd_device *obd, void *rec) { - struct cache_manager_obd *cmobd = &obd->u.cmobd; - struct obd_device *cache = cmobd->cm_cache_obd; + struct cm_obd *cmobd = &obd->u.cm; + struct obd_device *cache = cmobd->cache_obd; struct obdo *oa = (struct obdo *)rec; struct ldlm_extent *extent = NULL; unsigned long csb, ino; @@ -266,7 +270,7 @@ int cmobd_reint_write(struct obd_device *obd, void *rec) size = sizeof(csb); - obd_get_info(cmobd->cm_cache_exp, strlen("cache_sb") + 1, + obd_get_info(cmobd->cache_exp, strlen("cache_sb") + 1, "cache_sb", &size, &csb); ino = *(int*)(&oa->o_inline[0]); @@ -284,8 +288,23 @@ int cmobd_reint_write(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/cmobd_reint.c b/lustre/cmobd/cm_reint.c similarity index 70% rename from lustre/cmobd/cmobd_reint.c rename to lustre/cmobd/cm_reint.c index f68132f..230f6f1 100644 --- a/lustre/cmobd/cmobd_reint.c +++ b/lustre/cmobd/cm_reint.c @@ -33,33 +33,35 @@ #include #include -#include "cmobd_internal.h" +#include "cm_internal.h" -static int cmobd_reint_record(int opcode, struct obd_device *obd, char *record) +#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) { - int rc = 0; + if (OSS_REINT(opcode)) + return cmobd_reint_oss(obd, record, opcode); - 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, + 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, void *data) { struct obd_device *obd = (struct obd_device*)data; @@ -72,6 +74,7 @@ static int cmobd_reint_cb(struct llog_handle *llh, struct llog_rec_hdr *rec, CERROR("log is not plain log\n"); RETURN(-EINVAL); } + if (rec->lrh_type != SMFS_UPDATE_REC) RETURN(-EINVAL); @@ -79,10 +82,12 @@ static int cmobd_reint_cb(struct llog_handle *llh, struct llog_rec_hdr *rec, rc = smfs_rec_unpack(NULL, buf, &pbuf, &opcode); if (rc) GOTO(out, rc); - rc = cmobd_reint_record(opcode, obd, pbuf); + + rc = cmobd_reint_record(obd, pbuf, opcode); if (rc) GOTO(out, rc); - /*delete this record*/ + + /* delete this record. */ rc = LLOG_DEL_RECORD; out: RETURN(rc); @@ -90,7 +95,7 @@ out: int cmobd_reintegrate(struct obd_device *obd) { - struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct cm_obd *cmobd = &obd->u.cm; struct llog_ctxt *ctxt = NULL; struct llog_handle *llh; int val_size, rc = 0; @@ -99,7 +104,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->cm_cache_exp, strlen("reint_log") + 1, + rc = obd_get_info(cmobd->cache_exp, strlen("reint_log") + 1, "reint_log", &val_size, &ctxt); if (rc) RETURN(rc); @@ -115,5 +120,3 @@ int cmobd_reintegrate(struct obd_device *obd) RETURN(rc); } - - diff --git a/lustre/cmobd/cmobd_write.c b/lustre/cmobd/cm_write.c similarity index 91% rename from lustre/cmobd/cmobd_write.c rename to lustre/cmobd/cm_write.c index 815efc6..833cc8c 100644 --- a/lustre/cmobd/cmobd_write.c +++ b/lustre/cmobd/cm_write.c @@ -34,7 +34,7 @@ #include #include -#include "cmobd_internal.h" +#include "cm_internal.h" extern kmem_cache_t *cmobd_extent_slab; @@ -108,8 +108,10 @@ 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; - mdc_pack_fid(obdo_fid(oa), inode->i_ino, 0, inode->i_mode); - + + /* 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); valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME; } @@ -169,8 +171,8 @@ static int cmobd_send_pages(struct obd_device *obd, obd_count oa_bufs, struct cmobd_extent_set *set) { - struct cache_manager_obd *cmobd = &obd->u.cmobd; - struct obd_export *exp = cmobd->cm_master_exp; + struct cm_obd *cmobd = &obd->u.cm; + struct obd_export *exp = cmobd->master_exp; struct cmobd_async_page *cmap = NULL; obd_count i; int rc = 0; @@ -259,7 +261,7 @@ static int cmobd_write_extent(struct obd_device *obd, struct cmobd_extent_info *ei) { struct cmobd_extent_set *set = ei->ei_set; - struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct cm_obd *cmobd = &obd->u.cm; unsigned long flags; struct obd_ioobj ioo; struct niobuf_local *lnb; @@ -293,7 +295,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->cm_cache_exp, oa, 1, &ioo, + ret = obd_preprw(OBD_BRW_READ, cmobd->cache_exp, oa, 1, &ioo, oa_bufs, rnb, lnb, NULL); if (ret) GOTO(out, rc = ret); @@ -302,7 +304,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->cm_cache_exp, oa, 1, &ioo, + rc = obd_commitrw(OBD_BRW_READ, cmobd->cache_exp, oa, 1, &ioo, oa_bufs, lnb, NULL, ret); /* countdown and wake up */ @@ -355,16 +357,24 @@ 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 cache_manager_obd *cmobd = &obd->u.cmobd; - struct cmobd_write_service *ws = cmobd->cm_write_srv; + struct cm_obd *cmobd = &obd->u.cm; + struct cmobd_write_service *ws = cmobd->write_srv; struct cmobd_extent_info *extent = NULL; unsigned long flags; int rc; ENTRY; lock_kernel(); - - ptlrpc_daemonize(); + /* vv ptlrpc_daemonize(); vv */ + exit_mm(current); + + current->session = 1; + current->pgrp = 1; + current->tty = NULL; + + exit_files(current); + reparent_to_init(); + /* ^^ ptlrpc_daemonize(); ^^ */ SIGNAL_MASK_LOCK(current, flags); sigfillset(¤t->blocked); @@ -416,8 +426,8 @@ static int cmobd_write_main(void *arg) * ptlrpc threads functions */ static int cmobd_start_thread(struct obd_device *obd, char *name) { - struct cache_manager_obd *cmobd = &obd->u.cmobd; - struct cmobd_write_service *ws = cmobd->cm_write_srv; + struct cm_obd *cmobd = &obd->u.cm; + struct cmobd_write_service *ws = cmobd->write_srv; struct l_wait_info lwi = { 0 }; struct ptlrpc_svc_data d; struct ptlrpc_thread *thread; @@ -460,8 +470,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 cache_manager_obd *cmobd = &obd->u.cmobd; - struct cmobd_write_service *ws = cmobd->cm_write_srv; + struct cm_obd *cmobd = &obd->u.cm; + struct cmobd_write_service *ws = cmobd->write_srv; struct l_wait_info lwi = { 0 }; unsigned long flags; ENTRY; @@ -482,8 +492,8 @@ static void cmobd_stop_thread(struct obd_device *obd, static void cmobd_stop_all_threads(struct obd_device *obd) { - struct cache_manager_obd *cmobd = &obd->u.cmobd; - struct cmobd_write_service *ws = cmobd->cm_write_srv; + struct cm_obd *cmobd = &obd->u.cm; + struct cmobd_write_service *ws = cmobd->write_srv; unsigned long flags; struct ptlrpc_thread *thread; ENTRY; @@ -523,33 +533,33 @@ static int cmobd_start_n_threads(struct obd_device *obd, int num_threads, void cmobd_cleanup_write_srv(struct obd_device *obd) { - struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct cm_obd *cmobd = &obd->u.cm; struct list_head *pos, *n; struct cmobd_extent_info *ei; ENTRY; cmobd_stop_all_threads(obd); - list_for_each_safe(pos, n, &cmobd->cm_write_srv->ws_extents) { + list_for_each_safe(pos, n, &cmobd->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->cm_write_srv, sizeof(*cmobd->cm_write_srv)); + OBD_FREE(cmobd->write_srv, sizeof(*cmobd->write_srv)); EXIT; } int cmobd_init_write_srv(struct obd_device *obd) { - struct cache_manager_obd *cmobd = &obd->u.cmobd; + struct cm_obd *cmobd = &obd->u.cm; struct cmobd_write_service *ws; int rc; ENTRY; - OBD_ALLOC(cmobd->cm_write_srv, sizeof(*cmobd->cm_write_srv)); - if (cmobd->cm_write_srv == NULL) + OBD_ALLOC(cmobd->write_srv, sizeof(*cmobd->write_srv)); + if (cmobd->write_srv == NULL) RETURN(-ENOMEM); - ws = cmobd->cm_write_srv; + ws = cmobd->write_srv; INIT_LIST_HEAD(&ws->ws_threads); spin_lock_init(&ws->ws_thread_lock); @@ -583,8 +593,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 cache_manager_obd *cmobd = &obd->u.cmobd; - struct cmobd_write_service *ws = cmobd->cm_write_srv; + struct cm_obd *cmobd = &obd->u.cm; + struct cmobd_write_service *ws = cmobd->write_srv; struct cmobd_extent_set *set = ex->ei_set; unsigned long flags; struct l_wait_info lwi = { 0 }; @@ -611,7 +621,7 @@ wait: EXIT; } -static obd_size cmobd_fid2size(struct obd_export *exp, obd_id id, obd_gr grp) +static obd_size cmobd_id2size(struct obd_export *exp, obd_id id, obd_gr grp) { struct lvfs_run_ctxt saved; struct dentry *de = NULL; @@ -620,7 +630,7 @@ static obd_size cmobd_fid2size(struct obd_export *exp, obd_id id, obd_gr grp) push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL); - de = obd_lvfs_fid2dentry(exp, id, 0, grp); + de = obd_lvfs_id2dentry(exp, id, 0, grp); LASSERT(de); size = de->d_inode->i_size; @@ -649,8 +659,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 cache_manager_obd *cmobd = &obd->u.cmobd; - struct lov_obd *lov = &cmobd->cm_master_obd->u.lov; + struct cm_obd *cmobd = &obd->u.cm; + struct lov_obd *lov = &cmobd->master_obd->u.lov; struct lov_stripe_md *lsm = NULL; struct cmobd_extent_set set; struct cmobd_extent_info *ex; @@ -671,7 +681,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->cm_master_exp; + set.es_exp = cmobd->master_exp; set.es_ext_sz = CMOBD_MAX_EXTENT_SZ; set.es_count = 0; memcpy(&set.es_oa, oa, sizeof(*oa)); @@ -688,8 +698,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_fid2size(cmobd->cm_cache_exp, - oa->o_id, oa->o_gr) - 1; + set.es_extent.end = cmobd_id2size(cmobd->cache_exp, + oa->o_id, oa->o_gr) - 1; if (set.es_extent.end <= 0) GOTO(out, rc = 0); } diff --git a/lustre/cmobd/cmobd_internal.h b/lustre/cmobd/cmobd_internal.h deleted file mode 100644 index d245015..0000000 --- a/lustre/cmobd/cmobd_internal.h +++ /dev/null @@ -1,28 +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 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 deleted file mode 100644 index 0fb8e07..0000000 --- a/lustre/cmobd/cmobd_mds_reint.c +++ /dev/null @@ -1,184 +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 "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/cobd/cache_obd.c b/lustre/cobd/cache_obd.c index f4072eb..a081fc1 100644 --- a/lustre/cobd/cache_obd.c +++ b/lustre/cobd/cache_obd.c @@ -66,22 +66,24 @@ 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; -// struct lustre_handle real_conn = {0,}, cache_conn = {0,}; - struct lustre_handle cache_conn = {0,}; - struct obd_device *real; +#if 0 + struct lustre_handle master_conn = {0,}; +#endif + struct lustre_handle cache_conn = {0,}; + struct obd_device *master; struct obd_device *cache; int rc; ENTRY; if (lcfg->lcfg_inllen1 == 0 || lcfg->lcfg_inlbuf1 == NULL) { - CERROR("%s: setup requires real device name\n", + CERROR("%s: setup requires master device name\n", obd->obd_name); RETURN(-EINVAL); } - real = class_name2obd(lcfg->lcfg_inlbuf1); - if (real == NULL) { - CERROR("%s: unable to find a client for real: %s\n", + master = class_name2obd(lcfg->lcfg_inlbuf1); + if (master == NULL) { + CERROR("%s: unable to find a client for master: %s\n", obd->obd_name, lcfg->lcfg_inlbuf1); RETURN(-EINVAL); } @@ -91,60 +93,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->cobd_real_name, strlen(lcfg->lcfg_inlbuf1) + 1); - if (!cobd->cobd_real_name) + OBD_ALLOC(cobd->master_name, strlen(lcfg->lcfg_inlbuf1) + 1); + if (!cobd->master_name) GOTO(exit, rc = -ENOMEM); - memcpy(cobd->cobd_real_name, lcfg->lcfg_inlbuf1, + memcpy(cobd->master_name, lcfg->lcfg_inlbuf1, strlen(lcfg->lcfg_inlbuf1)); - OBD_ALLOC(cobd->cobd_cache_name, strlen(lcfg->lcfg_inlbuf2) + 1); - if (!cobd->cobd_cache_name) + OBD_ALLOC(cobd->cache_name, strlen(lcfg->lcfg_inlbuf2) + 1); + if (!cobd->cache_name) GOTO(exit, rc = -ENOMEM); - memcpy(cobd->cobd_cache_name, lcfg->lcfg_inlbuf2, + memcpy(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->cobd_real_name, &real_conn); + /* don't bother checking attached/setup; obd_connect() should, and it + * can change underneath us */ + rc = connect_to_obd(cobd->master_name, &master_conn); if (rc != 0) GOTO(exit, rc); - cobd->cobd_real_exp = class_conn2export(&real_conn); + cobd->master_exp = class_conn2export(&master_conn); #endif - rc = connect_to_obd(cobd->cobd_cache_name, &cache_conn); + rc = connect_to_obd(cobd->cache_name, &cache_conn); if (rc != 0) { - obd_disconnect(cobd->cobd_cache_exp, 0); + obd_disconnect(cobd->cache_exp, 0); GOTO(exit, rc); } - cobd->cobd_cache_exp = class_conn2export(&cache_conn); - + cobd->cache_exp = class_conn2export(&cache_conn); cobd->cache_on = 1; - 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); + + 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); } - /*default write to real obd*/ exit: if (rc) { - 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_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); } RETURN(rc); } @@ -157,20 +159,20 @@ static int cobd_cleanup(struct obd_device *obd, int flags) if (!list_empty(&obd->obd_exports)) return (-EBUSY); - 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_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->cache_on) { - rc = obd_disconnect(cobd->cobd_cache_exp, flags); + rc = obd_disconnect(cobd->cache_exp, flags); if (rc != 0) CERROR("error %d disconnecting cache\n", rc); } - rc = obd_disconnect(cobd->cobd_real_exp, flags); + rc = obd_disconnect(cobd->master_exp, flags); if (rc != 0) - CERROR("error %d disconnecting real\n", rc); + CERROR("error %d disconnecting master\n", rc); return (rc); } @@ -180,25 +182,21 @@ struct obd_export *cobd_get_exp(struct obd_device *obd) struct cache_obd *cobd = &obd->u.cobd; if (cobd->cache_on) - return cobd->cobd_cache_exp; + return cobd->cache_exp; else - return cobd->cobd_real_exp; + return cobd->master_exp; } static int cobd_connect(struct lustre_handle *conn, struct obd_device *obd, struct obd_uuid *cluuid, unsigned long connect_flags) { - int rc; - rc = class_connect(conn, obd, cluuid); - return rc; + return class_connect(conn, obd, cluuid); } static int cobd_disconnect(struct obd_export *exp, int flags) { - int rc; - rc = class_disconnect(exp, 0); - return rc; + return class_disconnect(exp, 0); } static int cobd_get_info(struct obd_export *exp, obd_count keylen, @@ -206,14 +204,15 @@ 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? */ + /* intercept cache utilisation info? */ return obd_get_info(cobd_exp, keylen, key, vallen, val); } @@ -229,8 +228,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); } @@ -311,7 +310,7 @@ static int cobd_destroy(struct obd_export *exp, struct obdo *obdo, static int cobd_precleanup(struct obd_device *obd, int flags) { - /*FIXME Do we need some cleanup here?*/ + /* FIXME-WANGDI: do we need some cleanup here? */ return 0; } @@ -331,8 +330,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; @@ -362,7 +361,8 @@ 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 ll_fid *rootfid) +static int cobd_md_getstatus(struct obd_export *exp, + struct lustre_id *rootid) { 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, struct ll_fid *rootfid) return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_getstatus(cobd_exp, rootfid); + return md_getstatus(cobd_exp, rootid); } static int cobd_brw(int cmd, struct obd_export *exp, struct obdo *oa, @@ -675,8 +675,7 @@ 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; } @@ -685,7 +684,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 *real_dev = NULL; + struct obd_device *master_dev = NULL; struct obd_export *cobd_exp; int rc = 0; @@ -694,39 +693,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->cobd_real_exp, 0); + rc = obd_disconnect(cobd->master_exp, 0); if (rc != 0) - CERROR("error %d disconnecting real\n", rc); - rc = connect_to_obd(cobd->cobd_cache_name, &cache_conn); + CERROR("error %d disconnecting master\n", rc); + rc = connect_to_obd(cobd->cache_name, &cache_conn); if (rc != 0) RETURN(rc); - cobd->cobd_cache_exp = class_conn2export(&cache_conn); + cobd->cache_exp = class_conn2export(&cache_conn); cobd->cache_on = 1; } break; case OBD_IOC_COBD_COFF: if (cobd->cache_on) { - struct lustre_handle real_conn = {0,}; + struct lustre_handle master_conn = {0,}; struct obd_device *cache_dev = NULL; int m_easize, m_cooksize; - cache_dev = class_exp2obd(cobd->cobd_cache_exp); + cache_dev = class_exp2obd(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->cobd_cache_exp, 0); + rc = obd_disconnect(cobd->cache_exp, 0); if (rc != 0) - CERROR("error %d disconnecting real\n", rc); + CERROR("error %d disconnecting master\n", rc); - /*FIXME, should read from real_dev*/ + /* FIXME-WANGDI: should we read from master_dev? */ - rc = connect_to_obd(cobd->cobd_real_name, &real_conn); + rc = connect_to_obd(cobd->master_name, &master_conn); if (rc != 0) RETURN(rc); - 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->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->cache_on = 0; } break; @@ -833,7 +832,7 @@ static int cobd_import_event(struct obd_device *obd, return 0; } -static int cobd_md_getattr(struct obd_export *exp, struct ll_fid *fid, +static int cobd_md_getattr(struct obd_export *exp, struct lustre_id *id, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request) { @@ -846,7 +845,7 @@ static int cobd_md_getattr(struct obd_export *exp, struct ll_fid *fid, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_getattr(cobd_exp, fid, valid, ea_size, request); + return md_getattr(cobd_exp, id, valid, ea_size, request); } static int cobd_md_req2lustre_md (struct obd_export *mdc_exp, @@ -865,7 +864,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 ll_fid *fid, +static int cobd_md_change_cbdata(struct obd_export *exp, struct lustre_id *id, ldlm_iterator_t it, void *data) { struct obd_device *obd = class_exp2obd(exp); @@ -877,14 +876,12 @@ static int cobd_md_change_cbdata(struct obd_export *exp, struct ll_fid *fid, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_change_cbdata(cobd_exp, fid, it, data); + return md_change_cbdata(cobd_exp, id, it, data); } -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) +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) { struct obd_device *obd = class_exp2obd(exp); struct obd_export *cobd_exp; @@ -895,7 +892,7 @@ static int cobd_md_getattr_name(struct obd_export *exp, struct ll_fid *fid, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_getattr_name(cobd_exp, fid, filename, namelen, valid, + return md_getattr_name(cobd_exp, id, filename, namelen, valid, ea_size, request); } @@ -932,7 +929,8 @@ 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 ll_fid *fid) +static int cobd_md_valid_attrs(struct obd_export *exp, + struct lustre_id *id) { struct obd_device *obd = class_exp2obd(exp); struct obd_export *cobd_exp; @@ -943,7 +941,7 @@ static int cobd_md_valid_attrs(struct obd_export *exp, struct ll_fid *fid) return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_valid_attrs(cobd_exp, fid); + return md_valid_attrs(cobd_exp, id); } static int cobd_md_rename(struct obd_export *exp, struct mdc_op_data *data, @@ -993,7 +991,8 @@ 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 ll_fid *mdc_fid, +static int cobd_md_readpage(struct obd_export *exp, + struct lustre_id *mdc_id, __u64 offset, struct page *page, struct ptlrpc_request **request) { @@ -1006,7 +1005,7 @@ static int cobd_md_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_readpage(cobd_exp, mdc_fid, offset, page, request); + return md_readpage(cobd_exp, mdc_id, offset, page, request); } static int cobd_md_close(struct obd_export *exp, struct obdo *obdo, @@ -1039,7 +1038,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 ll_fid *fid, +static int cobd_md_sync(struct obd_export *exp, struct lustre_id *id, struct ptlrpc_request **request) { struct obd_device *obd = class_exp2obd(exp); @@ -1052,7 +1051,7 @@ static int cobd_md_sync(struct obd_export *exp, struct ll_fid *fid, } cobd_exp = cobd_get_exp(obd); - return md_sync(cobd_exp, fid, request); + return md_sync(cobd_exp, id, request); } static int cobd_md_set_open_replay_data(struct obd_export *exp, @@ -1141,10 +1140,9 @@ 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 ll_fid *pfid, const char *name, int len, - void *lmm, int lmmsize, - struct ll_fid *cfid, struct lookup_intent *it, +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, int lookup_flags, struct ptlrpc_request **reqp, ldlm_blocking_callback cb_blocking) { @@ -1157,12 +1155,12 @@ static int cobd_md_intent_lock(struct obd_export *exp, return -EINVAL; } cobd_exp = cobd_get_exp(obd); - return md_intent_lock(cobd_exp, pfid, name, len, lmm, lmmsize, - cfid, it, lookup_flags, reqp, cb_blocking); + return md_intent_lock(cobd_exp, pid, name, len, lmm, lmmsize, + cid, 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; @@ -1177,8 +1175,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 ll_fid *fid, char *name, - int namelen, struct ll_fid *fid2, + struct lustre_id *id, char *name, + int namelen, struct lustre_id *id2, ldlm_iterator_t it, void *data) { struct obd_device *obd = class_exp2obd(exp); @@ -1190,8 +1188,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, fid, name, namelen, fid2, it, - data); + return md_change_cbdata_name(cobd_exp, id, name, namelen, + id2, 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 25b1e3a..a40f42d 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.cobd_real_exp); + class_exp2obd(cobd->u.cobd.master_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.cobd_cache_exp); + class_exp2obd(cobd->u.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 3c602cd..f32b34e 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -363,6 +363,7 @@ 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) @@ -674,13 +675,6 @@ 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 0287964..32cd252 100644 --- a/lustre/include/linux/lustre_fsfilt.h +++ b/lustre/include/linux/lustre_fsfilt.h @@ -57,10 +57,24 @@ 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); @@ -125,7 +139,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); + unsigned long, unsigned long); int (* fs_del_dir_entry)(struct obd_device *, struct dentry *); /*snap operations*/ int (* fs_is_redirector)(struct inode *inode); @@ -375,6 +389,7 @@ 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) @@ -389,6 +404,34 @@ 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) { @@ -459,10 +502,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_rcvd, void *handle, fsfilt_cb_t cb_func, + __u64 last_num, void *handle, fsfilt_cb_t cb_func, void *cb_data) { - return obd->obd_fsops->fs_add_journal_cb(obd, sb, last_rcvd, handle, + return obd->obd_fsops->fs_add_journal_cb(obd, sb, last_num, handle, cb_func, cb_data); } @@ -658,11 +701,15 @@ 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 mds) + unsigned long generation, unsigned long mds, + unsigned long fid) { LASSERT(obd->obd_fsops->fs_add_dir_entry); + return obd->obd_fsops->fs_add_dir_entry(obd, dir, name, - namelen, ino, generation, mds); + namelen, ino, + generation, mds, + fid); } static inline int diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index 66e79f1..5c7d80d 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -267,7 +267,9 @@ 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 */ -#define OBD_INLINESZ 64 +/* this should be sizeof(struct lustre_handle) + sizeof(struct llog_cookie) + + * sizeof(struct lustre_id). */ +#define OBD_INLINESZ (80) /* Note: 64-bit types are 64-bit aligned in structure */ struct obdo { @@ -290,6 +292,7 @@ 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 */ }; @@ -374,7 +377,8 @@ 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_REINT (0x40000000) /* reintegrate oa */ +#define OBD_MD_FID (0x80000000) /* take care about fid component */ #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|\ @@ -391,8 +395,9 @@ 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; @@ -450,6 +455,7 @@ 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 */ @@ -523,43 +529,58 @@ 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 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 +#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) /* INODE LOCK PARTS */ -#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; +#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 */ }; struct mea_old { __u32 mea_count; __u32 mea_master; - struct ll_fid mea_fids[0]; + struct lustre_id mea_ids[0]; }; #define MEA_MAGIC_LAST_CHAR 0xb2221ca1 @@ -569,11 +590,9 @@ struct mea { __u32 mea_magic; __u32 mea_count; __u32 mea_master; - struct ll_fid mea_fids[0]; + struct lustre_id mea_ids[0]; }; -extern void lustre_swab_ll_fid (struct ll_fid *fid); - #define MDS_STATUS_CONN 1 #define MDS_STATUS_LOV 2 @@ -582,18 +601,20 @@ 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 ll_fid fid1; - struct ll_fid fid2; + struct lustre_id id1; + struct lustre_id id2; 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; @@ -601,12 +622,10 @@ 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 generation; + __u32 nlink; /* #bytes to read in the case of MDS_READPAGE */ __u32 eadatasize; - __u32 mds; }; extern void lustre_swab_mds_body (struct mds_body *b); @@ -618,31 +637,32 @@ struct lustre_md { }; struct mdc_op_data { - struct ll_fid fid1; - struct ll_fid fid2; + struct lustre_id id1; + struct lustre_id id2; __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 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; + __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; }; /* Remove this once we declare it in include/linux/fs.h (v21 kernel patch?) */ @@ -666,49 +686,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 ll_fid cr_fid; - struct ll_fid cr_replayfid; - __u64 cr_time; - __u64 cr_rdev; + __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; }; extern void lustre_swab_mds_rec_create (struct mds_rec_create *cr); struct mds_rec_link { - __u32 lk_opcode; - __u32 lk_padding; - struct ll_fid lk_fid1; - struct ll_fid lk_fid2; - __u64 lk_time; + __u32 lk_opcode; + __u32 lk_padding; + struct lustre_id lk_id1; + struct lustre_id lk_id2; + __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 ll_fid ul_fid1; - struct ll_fid ul_fid2; - __u64 ul_time; + __u32 ul_opcode; + __u32 ul_mode; + struct lustre_id ul_id1; + struct lustre_id ul_id2; + __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 ll_fid rn_fid1; - struct ll_fid rn_fid2; - __u64 rn_time; + __u32 rn_opcode; + __u32 rn_padding; + struct lustre_id rn_id1; + struct lustre_id rn_id2; + __u64 rn_time; }; extern void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn); @@ -852,11 +872,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; @@ -967,7 +987,7 @@ struct llog_logid_rec { struct llog_create_rec { struct llog_rec_hdr lcr_hdr; - struct ll_fid lcr_fid; + struct lustre_id lcr_id; obd_id lcr_oid; obd_count lcr_ogen; __u32 padding; @@ -992,7 +1012,7 @@ struct llog_unlink_rec { struct llog_size_change_rec { struct llog_rec_hdr lsc_hdr; - struct ll_fid lsc_fid; + struct lustre_id lsc_id; __u32 lsc_io_epoch; __u32 padding; struct llog_rec_tail lsc_tail; @@ -1011,8 +1031,8 @@ struct llog_gen_rec { struct llog_lru_rec { struct llog_rec_hdr llr_hdr; - struct ll_fid llr_cfid; - struct ll_fid llr_pfid; + struct lustre_id llr_cid; + struct lustre_id llr_pid; struct llog_rec_tail llr_tail; } __attribute__((packed)); @@ -1087,10 +1107,12 @@ 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 ll_fid *obdo_fid(struct obdo *oa) +static inline struct lustre_id *obdo_id(struct obdo *oa) { - return (struct ll_fid *)(oa->o_inline + sizeof(struct lustre_handle) + - sizeof(struct llog_cookie)); + void *raw_id = oa->o_inline + sizeof(struct lustre_handle) + + sizeof(struct llog_cookie); + + return (struct lustre_id *)raw_id; } #endif diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index 7a9d350..868a4dd 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -64,6 +64,15 @@ #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 1c34c4c..bd8341b 100644 --- a/lustre/include/linux/lustre_lite.h +++ b/lustre/include/linux/lustre_lite.h @@ -40,15 +40,6 @@ /* 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) @@ -76,16 +67,17 @@ 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; @@ -151,31 +143,34 @@ enum { LPROC_LL_FILE_OPCODES }; -static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode) +static inline void +ll_inode2id(struct lustre_id *id, struct inode *inode) { - 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; + 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)); } static inline void -ll_prepare_mdc_op_data(struct mdc_op_data *data, struct inode *i1, - struct inode *i2, const char *name, int namelen, - int mode) +ll_prepare_mdc_data(struct mdc_op_data *data, struct inode *i1, + struct inode *i2, const char *name, int namelen, + int mode) { LASSERT(i1); - ll_inode2fid(&data->fid1, i1); + ll_inode2id(&data->id1, i1); /* it could be directory with mea */ data->mea1 = ll_i2info(i1)->lli_mea; if (i2) { - ll_inode2fid(&data->fid2, i2); + ll_inode2id(&data->id2, 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 c125662..2db1dcc 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 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; + __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; 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 REAL_MDS_NUMBER 1 -#define CACHE_MDS_NUMBER 0 +#define MDS_MASTER_OBD 1 +#define MDS_CACHE_OBD 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,13 +172,17 @@ int mds_reint_rec(struct mds_update_record *r, int offset, /* mds/handler.c */ #ifdef __KERNEL__ -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); +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); 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); @@ -192,13 +196,12 @@ 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 ll_fid *fid, +int mdc_change_cbdata(struct obd_export *exp, struct lustre_id *id, ldlm_iterator_t it, void *data); -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, +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, ldlm_blocking_callback cb_blocking); int mdc_enqueue(struct obd_export *exp, int lock_type, @@ -218,11 +221,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 ll_fid *rootfid); -int mdc_getattr(struct obd_export *exp, struct ll_fid *fid, +int mdc_getstatus(struct obd_export *exp, struct lustre_id *rootid); +int mdc_getattr(struct obd_export *exp, struct lustre_id *id, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request); -int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid, +int mdc_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); int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data, @@ -231,7 +234,9 @@ 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); @@ -239,7 +244,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 ll_fid *mdc_fid, +int mdc_readpage(struct obd_export *exp, struct lustre_id *id, __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, @@ -251,28 +256,23 @@ 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 ll_fid *fid, +int mdc_sync(struct obd_export *exp, struct lustre_id *id, 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 *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; -} + +int mdc_llog_process(struct obd_export *, char *, llog_cb_t, + void *); + +int mdc_done_writing(struct obd_export *, struct obdo *); /* 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 f3569c0..aaec825 100644 --- a/lustre/include/linux/lustre_net.h +++ b/lustre/include/linux/lustre_net.h @@ -708,15 +708,86 @@ 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); + 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 /* 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 62efd3c..b6fd845 100644 --- a/lustre/include/linux/lustre_smfs.h +++ b/lustre/include/linux/lustre_smfs.h @@ -33,6 +33,10 @@ 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; @@ -124,11 +128,14 @@ 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 @@ -313,9 +320,10 @@ 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 + + /* + * here we must release the cache_inode, otherwise we will have + * no chance to do it later. */ cache_inode->i_state &=~I_LOCK; inode->i_blocks = cache_inode->i_blocks; @@ -433,6 +441,11 @@ 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 3585660..fcccab4 100644 --- a/lustre/include/linux/lvfs.h +++ b/lustre/include/linux/lvfs.h @@ -3,7 +3,7 @@ #include -#define LL_FID_NAMELEN (16 + 1 + 8 + 1) +#define LL_ID_NAMELEN (16 + 1 + 8 + 1) #if defined __KERNEL__ #include @@ -28,7 +28,8 @@ struct lvfs_ucred { }; struct lvfs_callback_ops { - struct dentry *(*l_fid2dentry)(__u64 id_ino, __u32 gen, __u64 gr, void *data); + struct dentry *(*l_id2dentry)(__u64 ino, __u32 gen, + __u64 gr, void *data); }; #define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA @@ -58,7 +59,8 @@ struct lvfs_run_ctxt { #endif /* lvfs_common.c */ -struct dentry *lvfs_fid2dentry(struct lvfs_run_ctxt *, __u64, __u32, __u64 ,void *data); +struct dentry *lvfs_id2dentry(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); @@ -89,27 +91,25 @@ 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 *fid_name, - struct dentry *dparent, - int fid_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 *name, struct dentry *dparent, int namelen) { struct dentry *dchild; #ifdef S_PDIROPS struct qstr qstr; void *lock; - qstr.name = fid_name; - qstr.len = fid_namelen; + qstr.name = name; + qstr.len = namelen; lock = lock_dir(dparent->d_inode, &qstr); #else down(&dparent->d_inode->i_sem); #endif - dchild = lookup_one_len(fid_name, dparent, fid_namelen); + dchild = lookup_one_len(name, dparent, namelen); #ifdef S_PDIROPS unlock_dir(dparent->d_inode, lock); @@ -127,9 +127,10 @@ static inline void ll_sleep(int t) } #endif -static inline int ll_fid2str(char *str, __u64 id, __u32 generation) +static inline int ll_id2str(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 ae27f81..5d84673 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_FID_NAMELEN]; + char lld_name[LL_ID_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 4cf2769..c9e122d 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,26 +332,28 @@ struct mds_obd { struct ptlrpc_service *mds_readpage_service; struct super_block *mds_sb; struct vfsmount *mds_vfsmnt; - struct dentry *mds_fid_de; + struct dentry *mds_id_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 ll_fid mds_rootfid; + struct lustre_id mds_rootid; 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 llog_handle *mds_catalog; - struct obd_device *mds_osc_obd; /* XXX lov_obd */ + struct obd_device *mds_lov_obd; struct obd_uuid mds_lov_uuid; char *mds_profile; - struct obd_export *mds_osc_exp; /* XXX lov_exp */ + struct obd_export *mds_lov_exp; int mds_has_lov_desc; struct lov_desc mds_lov_desc; obd_id *mds_lov_objids; @@ -361,15 +363,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; /* XXX lmv_obd */ - struct obd_export *mds_lmv_exp; /* XXX lov_exp */ + struct obd_device *mds_lmv_obd; + struct obd_export *mds_lmv_exp; + struct ptlrpc_service *mds_create_service; struct semaphore mds_lmv_sem; uid_t mds_squash_uid; @@ -377,7 +379,8 @@ struct mds_obd { ptl_nid_t mds_nosquash_nid; atomic_t mds_real_clients; struct obd_uuid mds_lmv_uuid; - struct dentry *mds_fids_dir; + struct dentry *mds_id_dir; + int mds_obd_type; int mds_lmv_connected; struct dentry *mds_unnamed_dir; /* for mdt_obd_create only */ }; @@ -426,54 +429,55 @@ 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 *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 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 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; - struct semaphore lov_llog_sem; - int bufsize; - int refcount; - int lo_catalog_loaded:1; - unsigned long lov_connect_flags; - struct lov_tgt_desc *tgts; + 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; }; 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; @@ -492,13 +496,13 @@ struct niobuf_local { int rc; }; -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; +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; }; @@ -628,34 +632,35 @@ 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 cache_manager_obd cmobd; + 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; } 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 0x0001 -#define OBD_OPT_FAILOVER 0x0002 -#define OBD_OPT_REAL_CLIENT 0x0004 -#define OBD_OPT_MDS_CONNECTION 0x0008 +#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_LLOG_FL_SENDNOW 0x0001 -#define OBD_LLOG_FL_CREATE 0x0002 +#define OBD_LLOG_FL_SENDNOW (1 << 0) +#define OBD_LLOG_FL_CREATE (1 << 1) struct mdc_op_data; @@ -805,6 +810,11 @@ 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); /* @@ -815,11 +825,11 @@ struct obd_ops { }; struct md_ops { - int (*m_getstatus)(struct obd_export *, struct ll_fid *); - int (*m_change_cbdata)(struct obd_export *, struct ll_fid *, + int (*m_getstatus)(struct obd_export *, struct lustre_id *); + int (*m_change_cbdata)(struct obd_export *, struct lustre_id *, ldlm_iterator_t, void *); - int (*m_change_cbdata_name)(struct obd_export *, struct ll_fid *, - char *, int, struct ll_fid *, + int (*m_change_cbdata_name)(struct obd_export *, struct lustre_id *, + char *, int, struct lustre_id *, ldlm_iterator_t, void *); int (*m_close)(struct obd_export *, struct obdo *, struct obd_client_handle *, @@ -832,15 +842,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 ll_fid *, + int (*m_getattr)(struct obd_export *, struct lustre_id *, unsigned long, unsigned int, struct ptlrpc_request **); - int (*m_getattr_name)(struct obd_export *, struct ll_fid *, + int (*m_getattr_name)(struct obd_export *, struct lustre_id *, char *, int, unsigned long, unsigned int, struct ptlrpc_request **); int (*m_intent_lock)(struct obd_export *, - struct ll_fid *, const char *, int, - void *, int, struct ll_fid *, + struct lustre_id *, const char *, int, + void *, int, struct lustre_id *, struct lookup_intent *, int, struct ptlrpc_request **, ldlm_blocking_callback); @@ -852,13 +862,14 @@ 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 ll_fid *, + int (*m_sync)(struct obd_export *, struct lustre_id *, struct ptlrpc_request **); - int (*m_readpage)(struct obd_export *, struct ll_fid *, + int (*m_readpage)(struct obd_export *, struct lustre_id *, __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 ll_fid *); + int (*m_valid_attrs)(struct obd_export *, struct lustre_id *); + struct obd_device * (*m_get_real_obd)(struct obd_export *, char *name, int len); @@ -875,24 +886,26 @@ 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 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. + 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. */ }; -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 dd05896..0c30089 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_osc; - char * lp_mdc; + char *lp_profile; + char *lp_lov; + char *lp_lmv; }; struct lustre_profile *class_get_profile(char * prof); @@ -141,6 +141,7 @@ 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); @@ -154,9 +155,10 @@ 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 failover); -void class_disconnect_exports(struct obd_device *obddev, int failover); -void class_disconnect_stale_exports(struct obd_device *obddev, int failover); +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); + /* 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); @@ -698,6 +700,17 @@ 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; @@ -719,12 +732,13 @@ static inline int obd_destroy_export(struct obd_export *exp) } static inline struct dentry * -obd_lvfs_fid2dentry(struct obd_export *exp, __u64 id_ino, __u32 gen, __u64 gr) +obd_lvfs_id2dentry(struct obd_export *exp, __u64 ino, + __u32 gen, __u64 gr) { LASSERT(exp->exp_obd); - return lvfs_fid2dentry(&exp->exp_obd->obd_lvfs_ctxt, id_ino, gen, gr, - exp->exp_obd); + return lvfs_id2dentry(&exp->exp_obd->obd_lvfs_ctxt, + ino, gen, gr, exp->exp_obd); } #ifndef time_before @@ -1188,20 +1202,21 @@ 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 ll_fid *fid) + +static inline int md_getstatus(struct obd_export *exp, struct lustre_id *id) { int rc; EXP_CHECK_MD_OP(exp, getstatus); MD_COUNTER_INCREMENT(exp->exp_obd, getstatus); - rc = MDP(exp->exp_obd, getstatus)(exp, fid); + rc = MDP(exp->exp_obd, getstatus)(exp, id); RETURN(rc); } -/* this function notifies MDC, that inode described by @fid gets removed from +/* this function notifies MDC, that inode described by @id gets removed from * memory.*/ static inline int md_delete_object(struct obd_export *exp, - struct ll_fid *fid) + struct lustre_id *id) { int rc; ENTRY; @@ -1213,11 +1228,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, fid); + rc = MDP(exp->exp_obd, delete_object)(exp, id); RETURN(rc); } -static inline int md_getattr(struct obd_export *exp, struct ll_fid *fid, +static inline int md_getattr(struct obd_export *exp, struct lustre_id *id, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request) { @@ -1225,24 +1240,24 @@ static inline int md_getattr(struct obd_export *exp, struct ll_fid *fid, ENTRY; EXP_CHECK_MD_OP(exp, getattr); MD_COUNTER_INCREMENT(exp->exp_obd, getattr); - rc = MDP(exp->exp_obd, getattr)(exp, fid, valid, ea_size, request); + rc = MDP(exp->exp_obd, getattr)(exp, id, valid, ea_size, request); RETURN(rc); } -static inline int md_change_cbdata(struct obd_export *exp, struct ll_fid *fid, +static inline int md_change_cbdata(struct obd_export *exp, struct lustre_id *id, 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, fid, it, data); + rc = MDP(exp->exp_obd, change_cbdata)(exp, id, it, data); RETURN(rc); } static inline int md_change_cbdata_name(struct obd_export *exp, - struct ll_fid *fid, char *name, - int namelen, struct ll_fid *fid2, + struct lustre_id *id, char *name, + int namelen, struct lustre_id *id2, ldlm_iterator_t it, void *data) { int rc; @@ -1254,8 +1269,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, fid, name, namelen, - fid2, it, data); + rc = MDP(exp->exp_obd, change_cbdata_name)(exp, id, name, namelen, + id2, it, data); RETURN(rc); } @@ -1315,7 +1330,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 ll_fid *fid, +static inline int 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) @@ -1324,15 +1339,15 @@ static inline int md_getattr_name(struct obd_export *exp, struct ll_fid *fid, ENTRY; EXP_CHECK_MD_OP(exp, getattr_name); MD_COUNTER_INCREMENT(exp->exp_obd, getattr_name); - rc = MDP(exp->exp_obd, getattr_name)(exp, fid, filename, namelen, + rc = MDP(exp->exp_obd, getattr_name)(exp, id, filename, namelen, valid, ea_size, request); RETURN(rc); } static inline int md_intent_lock(struct obd_export *exp, - struct ll_fid *pfid, const char *name, + struct lustre_id *pid, const char *name, int len, void *lmm, int lmmsize, - struct ll_fid *cfid, struct lookup_intent *it, + struct lustre_id *cid, struct lookup_intent *it, int flags, struct ptlrpc_request **reqp, ldlm_blocking_callback cb_blocking) { @@ -1340,8 +1355,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, pfid, name, len, - lmm, lmmsize, cfid, it, flags, + rc = MDP(exp->exp_obd, intent_lock)(exp, pid, name, len, + lmm, lmmsize, cid, it, flags, reqp, cb_blocking); RETURN(rc); } @@ -1385,18 +1400,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 ll_fid *fid, +static inline int md_sync(struct obd_export *exp, struct lustre_id *id, 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, fid, request); + rc = MDP(exp->exp_obd, sync)(exp, id, request); RETURN(rc); } -static inline int md_readpage(struct obd_export *exp, struct ll_fid *fid, +static inline int md_readpage(struct obd_export *exp, struct lustre_id *id, __u64 offset, struct page *page, struct ptlrpc_request **request) { @@ -1404,7 +1419,7 @@ static inline int md_readpage(struct obd_export *exp, struct ll_fid *fid, ENTRY; EXP_CHECK_MD_OP(exp, readpage); MD_COUNTER_INCREMENT(exp->exp_obd, readpage); - rc = MDP(exp->exp_obd, readpage)(exp, fid, offset, page, request); + rc = MDP(exp->exp_obd, readpage)(exp, id, offset, page, request); RETURN(rc); } @@ -1429,12 +1444,13 @@ 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 ll_fid *fid) +static inline int md_valid_attrs(struct obd_export *exp, + struct lustre_id *id) { ENTRY; EXP_CHECK_MD_OP(exp, valid_attrs); MD_COUNTER_INCREMENT(exp->exp_obd, valid_attrs); - return MDP(exp->exp_obd, valid_attrs)(exp, fid); + return MDP(exp->exp_obd, valid_attrs)(exp, id); } static inline int md_req2lustre_md(struct obd_export *exp, @@ -1479,7 +1495,8 @@ 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 a3dc652..ad5d653 100644 --- a/lustre/include/linux/obd_lmv.h +++ b/lustre/include/linux/obd_lmv.h @@ -7,5 +7,4 @@ #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 new file mode 100644 index 0000000..0aa7916 --- /dev/null +++ b/lustre/kernel_patches/patches/ext3-dentry-fid.patch @@ -0,0 +1,52 @@ +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 73a495a..75d4767 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.7 2004/10/23 13:47:08 yury Exp $" ++#ident "$Id: kksymoops-2.4.24.vanilla.patch,v 1.8 2004/10/24 16:10:34 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 fd99cca..ff01c9c 100644 --- a/lustre/kernel_patches/series/vanilla-2.4.24 +++ b/lustre/kernel_patches/series/vanilla-2.4.24 @@ -50,3 +50,4 @@ 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 d0e2466..73e3ece 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 failover) +int client_disconnect_export(struct obd_export *exp, int flags) { struct obd_device *obd = class_exp2obd(exp); struct client_obd *cli = &obd->u.cli; @@ -810,6 +810,7 @@ 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; @@ -865,6 +866,8 @@ 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 @@ -904,6 +907,7 @@ void target_cleanup_recovery(struct obd_device *obd) } } +#ifdef __KERNEL__ static void target_abort_recovery(void *data) { struct obd_device *obd = data; @@ -919,6 +923,7 @@ 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) { @@ -940,6 +945,7 @@ 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); @@ -952,7 +958,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) @@ -970,6 +976,7 @@ 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; @@ -1043,7 +1050,6 @@ target_next_replay_req(struct obd_device *obd) return req; } -#ifdef __KERNEL__ static int target_recovery_thread(void *arg) { struct obd_device *obd = arg; @@ -1138,6 +1144,7 @@ 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 3b9b0f6..b50e458 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 ll_fid mdc_fid; + struct lustre_id id; __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_mdc_exp); + struct obd_device *obddev = class_exp2obd(sbi->ll_lmv_exp); struct ldlm_res_id res_id = - { .name = {lli->lli_st_ino, (__u64)lli->lli_st_generation} }; + { .name = {id_fid(&lli->lli_id), id_group(&lli->lli_id)} }; 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_op_data(&data, inode, NULL, NULL, 0, 0); + llu_prepare_mdc_data(&data, inode, NULL, NULL, 0, 0); - rc = mdc_enqueue(sbi->ll_mdc_exp, LDLM_IBITS, &it, LCK_PR, + rc = mdc_enqueue(sbi->ll_lmv_exp, LDLM_IBITS, &it, LCK_PR, &data, &lockh, NULL, 0, ldlm_completion_ast, llu_mdc_blocking_ast, inode); @@ -84,11 +84,12 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page) } ldlm_lock_dump_handle(D_OTHER, &lockh); - mdc_pack_fid(&mdc_fid, lli->lli_st_ino, lli->lli_st_generation, S_IFDIR); + /* 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); offset = page->index << PAGE_SHIFT; - rc = mdc_readpage(sbi->ll_mdc_exp, &mdc_fid, - offset, page, &request); + rc = mdc_readpage(sbi->ll_lmv_exp, &id, 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 0ceefdb..78b9202 100644 --- a/lustre/liblustre/file.c +++ b/lustre/liblustre/file.c @@ -42,22 +42,17 @@ #include "llite_lib.h" -void llu_prepare_mdc_op_data(struct mdc_op_data *data, - struct inode *i1, - struct inode *i2, - const char *name, - int namelen, - int mode) +void llu_prepare_mdc_data(struct mdc_op_data *data, struct inode *i1, + struct inode *i2, const char *name, + int namelen, int mode) { LASSERT(i1); - ll_i2uctxt(&data->ctxt, i1, i2); - ll_inode2fid(&data->fid1, i1); - - if (i2) { - ll_inode2fid(&data->fid2, i2); - } + ll_inode2id(&data->id1, i1); + if (i2) + ll_inode2id(&data->id2, i2); + data->valid = 0; data->name = name; data->namelen = namelen; data->create_mode = mode; @@ -345,7 +340,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_mdc_exp, inode); + rc2 = llu_mdc_close(sbi->ll_lmv_exp, inode); if (rc2 && !rc) rc = rc2; diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c index 88c92d1..bf006fa 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, NULL); + LCFG_INIT(lcfg, LCFG_ADD_UUID, name); lcfg.lcfg_nid = nid; lcfg.lcfg_inllen1 = strlen(peer) + 1; lcfg.lcfg_inlbuf1 = peer; @@ -146,9 +146,8 @@ 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_parse_llog failed: rc = %d\n", rc); - } + if (rc) + CERROR("class_config_process_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 6c0c61d..34f1fea 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_mdc_exp; - struct obd_export *ll_osc_exp; + struct obd_export *ll_lmv_exp; + struct obd_export *ll_lov_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 ll_fid lli_fid; + struct lustre_id lli_id; struct lov_stripe_md *lli_smd; char *lli_symlink_name; @@ -81,10 +81,9 @@ 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; @@ -126,17 +125,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_osc_exp; + return llu_i2info(inode)->lli_sbi->ll_lov_exp; } static inline struct obd_export *llu_i2mdcexp(struct inode *inode) { - return llu_i2info(inode)->lli_sbi->ll_mdc_exp; + return llu_i2info(inode)->lli_sbi->ll_lmv_exp; } static inline int llu_is_root_inode(struct inode *inode) { - return (llu_i2info(inode)->lli_fid.id == + return (llu_i2info(inode)->lli_id.li_stc.u.e3s.l3s_ino == llu_i2info(inode)->lli_sbi->ll_rootino); } @@ -166,17 +165,18 @@ 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,12 +221,10 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr); extern struct fssw_ops llu_fssw_ops; /* file.c */ -void llu_prepare_mdc_op_data(struct mdc_op_data *data, - struct inode *i1, - struct inode *i2, - const char *name, - int namelen, - int mode); +void llu_prepare_mdc_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 2a7c5e0..04606fd 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] != 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 (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 (S_ISDIR(lli->lli_st_mode) && (bits & MDS_INODELOCK_UPDATE)) { @@ -166,11 +166,6 @@ 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; } @@ -199,8 +194,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_mdc_exp, req, offset, - llu_i2sbi(inode)->ll_osc_exp, &md); + rc = mdc_req2lustre_md(llu_i2sbi(inode)->ll_lmv_exp, req, offset, + llu_i2sbi(inode)->ll_lov_exp, &md); if (rc) RETURN(rc); @@ -212,9 +207,8 @@ 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 ll_fid pfid, cfid; + struct lustre_id pid, cid; 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; @@ -249,8 +243,8 @@ int llu_pb_revalidate(struct pnode *pnode, int flags, struct lookup_intent *it) } exp = llu_i2mdcexp(pb->pb_ino); - ll_inode2fid(&pfid, pnode->p_parent->p_base->pb_ino); - ll_inode2fid(&cfid, pb->pb_ino); + ll_inode2id(&pid, pnode->p_parent->p_base->pb_ino); + ll_inode2id(&cid, pb->pb_ino); icbd.icbd_parent = pnode->p_parent->p_base->pb_ino; icbd.icbd_child = pnode; @@ -259,12 +253,8 @@ int llu_pb_revalidate(struct pnode *pnode, int flags, struct lookup_intent *it) it->it_op_release = ll_intent_release; } - 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); + rc = mdc_intent_lock(exp, &pid, pb->pb_name.name, pb->pb_name.len, + NULL, 0, &cid, 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) @@ -340,8 +330,8 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, struct llu_inode_info *lli; ENTRY; - rc = mdc_req2lustre_md(sbi->ll_mdc_exp, request, offset, - sbi->ll_osc_exp, &md); + rc = mdc_req2lustre_md(sbi->ll_lmv_exp, request, offset, + sbi->ll_lov_exp, &md); if (rc) RETURN(rc); @@ -349,11 +339,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_osc_exp, &md.lsm); + obd_free_memmd(sbi->ll_lov_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_osc_exp, &md.lsm); + obd_free_memmd(sbi->ll_lov_exp, &md.lsm); } lli = llu_i2info(inode); @@ -406,8 +396,7 @@ 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 ll_fid pfid; - struct ll_uctxt ctxt; + struct lustre_id pid; struct it_cb_data icbd; struct ptlrpc_request *req = NULL; struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; @@ -425,10 +414,9 @@ static int llu_lookup_it(struct inode *parent, struct pnode *pnode, icbd.icbd_child = pnode; icbd.icbd_parent = parent; icbd.icbd_child = pnode; - ll_inode2fid(&pfid, parent); - ll_i2uctxt(&ctxt, parent, NULL); + ll_inode2id(&pid, parent); - rc = mdc_intent_lock(llu_i2mdcexp(parent), &ctxt, &pfid, + rc = mdc_intent_lock(llu_i2mdcexp(parent), &pid, 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 8c4c686..15be024 100644 --- a/lustre/liblustre/rw.c +++ b/lustre/liblustre/rw.c @@ -32,9 +32,8 @@ #include #include -#include -#include #include +#include #include #include #include @@ -224,7 +223,7 @@ int llu_glimpse_size(struct inode *inode) CDEBUG(D_DLMTRACE, "Glimpsing inode %lu\n", lli->lli_st_ino); - rc = obd_enqueue(sbi->ll_osc_exp, lli->lli_smd, LDLM_EXTENT, &policy, + rc = obd_enqueue(sbi->ll_lov_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); @@ -240,7 +239,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_osc_exp, lli->lli_smd, LCK_PR, &lockh); + obd_cancel(sbi->ll_lov_exp, lli->lli_smd, LCK_PR, &lockh); RETURN(rc); } @@ -265,7 +264,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_osc_exp, lsm, LDLM_EXTENT, policy, mode, + rc = obd_enqueue(sbi->ll_lov_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); @@ -294,7 +293,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_osc_exp, lsm, mode, lockh); + rc = obd_cancel(sbi->ll_lov_exp, lsm, mode, lockh); RETURN(rc); } diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 028c2c8..7b5fc95 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_mdc_exp); + struct obd_device *obd = class_exp2obd(sbi->ll_lmv_exp); struct lustre_cfg lcfg; int next = 0; ENTRY; list_del(&sbi->ll_conn_chain); - obd_disconnect(sbi->ll_osc_exp, 0); - obd_disconnect(sbi->ll_mdc_exp, 0); + obd_disconnect(sbi->ll_lov_exp, 0); + obd_disconnect(sbi->ll_lmv_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; } -static struct inode_ops llu_inode_ops; +struct inode_ops llu_inode_ops; void llu_update_inode(struct inode *inode, struct mds_body *body, struct lov_stripe_md *lsm) @@ -139,8 +139,19 @@ 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 = body->ino; + lli->lli_st_ino = id_ino(&body->id1); + if (body->valid & OBD_MD_FLGENER) + lli->lli_st_generation = id_gen(&body->id1); + if (body->valid & OBD_MD_FLATIME) LTIME_S(lli->lli_st_atime) = body->atime; if (body->valid & OBD_MD_FLMTIME) @@ -159,22 +170,12 @@ 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) @@ -342,7 +343,7 @@ int llu_inode_getattr(struct inode *inode, struct lov_stripe_md *lsm) } static struct inode* llu_new_inode(struct filesys *fs, - struct ll_fid *fid) + struct lustre_id *id) { struct inode *inode; struct llu_inode_info *lli; @@ -359,17 +360,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_fid; - lli->lli_sysio_fid.fid_len = sizeof(lli->lli_fid); + lli->lli_sysio_fid.fid_data = &lli->lli_id; + lli->lli_sysio_fid.fid_len = sizeof(lli->lli_id); - memcpy(&lli->lli_fid, fid, sizeof(*fid)); + memcpy(&lli->lli_id, id, sizeof(*id)); /* file identifier is needed by functions like _sysio_i_find() */ inode = _sysio_i_new(fs, &lli->lli_sysio_fid, #ifndef AUTOMOUNT_FILE_NAME - fid->f_type & S_IFMT, + id->li_stc.u.e3s.l3s_type & S_IFMT, #else - fid->f_type, /* all of the bits! */ + id->li_stc.u.e3s.l3s_type, /* all of the bits! */ #endif 0, 0, &llu_inode_ops, lli); @@ -393,9 +394,9 @@ static int llu_have_md_lock(struct inode *inode, __u64 lockpart) LASSERT(inode); - obddev = sbi->ll_mdc_exp->exp_obd; - res_id.name[0] = lli->lli_st_ino; - res_id.name[1] = lli->lli_st_generation; + 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); CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id.name[0]); @@ -430,24 +431,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 ll_fid fid; + struct lustre_id id; 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_osc_exp, NULL); + ealen = obd_size_diskmd(sbi->ll_lov_exp, NULL); valid |= OBD_MD_FLEASIZE; } - ll_inode2fid(&fid, inode); - rc = mdc_getattr(sbi->ll_mdc_exp, &fid, valid, ealen, &req); + ll_inode2id(&id, inode); + rc = mdc_getattr(sbi->ll_lmv_exp, &id, 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_mdc_exp, req, 0, sbi->ll_osc_exp, - &md); + rc = mdc_req2lustre_md(sbi->ll_lmv_exp, req, 0, + sbi->ll_lov_exp, &md); /* XXX Too paranoid? */ if (((md.body->valid ^ valid) & OBD_MD_FLEASIZE) && @@ -466,7 +467,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_osc_exp, &md.lsm); + obd_free_memmd(sbi->ll_lov_exp, &md.lsm); if (md.body->valid & OBD_MD_FLSIZE) set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, @@ -545,7 +546,7 @@ static int null_if_equal(struct ldlm_lock *lock, void *data) void llu_clear_inode(struct inode *inode) { - struct ll_fid fid; + struct lustre_id id; struct llu_inode_info *lli = llu_i2info(inode); struct llu_sb_info *sbi = llu_i2sbi(inode); ENTRY; @@ -553,16 +554,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_inode2fid(&fid, inode); + ll_inode2id(&id, inode); clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(lli->lli_flags)); - mdc_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode); + mdc_change_cbdata(sbi->ll_lmv_exp, &id, null_if_equal, inode); if (lli->lli_smd) - obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd, + obd_change_cbdata(sbi->ll_lov_exp, lli->lli_smd, null_if_equal, inode); if (lli->lli_smd) { - obd_free_memmd(sbi->ll_osc_exp, &lli->lli_smd); + obd_free_memmd(sbi->ll_lov_exp, &lli->lli_smd); lli->lli_smd = NULL; } @@ -681,11 +682,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_op_data(&op_data, inode, NULL, NULL, 0, 0); - - rc = mdc_setattr(sbi->ll_mdc_exp, &op_data, - attr, NULL, 0, NULL, 0, &request); + llu_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0); + 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) @@ -693,8 +694,8 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr) RETURN(rc); } - rc = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0, - sbi->ll_osc_exp, &md); + rc = mdc_req2lustre_md(sbi->ll_lmv_exp, request, 0, + sbi->ll_lov_exp, &md); if (rc) { ptlrpc_req_finished(request); RETURN(rc); @@ -771,7 +772,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_osc_exp, &oa, lsm, NULL); + rc = obd_setattr(sbi->ll_lov_exp, &oa, lsm, NULL); if (rc) CERROR("obd_setattr fails: rc=%d\n", rc); } @@ -843,8 +844,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_op_data(&op_data, dir, NULL, name, len, 0); - err = mdc_create(sbi->ll_mdc_exp, &op_data, + llu_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); + err = mdc_create(sbi->ll_lmv_exp, &op_data, tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO, current->fsuid, current->fsgid, 0, &request); ptlrpc_req_finished(request); @@ -857,7 +858,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 ll_fid fid; + struct lustre_id id; struct mds_body *body; int rc, symlen = lli->lli_st_size + 1; ENTRY; @@ -870,8 +871,8 @@ static int llu_readlink_internal(struct inode *inode, RETURN(0); } - ll_inode2fid(&fid, inode); - rc = mdc_getattr(sbi->ll_mdc_exp, &fid, + ll_inode2id(&id, inode); + rc = mdc_getattr(sbi->ll_lmv_exp, &id, OBD_MD_LINKNAME, symlen, request); if (rc) { CERROR("inode %lu: rc = %d\n", lli->lli_st_ino, rc); @@ -962,11 +963,11 @@ static int llu_iop_mknod_raw(struct pnode *pno, case S_IFBLK: case S_IFIFO: case S_IFSOCK: - 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, + 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, current->fsuid, current->fsgid, dev, &request); ptlrpc_req_finished(request); break; @@ -994,8 +995,8 @@ static int llu_iop_link_raw(struct pnode *old, struct pnode *new) LASSERT(dir); liblustre_wait_event(0); - llu_prepare_mdc_op_data(&op_data, src, dir, name, namelen, 0); - rc = mdc_link(llu_i2sbi(src)->ll_mdc_exp, &op_data, &request); + llu_prepare_mdc_data(&op_data, src, dir, name, namelen, 0); + rc = mdc_link(llu_i2sbi(src)->ll_lmv_exp, &op_data, &request); ptlrpc_req_finished(request); liblustre_wait_event(0); @@ -1020,13 +1021,12 @@ static int llu_iop_unlink_raw(struct pnode *pno) LASSERT(target); liblustre_wait_event(0); - llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); - rc = mdc_unlink(llu_i2sbi(dir)->ll_mdc_exp, &op_data, &request); + llu_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); + rc = mdc_unlink(llu_i2sbi(dir)->ll_lmv_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_op_data(&op_data, src, tgt, NULL, 0, 0); - rc = mdc_rename(llu_i2sbi(src)->ll_mdc_exp, &op_data, + llu_prepare_mdc_data(&op_data, src, tgt, NULL, 0, 0); + rc = mdc_rename(llu_i2sbi(src)->ll_lmv_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_mdc_exp), osfs, max_age); + rc = obd_statfs(class_exp2obd(sbi->ll_lmv_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_osc_exp), &obd_osfs, max_age); + rc = obd_statfs(class_exp2obd(sbi->ll_lov_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_fsid.__val[1]; + buf->f_fsid = fs.f_fstc.__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_op_data(&op_data, dir, NULL, name, len, 0); - err = mdc_create(llu_i2sbi(dir)->ll_mdc_exp, &op_data, NULL, 0, mode, + 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, 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_op_data(&op_data, dir, NULL, name, len, S_IFDIR); - rc = mdc_unlink(llu_i2sbi(dir)->ll_mdc_exp, &op_data, &request); + llu_prepare_mdc_data(&op_data, dir, NULL, name, len, S_IFDIR); + rc = mdc_unlink(llu_i2sbi(dir)->ll_lmv_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 don't support O_NONBLOCK, O_ASYNC, " + CERROR("liblustre does not 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 ll_fid fid; - struct file_identifier fileid = {&fid, sizeof(fid)}; + struct lustre_id id; + struct file_identifier fileid = {&id, sizeof(id)}; if ((md->body->valid & (OBD_MD_FLGENER | OBD_MD_FLID | OBD_MD_FLTYPE)) != @@ -1364,17 +1364,15 @@ struct inode *llu_iget(struct filesys *fs, struct lustre_md *md) return ERR_PTR(-EPERM); } - /* try to find existing inode */ - fid.id = md->body->ino; - fid.generation = md->body->generation; - fid.f_type = md->body->mode & S_IFMT; + id = md->body->id1; + /* try to find existing inode */ inode = _sysio_i_find(fs, &fileid); if (inode) { struct llu_inode_info *lli = llu_i2info(inode); if (inode->i_zombie || - lli->lli_st_generation != md->body->generation) { + lli->lli_st_generation != id_gen(&md->body->id1)) { I_RELE(inode); } else { @@ -1383,15 +1381,13 @@ struct inode *llu_iget(struct filesys *fs, struct lustre_md *md) } } - inode = llu_new_inode(fs, &fid); + inode = llu_new_inode(fs, &id); 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, @@ -1403,18 +1399,18 @@ llu_fsswop_mount(const char *source, struct inode *root; struct pnode_base *rootpb; struct obd_device *obd; - struct ll_fid rootfid; + struct lustre_id rootid; struct llu_sb_info *sbi; struct obd_statfs osfs; static struct qstr noname = { NULL, 0, 0 }; struct ptlrpc_request *request = NULL; - struct lustre_handle mdc_conn = {0, }; - struct lustre_handle osc_conn = {0, }; + struct lustre_handle lmv_conn = {0, }; + struct lustre_handle lov_conn = {0, }; struct lustre_md md; class_uuid_t uuid; struct config_llog_instance cfg; struct lustre_profile *lprof; - char *osc = NULL, *mdc = NULL; + char *lov = NULL, *lmv = NULL; int async = 1, err = -EINVAL; ENTRY; @@ -1449,23 +1445,23 @@ llu_fsswop_mount(const char *source, CERROR("No profile found: %s\n", g_zconf_profile); GOTO(out_free, err = -EINVAL); } - if (osc) - OBD_FREE(osc, strlen(osc) + 1); - OBD_ALLOC(osc, strlen(lprof->lp_osc) + + if (lov) + OBD_FREE(lov, strlen(lov) + 1); + OBD_ALLOC(lov, strlen(lprof->lp_lov) + strlen(sbi->ll_instance) + 2); - sprintf(osc, "%s-%s", lprof->lp_osc, sbi->ll_instance); + sprintf(lov, "%s-%s", lprof->lp_lov, sbi->ll_instance); - if (mdc) - OBD_FREE(mdc, strlen(mdc) + 1); - OBD_ALLOC(mdc, strlen(lprof->lp_mdc) + + if (lmv) + OBD_FREE(lmv, strlen(lmv) + 1); + OBD_ALLOC(lmv, strlen(lprof->lp_lmv) + strlen(sbi->ll_instance) + 2); - sprintf(mdc, "%s-%s", lprof->lp_mdc, sbi->ll_instance); + sprintf(lmv, "%s-%s", lprof->lp_lmv, sbi->ll_instance); - if (!osc) { + if (!lov) { CERROR("no osc\n"); GOTO(out_free, err = -EINVAL); } - if (!mdc) { + if (!lmv) { CERROR("no mdc\n"); GOTO(out_free, err = -EINVAL); } @@ -1476,68 +1472,68 @@ llu_fsswop_mount(const char *source, goto out_free; } - obd = class_name2obd(mdc); + obd = class_name2obd(lmv); if (!obd) { - CERROR("MDC %s: not setup or attached\n", mdc); + CERROR("MDC %s: not setup or attached\n", lmv); 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, osc)) + if (mdc_init_ea_size(obd, lov)) GOTO(out_free, err = -EINVAL); #endif /* setup mdc */ - err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, 0); + err = obd_connect(&lmv_conn, obd, &sbi->ll_sb_uuid, 0); if (err) { - CERROR("cannot connect to %s: rc = %d\n", mdc, err); + CERROR("cannot connect to %s: rc = %d\n", lmv, err); GOTO(out_free, err); } - sbi->ll_mdc_exp = class_conn2export(&mdc_conn); + sbi->ll_lmv_exp = class_conn2export(&lmv_conn); err = obd_statfs(obd, &osfs, 100000000); if (err) - GOTO(out_mdc, err); + GOTO(out_lmv, err); /* * FIXME fill fs stat data into sbi here!!! FIXME */ - /* setup osc */ - obd = class_name2obd(osc); + /* setup lov */ + obd = class_name2obd(lov); if (!obd) { - CERROR("OSC %s: not setup or attached\n", osc); - GOTO(out_mdc, err = -EINVAL); + CERROR("OSC %s: not setup or attached\n", lov); + GOTO(out_lmv, err = -EINVAL); } obd_set_info(obd->obd_self_export, strlen("async"), "async", sizeof(async), &async); - err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, 0); + err = obd_connect(&lov_conn, obd, &sbi->ll_sb_uuid, 0); if (err) { - CERROR("cannot connect to %s: rc = %d\n", osc, err); - GOTO(out_mdc, err); + CERROR("cannot connect to %s: rc = %d\n", lov, err); + GOTO(out_lmv, err); } - sbi->ll_osc_exp = class_conn2export(&osc_conn); + sbi->ll_lov_exp = class_conn2export(&lov_conn); - err = mdc_getstatus(sbi->ll_mdc_exp, &rootfid); + err = mdc_getstatus(sbi->ll_lmv_exp, &rootid); if (err) { CERROR("cannot mds_connect: rc = %d\n", err); - GOTO(out_osc, err); + GOTO(out_lov, err); } - CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id); - sbi->ll_rootino = rootfid.id; + CDEBUG(D_SUPER, "rootid "LPU64"\n", rootid.li_stc.u.e3s.l3s_ino); + sbi->ll_rootino = rootid.li_stc.u.e3s.l3s_ino; /* fetch attr of root inode */ - err = mdc_getattr(sbi->ll_mdc_exp, &rootfid, + err = mdc_getattr(sbi->ll_lmv_exp, &rootid, OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, 0, &request); if (err) { CERROR("mdc_getattr failed for root: rc = %d\n", err); - GOTO(out_osc, err); + GOTO(out_lov, err); } - err = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0, sbi->ll_osc_exp, - &md); + err = mdc_req2lustre_md(sbi->ll_lmv_exp, request, 0, + sbi->ll_lov_exp, &md); if (err) { CERROR("failed to understand root inode md: rc = %d\n",err); GOTO(out_request, err); @@ -1576,10 +1572,10 @@ out_inode: _sysio_i_gone(root); out_request: ptlrpc_req_finished(request); -out_osc: - obd_disconnect(sbi->ll_osc_exp, 0); -out_mdc: - obd_disconnect(sbi->ll_mdc_exp, 0); +out_lov: + obd_disconnect(sbi->ll_lov_exp, 0); +out_lmv: + obd_disconnect(sbi->ll_lmv_exp, 0); out_free: OBD_FREE(sbi, sizeof(*sbi)); return err; @@ -1589,31 +1585,30 @@ struct fssw_ops llu_fssw_ops = { llu_fsswop_mount }; -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, +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, #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 1984bc0..7743136 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_osc_exp, sbi->ll_mdc_exp, + rc = ll_prep_inode(sbi->ll_lov_exp, sbi->ll_lmv_exp, &de->d_inode, request, offset, NULL); RETURN(rc); @@ -203,6 +203,7 @@ 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", @@ -220,7 +221,8 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd, struct lookup_intent *it) { int rc; - struct ll_fid pfid, cfid; + struct lustre_id pid; + struct lustre_id cid; struct it_cb_data icbd; struct ptlrpc_request *req = NULL; struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; @@ -235,18 +237,20 @@ 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_i2mdcexp(de->d_inode); - ll_inode2fid(&pfid, de->d_parent->d_inode); - ll_inode2fid(&cfid, de->d_inode); + exp = ll_i2lmvexp(de->d_inode); + ll_inode2id(&pid, de->d_parent->d_inode); + ll_inode2id(&cid, 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); @@ -258,8 +262,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, &pfid, de->d_name.name, - de->d_name.len, NULL, 0, &cfid, &lookup_it, + rc = md_intent_lock(exp, &pid, de->d_name.name, + de->d_name.len, NULL, 0, &cid, &lookup_it, flags, &req, ll_mdc_blocking_ast); /* If there was no lookup lock, no point in even checking for UPDATE lock */ @@ -279,9 +283,13 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd, ll_lookup_finish_locks(&lookup_it, de); } - rc = md_intent_lock(exp, &pfid, de->d_name.name, de->d_name.len, - NULL, 0, &cfid, it, flags, &req, + /* 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, 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) @@ -362,7 +370,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_mdc_exp, inode->i_ino, inode->i_generation, + rc = obd_pin(sbi->ll_lmv_exp, inode->i_ino, inode->i_generation, inode->i_mode & S_IFMT, handle, flag); if (rc) { @@ -412,7 +420,7 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd, return; } - rc = obd_unpin(sbi->ll_mdc_exp, &handle, flag); + rc = obd_unpin(sbi->ll_lmv_exp, &handle, flag); EXIT; return; } @@ -436,12 +444,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 ll_fid parent, child; + struct lustre_id parent, child; LASSERT(dentry->d_parent && dentry->d_parent->d_inode); - ll_inode2fid(&parent, dentry->d_parent->d_inode); - ll_inode2fid(&child, inode); - md_change_cbdata_name(sbi->ll_mdc_exp, &parent, + ll_inode2id(&parent, dentry->d_parent->d_inode); + ll_inode2id(&child, inode); + md_change_cbdata_name(sbi->ll_lmv_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 6ac70be..50d402d 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -61,24 +61,26 @@ 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_fid(&mdc_fid, inode->i_ino, inode->i_generation, S_IFDIR); - mdc_fid.mds = ll_i2info(inode)->lli_mds; + 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)); + offset = page->index << PAGE_SHIFT; - rc = md_readpage(ll_i2sbi(inode)->ll_mdc_exp, &mdc_fid, - offset, page, &request); + rc = md_readpage(ll_i2sbi(inode)->ll_lmv_exp, &id, 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!" @@ -88,8 +90,7 @@ static int ll_dir_readpage(struct file *file, struct page *page) ptlrpc_req_finished(request); unlock_page(page); - EXIT; - return rc; + RETURN(rc); } struct address_space_operations ll_dir_aops = { @@ -116,7 +117,6 @@ 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,16 +208,17 @@ 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 = { dir->i_ino, (__u64)dir->i_generation} }; + { .name = { id_fid(&li->lli_id), id_group(&li->lli_id)} }; struct lustre_handle lockh; - struct obd_device *obddev = class_exp2obd(ll_i2sbi(dir)->ll_mdc_exp); + struct obd_device *obddev = class_exp2obd(ll_i2sbi(dir)->ll_lmv_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_mdc_exp, NULL, 0); + obddev = md_get_real_obd(ll_i2sbi(dir)->ll_lmv_exp, NULL, 0); rc = ldlm_lock_match(obddev->obd_namespace, LDLM_FL_BLOCK_GRANTED, &res_id, LDLM_IBITS, &policy, LCK_PR, &lockh); if (!rc) { @@ -225,9 +226,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_op_data(&data, dir, NULL, NULL, 0, 0); + ll_prepare_mdc_data(&data, dir, NULL, NULL, 0, 0); - rc = md_enqueue(ll_i2sbi(dir)->ll_mdc_exp, LDLM_IBITS, &it, + rc = md_enqueue(ll_i2sbi(dir)->ll_lmv_exp, LDLM_IBITS, &it, LCK_PR, &data, &lockh, NULL, 0, ldlm_completion_ast, ll_mdc_blocking_ast, dir); @@ -400,8 +401,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_op_data(&op_data, inode, NULL, name,lums.lums_namelen,0); - err = md_create(sbi->ll_mdc_exp, &op_data, &nstripes, sizeof(nstripes), + 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), mode, current->fsuid, current->fsgid, 0, &request); ptlrpc_req_finished(request); @@ -430,7 +431,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 ll_fid fid; + struct lustre_id id; char *buf = NULL; char *filename; int namelen, rc, len = 0; @@ -450,8 +451,8 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, } valid = OBD_MD_FLID; - ll_inode2fid(&fid, inode); - rc = md_getattr_name(sbi->ll_mdc_exp, &fid, + ll_inode2id(&id, inode); + rc = md_getattr_name(sbi->ll_lmv_exp, &id, filename, namelen, valid, 0, &request); if (rc < 0) { CDEBUG(D_INFO, "md_getattr_name: %d\n", rc); @@ -476,7 +477,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_op_data(&op_data, inode, NULL, NULL, 0, 0); + ll_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0); LASSERT(sizeof(lum) == sizeof(*lump)); LASSERT(sizeof(lum.lmm_objects[0]) == @@ -488,7 +489,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_mdc_exp, &op_data, + rc = md_setattr(sbi->ll_lmv_exp, &op_data, &attr, &lum, sizeof(lum), NULL, 0, &request); if (rc) { ptlrpc_req_finished(request); @@ -504,16 +505,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 ll_fid fid; + struct lustre_id id; struct mds_body *body; unsigned long valid = 0; int rc, lmmsize; valid |= OBD_MD_FLDIREA; - ll_inode2fid(&fid, inode); - rc = md_getattr(sbi->ll_mdc_exp, &fid, valid, - obd_size_diskmd(sbi->ll_osc_exp, NULL), + ll_inode2id(&id, inode); + rc = md_getattr(sbi->ll_lmv_exp, &id, valid, + obd_size_diskmd(sbi->ll_lov_exp, NULL), &request); if (rc < 0) { CDEBUG(D_INFO, "md_getattr failed: rc = %d\n", rc); @@ -542,7 +543,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, } case IOC_MDC_GETSTRIPE: { struct ptlrpc_request *request = NULL; - struct ll_fid fid; + struct lustre_id id; struct mds_body *body; struct lov_user_md *lump = (struct lov_user_md *)arg; struct lov_mds_md *lmm; @@ -553,10 +554,10 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, if (IS_ERR(filename)) RETURN(PTR_ERR(filename)); - ll_inode2fid(&fid, inode); - rc = md_getattr_name(sbi->ll_mdc_exp, &fid, filename, + ll_inode2id(&id, inode); + rc = md_getattr_name(sbi->ll_lmv_exp, &id, filename, strlen(filename) + 1, OBD_MD_FLEASIZE, - obd_size_diskmd(sbi->ll_osc_exp, NULL), + obd_size_diskmd(sbi->ll_lov_exp, NULL), &request); if (rc < 0) { CDEBUG(D_INFO, "md_getattr_name failed on %s: rc %d\n", @@ -659,7 +660,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, bufs[1] = NULL; } size = data->ioc_plen1; - req = ptlrpc_prep_req(sbi2mdc(sbi)->cl_import, + req = ptlrpc_prep_req(sbi2lmv(sbi)->cl_import, LUSTRE_LOG_VERSION, LLOG_CATINFO, 2, lens, bufs); if (!req) @@ -678,7 +679,8 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, RETURN(rc); } default: - return obd_iocontrol(cmd, sbi->ll_osc_exp,0,NULL,(void *)arg); + return obd_iocontrol(cmd, sbi->ll_lov_exp, 0, + NULL, (void *)arg); } } diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 117a08c..e30f5ba 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 *mdc_exp, struct inode *inode, +int ll_mdc_close(struct obd_export *lmv_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 *mdc_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 = ll_i2info(inode)->lli_mds; - rc = md_close(mdc_exp, &obdo, och, &req); + obdo.o_mds = id_group(&ll_i2info(inode)->lli_id); + rc = md_close(lmv_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 *mdc_exp, struct inode *inode, inode->i_ino, rc); } - mdc_clear_open_replay_data(mdc_exp, och); + mdc_clear_open_replay_data(lmv_exp, och); ptlrpc_req_finished(req); och->och_fh.cookie = DEAD_HANDLE_MAGIC; file->private_data = NULL; @@ -101,9 +101,8 @@ int ll_file_release(struct inode *inode, struct file *file) int rc; ENTRY; - CDEBUG(D_VFSTRACE, "VFS Op:inode=%u/%lu/%u(%p)\n", - ll_i2info(inode)->lli_mds, inode->i_ino, - inode->i_generation, inode); + CDEBUG(D_VFSTRACE, "VFS Op:inode="DLID4"(%p)\n", + OLID4(&ll_i2info(inode)->lli_id), inode); /* don't do anything for / */ if (inode->i_sb->s_root == file->f_dentry) @@ -113,7 +112,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_mdc_exp, inode, file); + rc = ll_mdc_close(sbi->ll_lmv_exp, inode, file); RETURN(rc); } @@ -131,9 +130,9 @@ static int ll_intent_file_open(struct file *file, void *lmm, if (!parent) RETURN(-ENOENT); - ll_prepare_mdc_op_data(&data, parent->d_inode, NULL, name, len, O_RDWR); + ll_prepare_mdc_data(&data, parent->d_inode, NULL, name, len, O_RDWR); - rc = md_enqueue(sbi->ll_mdc_exp, LDLM_IBITS, itp, LCK_PR, &data, + rc = md_enqueue(sbi->ll_lmv_exp, LDLM_IBITS, itp, LCK_PR, &data, &lockh, lmm, lmmsize, ldlm_completion_ast, ll_mdc_blocking_ast, NULL); if (rc == 0) { @@ -151,7 +150,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 *mdc_exp = ll_i2mdcexp(file->f_dentry->d_inode); + struct obd_export *lmv_exp = ll_i2lmvexp(file->f_dentry->d_inode); struct ll_file_data *fd; struct mds_body *body; ENTRY; @@ -170,6 +169,7 @@ 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(mdc_exp, &fd->fd_mds_och, it->d.lustre.it_data); + mdc_set_open_replay_data(lmv_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_osc_exp, lli->lli_smd, LDLM_EXTENT, &policy, + rc = obd_enqueue(sbi->ll_lov_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,10 +694,9 @@ 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: %llu, blocks: %lu\n", - inode->i_size, inode->i_blocks); - obd_cancel(sbi->ll_osc_exp, lli->lli_smd, LCK_PR, &lockh); - + 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); RETURN(rc); } @@ -733,8 +732,7 @@ 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_osc_exp, lsm, LDLM_EXTENT, policy, mode, + rc = obd_enqueue(sbi->ll_lov_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); @@ -775,7 +773,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_osc_exp, lsm, mode, lockh); + rc = obd_cancel(sbi->ll_lov_exp, lsm, mode, lockh); RETURN(rc); } @@ -813,7 +811,6 @@ 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); @@ -844,8 +841,11 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count, RETURN(retval); } -static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, - loff_t *ppos) +/* + * 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) { 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_i2mdcexp(inode), req, 1, exp, &md); + rc = mdc_req2lustre_md(ll_i2lmvexp(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 ll_fid fid; + struct lustre_id id; 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_inode2fid(&fid, inode); - err = md_sync(ll_i2sbi(inode)->ll_mdc_exp, &fid, &req); + ll_inode2id(&id, inode); + err = md_sync(ll_i2sbi(inode)->ll_lmv_exp, &id, &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_osc_exp, oa, lsm, + err = obd_sync(ll_i2sbi(inode)->ll_lov_exp, oa, lsm, 0, OBD_OBJECT_EOF); if (!rc) rc = err; @@ -1322,10 +1322,11 @@ 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 = {inode->i_ino, inode->i_generation, LDLM_FLOCK} }; + { .name = {id_fid(&li->lli_id), id_group(&li->lli_id), LDLM_FLOCK} }; struct lustre_handle lockh = {0}; ldlm_policy_data_t flock; ldlm_mode_t mode = 0; @@ -1394,7 +1395,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_mdc_exp, NULL, 0); + obddev = md_get_real_obd(sbi->ll_lmv_exp, NULL, 0); rc = ldlm_cli_enqueue(obddev->obd_self_export, NULL, obddev->obd_namespace, res_id, LDLM_FLOCK, &flock, mode, &flags, @@ -1408,10 +1409,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; @@ -1420,17 +1421,21 @@ 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 - ll_inode2fid(&cfid, dentry->d_inode); - rc = md_intent_lock(sbi->ll_mdc_exp, &cfid, - NULL, 0, NULL, 0, &cfid, &oit, 0, &req, + rc = md_intent_lock(sbi->ll_lmv_exp, &id, + NULL, 0, NULL, 0, &id, &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 ce92461..5e0c95b 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -35,14 +35,17 @@ struct ll_ra_info { }; struct ll_sb_info { - /* this protects pglist and ra_info. It isn't safe to - * grab from interrupt contexts */ + /* this protects pglist and max_r_a_pages. It isn't safe to grab from + * interrupt contexts. */ spinlock_t ll_lock; + struct obd_uuid ll_sb_uuid; - 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 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 lustre_mount_data *ll_lmd; char *ll_instance; @@ -53,7 +56,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; @@ -153,7 +156,8 @@ struct ll_async_page { /* llite/lproc_llite.c */ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, - struct super_block *sb, char *osc, char *mdc); + struct super_block *sb, char *lov, + char *lmv); void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi); /* llite/dir.c */ @@ -202,7 +206,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 *mdc_exp, struct inode *inode, +int ll_mdc_close(struct obd_export *lmv_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, @@ -351,18 +355,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_osc_exp; + return ll_s2sbi(sb)->ll_lov_exp; } /* don't need an addref as the sb_info should be holding one */ -static inline struct obd_export *ll_s2mdcexp(struct super_block *sb) +static inline struct obd_export *ll_s2lmvexp(struct super_block *sb) { - return ll_s2sbi(sb)->ll_mdc_exp; + return ll_s2sbi(sb)->ll_lmv_exp; } -static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi) +static inline struct client_obd *sbi2lmv(struct ll_sb_info *sbi) { - struct obd_device *obd = sbi->ll_mdc_exp->exp_obd; + struct obd_device *obd = sbi->ll_lmv_exp->exp_obd; if (obd == NULL) LBUG(); return &obd->u.cli; @@ -379,14 +383,14 @@ static inline struct obd_export *ll_i2obdexp(struct inode *inode) return ll_s2obdexp(inode->i_sb); } -static inline struct obd_export *ll_i2mdcexp(struct inode *inode) +static inline struct obd_export *ll_i2lmvexp(struct inode *inode) { - return ll_s2mdcexp(inode->i_sb); + return ll_s2lmvexp(inode->i_sb); } static inline int ll_mds_max_easize(struct super_block *sb) { - return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize; + return sbi2lmv(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 4ab2c4a..bd2774c 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -92,130 +92,148 @@ void lustre_free_sbi(struct super_block *sb) EXIT; } -int lustre_init_ea_size(struct ll_sb_info *sbi) +int lustre_init_lov_desc(struct ll_sb_info *sbi) { - struct lov_desc desc; - int rc, valsize; + int valsize, rc; + ENTRY; - /* 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)); + 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); +} +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 *mdc, char *osc) +int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov) { - 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(mdc); + obd = class_name2obd(lmv); if (!obd) { - CERROR("MDC %s: not setup or attached\n", mdc); + CERROR("MDC %s: not setup or attached\n", lmv); RETURN(-EINVAL); } if (proc_lustre_fs_root) { err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb, - osc, mdc); + lov, lmv); if (err < 0) CERROR("could not register mount in /proc/lustre"); } - err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, 0); + err = obd_connect(&lmv_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", mdc); + "complete, abort, or time out.\n", lmv); GOTO(out, err); } else if (err) { - CERROR("cannot connect to %s: rc = %d\n", mdc, err); + CERROR("cannot connect to %s: rc = %d\n", lmv, err); GOTO(out, err); } - sbi->ll_mdc_exp = class_conn2export(&mdc_conn); + sbi->ll_lmv_exp = class_conn2export(&lmv_conn); + lustre_init_lmv_desc(sbi); + err = obd_statfs(obd, &osfs, jiffies - HZ); if (err) - GOTO(out_mdc, err); + GOTO(out_lmv, err); - LASSERT(osfs.os_bsize); + if (!osfs.os_bsize) { + CERROR("Invalid block size is detected."); + GOTO(out_lmv, err); + } + + sb->s_magic = LL_SUPER_MAGIC; 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_mdc_exp->exp_obd->obd_uuid.uuid, - strlen(sbi->ll_mdc_exp->exp_obd->obd_uuid.uuid)); + devno = get_uuid2int(sbi->ll_lmv_exp->exp_obd->obd_uuid.uuid, + strlen(sbi->ll_lmv_exp->exp_obd->obd_uuid.uuid)); sb->s_dev = devno; - obd = class_name2obd(osc); + obd = class_name2obd(lov); if (!obd) { - CERROR("OSC %s: not setup or attached\n", osc); - GOTO(out_mdc, err); + CERROR("OSC %s: not setup or attached\n", lov); + GOTO(out_lmv, err); } - err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, 0); + err = obd_connect(&lov_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", osc); + "complete, abort, or time out.\n", lov); GOTO(out, err); } else if (err) { - CERROR("cannot connect to %s: rc = %d\n", osc, err); - GOTO(out_mdc, err); + CERROR("cannot connect to %s: rc = %d\n", lov, err); + GOTO(out_lmv, err); } - sbi->ll_osc_exp = class_conn2export(&osc_conn); - - lustre_init_ea_size(sbi); - err = md_getstatus(sbi->ll_mdc_exp, &rootfid); + 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)); + } + + err = md_getstatus(sbi->ll_lmv_exp, &sbi->ll_rootid); if (err) { CERROR("cannot mds_connect: rc = %d\n", err); - GOTO(out_osc, err); + GOTO(out_lov, err); } - CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id); - sbi->ll_rootino = rootfid.id; + CDEBUG(D_SUPER, "rootid "DLID4"\n", OLID4(&sbi->ll_rootid)); sb->s_op = &lustre_super_operations; /* make root inode * XXX: move this to after cbd setup? */ - err = md_getattr(sbi->ll_mdc_exp, &rootfid, - OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS, 0, &request); + err = md_getattr(sbi->ll_lmv_exp, &sbi->ll_rootid, + OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS | OBD_MD_FID, + 0, &request); if (err) { CERROR("md_getattr failed for root: rc = %d\n", err); - GOTO(out_osc, err); + GOTO(out_lov, err); } - err = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0, - sbi->ll_osc_exp, &md); + err = mdc_req2lustre_md(sbi->ll_lmv_exp, request, 0, + sbi->ll_lov_exp, &md); if (err) { - CERROR("failed to understand root inode md: rc = %d\n",err); - ptlrpc_req_finished (request); - GOTO(out_osc, err); + CERROR("failed to understand root inode md: rc = %d\n", err); + ptlrpc_req_finished(request); + GOTO(out_lov, err); } - LASSERT(sbi->ll_rootino != 0); - root = ll_iget(sb, sbi->ll_rootino, &md); + 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); 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); } @@ -228,9 +246,9 @@ int lustre_common_fill_super(struct super_block *sb, char *mdc, char *osc) 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; @@ -248,10 +266,10 @@ int lustre_common_fill_super(struct super_block *sb, char *mdc, char *osc) out_root: if (root) iput(root); -out_osc: - obd_disconnect(sbi->ll_osc_exp, 0); -out_mdc: - obd_disconnect(sbi->ll_mdc_exp, 0); +out_lov: + obd_disconnect(sbi->ll_lov_exp, 0); +out_lmv: + obd_disconnect(sbi->ll_lmv_exp, 0); out: lprocfs_unregister_mountpoint(sbi); RETURN(err); @@ -264,11 +282,10 @@ 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_osc_exp, 0); + obd_disconnect(sbi->ll_lov_exp, 0); lprocfs_unregister_mountpoint(sbi); if (sbi->ll_proc_root) { @@ -276,7 +293,7 @@ void lustre_common_put_super(struct super_block *sb) sbi->ll_proc_root = NULL; } - obd_disconnect(sbi->ll_mdc_exp, 0); + obd_disconnect(sbi->ll_lmv_exp, 0); // We do this to get rid of orphaned dentries. That is not really trw. spin_lock(&dcache_lock); @@ -290,7 +307,6 @@ void lustre_common_put_super(struct super_block *sb) EXIT; } - char *ll_read_opt(const char *opt, char *data) { char *value; @@ -326,7 +342,7 @@ int ll_set_opt(const char *opt, char *data, int fl) RETURN(fl); } -void ll_options(char *options, char **ost, char **mdc, int *flags) +void ll_options(char *options, char **lov, char **lmv, int *flags) { char *this_char; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) @@ -347,9 +363,9 @@ void ll_options(char *options, char **ost, char **mdc, int *flags) while ((this_char = strsep (&opt_ptr, ",")) != NULL) { #endif CDEBUG(D_SUPER, "this_char %s\n", this_char); - if (!*ost && (*ost = ll_read_opt("osc", this_char))) + if (!*lov && (*lov = ll_read_opt("osc", this_char))) continue; - if (!*mdc && (*mdc = ll_read_opt("mdc", this_char))) + if (!*lmv && (*lmv = ll_read_opt("mdc", this_char))) continue; if (!(*flags & LL_SBI_NOLCK) && ((*flags) = (*flags) | @@ -369,13 +385,14 @@ 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 *osc = NULL; - char *mdc = NULL; + char *lov = NULL; + char *lmv = NULL; int err; ENTRY; @@ -386,28 +403,27 @@ int ll_fill_super(struct super_block *sb, void *data, int silent) RETURN(-ENOMEM); sbi->ll_flags |= LL_SBI_READAHEAD; - ll_options(data, &osc, &mdc, &sbi->ll_flags); + ll_options(data, &lov, &lmv, &sbi->ll_flags); - if (!osc) { + if (!lov) { CERROR("no osc\n"); GOTO(out, err = -EINVAL); } - if (!mdc) { + if (!lmv) { CERROR("no mdc\n"); GOTO(out, err = -EINVAL); } - err = lustre_common_fill_super(sb, mdc, osc); + err = lustre_common_fill_super(sb, lmv, lov); out: if (err) lustre_free_sbi(sb); - if (mdc) - OBD_FREE(mdc, strlen(mdc) + 1); - if (osc) - OBD_FREE(osc, strlen(osc) + 1); - + if (lmv) + OBD_FREE(lmv, strlen(lmv) + 1); + if (lov) + OBD_FREE(lov, strlen(lov) + 1); RETURN(err); } /* ll_read_super */ @@ -416,13 +432,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 mdc_conn = {0, }; + struct lustre_handle lmv_conn = {0, }; struct obd_export *exp; - char * name = "mdc_dev"; + char *name = "mdc_dev"; class_uuid_t uuid; - struct obd_uuid mdc_uuid; + struct obd_uuid lmv_uuid; struct llog_ctxt *ctxt; int rc = 0; int err; @@ -432,7 +448,7 @@ static int lustre_process_log(struct lustre_mount_data *lmd, char *profile, RETURN(-EINVAL); generate_random_uuid(uuid); - class_uuid_unparse(uuid, &mdc_uuid); + class_uuid_unparse(uuid, &lmv_uuid); if (lmd->lmd_local_nid) { PCFG_INIT(pcfg, NAL_CMD_REGISTER_MYNID); @@ -469,7 +485,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 = mdc_uuid.uuid; + lcfg.lcfg_inlbuf2 = lmv_uuid.uuid; lcfg.lcfg_inllen2 = strlen(lcfg.lcfg_inlbuf2) + 1; err = class_process_config(&lcfg); if (err < 0) @@ -495,13 +511,13 @@ static int lustre_process_log(struct lustre_mount_data *lmd, char *profile, if (err) GOTO(out_cleanup, err); - err = obd_connect(&mdc_conn, obd, &mdc_uuid, 0); + err = obd_connect(&lmv_conn, obd, &lmv_uuid, 0); if (err) { CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err); GOTO(out_cleanup, err); } - exp = class_conn2export(&mdc_conn); + exp = class_conn2export(&lmv_conn); ctxt = llog_get_context(&exp->exp_obd->obd_llogs,LLOG_CONFIG_REPL_CTXT); rc = class_config_process_llog(ctxt, profile, cfg); @@ -549,9 +565,8 @@ 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; @@ -602,39 +617,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 (osc) - OBD_FREE(osc, strlen(osc) + 1); - OBD_ALLOC(osc, strlen(lprof->lp_osc) + + if (lov) + OBD_FREE(lov, strlen(lov) + 1); + OBD_ALLOC(lov, strlen(lprof->lp_lov) + strlen(sbi->ll_instance) + 2); - sprintf(osc, "%s-%s", lprof->lp_osc, sbi->ll_instance); + sprintf(lov, "%s-%s", lprof->lp_lov, sbi->ll_instance); - if (mdc) - OBD_FREE(mdc, strlen(mdc) + 1); - OBD_ALLOC(mdc, strlen(lprof->lp_mdc) + + if (lmv) + OBD_FREE(lmv, strlen(lmv) + 1); + OBD_ALLOC(lmv, strlen(lprof->lp_lmv) + strlen(sbi->ll_instance) + 2); - sprintf(mdc, "%s-%s", lprof->lp_mdc, sbi->ll_instance); + sprintf(lmv, "%s-%s", lprof->lp_lmv, sbi->ll_instance); } - if (!osc) { + if (!lov) { CERROR("no osc\n"); GOTO(out_free, err = -EINVAL); } - if (!mdc) { + if (!lmv) { CERROR("no mdc\n"); GOTO(out_free, err = -EINVAL); } - err = lustre_common_fill_super(sb, mdc, osc); + err = lustre_common_fill_super(sb, lmv, lov); if (err) GOTO(out_free, err); out_dev: - if (mdc) - OBD_FREE(mdc, strlen(mdc) + 1); - if (osc) - OBD_FREE(osc, strlen(osc) + 1); + if (lmv) + OBD_FREE(lmv, strlen(lmv) + 1); + if (lov) + OBD_FREE(lov, strlen(lov) + 1); RETURN(err); @@ -704,7 +719,7 @@ void lustre_put_super(struct super_block *sb) ENTRY; CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb); - obd = class_exp2obd(sbi->ll_mdc_exp); + obd = class_exp2obd(sbi->ll_lmv_exp); if (obd) force_umount = obd->obd_no_recov; obd = NULL; @@ -748,7 +763,7 @@ void lustre_put_super(struct super_block *sb) int ll_process_config_update(struct ll_sb_info *sbi, int clean) { - struct obd_export *mdc_exp = sbi->ll_mdc_exp; + struct obd_export *lmv_exp = sbi->ll_lmv_exp; struct lustre_mount_data *lmd = sbi->ll_lmd; struct llog_ctxt *ctxt; struct config_llog_instance cfg; @@ -764,12 +779,12 @@ int ll_process_config_update(struct ll_sb_info *sbi, int clean) RETURN(0); } - rc = ldlm_cli_cancel_unused(mdc_exp->exp_obd->obd_namespace, NULL, + rc = ldlm_cli_cancel_unused(lmv_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_osc_exp, NULL, LDLM_FL_CONFIG_CHANGE, + rc = obd_cancel_unused(sbi->ll_lov_exp, NULL, LDLM_FL_CONFIG_CHANGE, NULL); if (rc != 0) CWARN("obd_cancel_unused(lov): %d\n", rc); @@ -793,7 +808,7 @@ int ll_process_config_update(struct ll_sb_info *sbi, int clean) CWARN("Applying configuration log %s\n", name); - ctxt = llog_get_context(&mdc_exp->exp_obd->obd_llogs, + ctxt = llog_get_context(&lmv_exp->exp_obd->obd_llogs, LLOG_CONFIG_REPL_CTXT); rc = class_config_process_llog(ctxt, name, &cfg); if (rc == 0) @@ -804,11 +819,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_osc_exp, strlen("lovdesc") + 1, + rc = obd_get_info(sbi->ll_lov_exp, strlen("lovdesc") + 1, "lovdesc", &valsize, &desc); - rc = obd_init_ea_size(mdc_exp, - obd_size_diskmd(sbi->ll_osc_exp, NULL), + rc = obd_init_ea_size(lmv_exp, + obd_size_diskmd(sbi->ll_lov_exp, NULL), (desc.ld_tgt_count * sizeof(struct llog_cookie))); } @@ -847,7 +862,7 @@ int null_if_equal(struct ldlm_lock *lock, void *data) void ll_clear_inode(struct inode *inode) { - struct ll_fid fid; + struct lustre_id id; struct ll_inode_info *lli = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); ENTRY; @@ -856,22 +871,22 @@ void ll_clear_inode(struct inode *inode) inode->i_generation, inode); lli->lli_inode_magic = LLI_INODE_DEAD; - ll_inode2fid(&fid, inode); + ll_inode2id(&id, inode); + clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags)); - md_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode); + md_change_cbdata(sbi->ll_lmv_exp, &id, null_if_equal, inode); if (lli->lli_smd) - obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd, + obd_change_cbdata(sbi->ll_lov_exp, lli->lli_smd, null_if_equal, inode); if (lli->lli_smd) { - obd_free_memmd(sbi->ll_osc_exp, &lli->lli_smd); + obd_free_memmd(sbi->ll_lov_exp, &lli->lli_smd); lli->lli_smd = NULL; } if (lli->lli_mea) { - /* FIXME: change cbdata for mea here */ - obd_free_memmd(sbi->ll_mdc_exp, + obd_free_memmd(sbi->ll_lmv_exp, (struct lov_stripe_md **) &lli->lli_mea); lli->lli_mea = NULL; } @@ -953,9 +968,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_op_data(&op_data, inode, NULL, NULL, 0, 0); + ll_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0); - rc = md_setattr(sbi->ll_mdc_exp, &op_data, + rc = md_setattr(sbi->ll_lmv_exp, &op_data, attr, NULL, 0, NULL, 0, &request); if (rc) { ptlrpc_req_finished(request); @@ -964,8 +979,8 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) RETURN(rc); } - rc = mdc_req2lustre_md(sbi->ll_mdc_exp, request, 0, - sbi->ll_osc_exp, &md); + rc = mdc_req2lustre_md(sbi->ll_lmv_exp, request, 0, + sbi->ll_lov_exp, &md); if (rc) { ptlrpc_req_finished(request); RETURN(rc); @@ -1054,7 +1069,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_osc_exp, &oa, lsm, NULL); + rc = obd_setattr(sbi->ll_lov_exp, &oa, lsm, NULL); if (rc) CERROR("obd_setattr fails: rc=%d\n", rc); } @@ -1075,7 +1090,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, int rc; ENTRY; - rc = obd_statfs(class_exp2obd(sbi->ll_mdc_exp), osfs, max_age); + rc = obd_statfs(class_exp2obd(sbi->ll_lmv_exp), osfs, max_age); if (rc) { CERROR("mdc_statfs fails: rc = %d\n", rc); RETURN(rc); @@ -1086,7 +1101,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_osc_exp), &obd_osfs, max_age); + rc = obd_statfs(class_exp2obd(sbi->ll_lov_exp), &obd_osfs, max_age); if (rc) { CERROR("obd_statfs fails: rc = %d\n", rc); RETURN(rc); @@ -1149,9 +1164,10 @@ 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 mds_body *body = md->body; struct lov_stripe_md *lsm = md->lsm; + struct mds_body *body = md->body; struct mea *mea = md->mea; ENTRY; @@ -1206,13 +1222,26 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) } } if (lli->lli_mea != mea) - obd_free_memmd(ll_i2mdcexp(inode), - (struct lov_stripe_md **) &mea); - + obd_free_memmd(ll_i2lmvexp(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 = body->ino; + inode->i_ino = id_ino(&body->id1); + if (body->valid & OBD_MD_FLGENER) + inode->i_generation = id_gen(&body->id1); if (body->valid & OBD_MD_FLATIME) LTIME_S(inode->i_atime) = body->atime; if (body->valid & OBD_MD_FLMTIME && @@ -1224,10 +1253,14 @@ 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) @@ -1236,8 +1269,6 @@ 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; @@ -1251,12 +1282,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) body->mds; + inode->i_dev = (kdev_t)id_group(&lli->lli_id); #endif - LASSERT(body->mds < 1000); + LASSERT(!sbi->ll_lmv_desc.ld_tgt_count || + id_group(&lli->lli_id) < sbi->ll_lmv_desc.ld_tgt_count); } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) @@ -1342,13 +1373,13 @@ void ll_read_inode2(struct inode *inode, void *opaque) void ll_delete_inode(struct inode *inode) { int rc; - struct ll_fid fid; + struct lustre_id id; struct ll_sb_info *sbi = ll_i2sbi(inode); ENTRY; - ll_inode2fid(&fid, inode); + ll_inode2id(&id, inode); - rc = md_delete_object(sbi->ll_mdc_exp, &fid); + rc = md_delete_object(sbi->ll_lmv_exp, &id); if (rc) { CERROR("md_delete_object() failed, error %d.\n", rc); @@ -1368,12 +1399,12 @@ int ll_iocontrol(struct inode *inode, struct file *file, switch(cmd) { case EXT3_IOC_GETFLAGS: { - struct ll_fid fid; + struct lustre_id id; unsigned long valid = OBD_MD_FLFLAGS; struct mds_body *body; - ll_inode2fid(&fid, inode); - rc = md_getattr(sbi->ll_mdc_exp, &fid, valid, 0, &req); + ll_inode2id(&id, inode); + rc = md_getattr(sbi->ll_lmv_exp, &id, valid, 0, &req); if (rc) { CERROR("failure %d inode %lu\n", rc, inode->i_ino); RETURN(-abs(rc)); @@ -1405,13 +1436,13 @@ int ll_iocontrol(struct inode *inode, struct file *file, if (!oa) RETURN(-ENOMEM); - ll_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0); + ll_prepare_mdc_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_mdc_exp, &op_data, + rc = md_setattr(sbi->ll_lmv_exp, &op_data, &attr, NULL, 0, NULL, 0, &req); if (rc) { ptlrpc_req_finished(req); @@ -1427,7 +1458,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_osc_exp, oa, lsm, NULL); + rc = obd_setattr(sbi->ll_lov_exp, oa, lsm, NULL); obdo_free(oa); if (rc) { if (rc != -EPERM && rc != -EACCES) @@ -1457,6 +1488,7 @@ 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); @@ -1467,30 +1499,31 @@ 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_mdc_exp); + obd = class_exp2obd(sbi->ll_lmv_exp); if (obd == NULL) { CERROR("Invalid MDC connection handle "LPX64"\n", - sbi->ll_mdc_exp->exp_handle.h_cookie); + sbi->ll_lmv_exp->exp_handle.h_cookie); EXIT; return; } obd->obd_no_recov = 1; - obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_mdc_exp, sizeof ioc_data, - &ioc_data, NULL); + obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_lmv_exp, + sizeof(ioc_data), &ioc_data, NULL); - obd = class_exp2obd(sbi->ll_osc_exp); + obd = class_exp2obd(sbi->ll_lov_exp); if (obd == NULL) { CERROR("Invalid LOV connection handle "LPX64"\n", - sbi->ll_osc_exp->exp_handle.h_cookie); + sbi->ll_lov_exp->exp_handle.h_cookie); EXIT; return; } obd->obd_no_recov = 1; - obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_osc_exp, sizeof ioc_data, - &ioc_data, NULL); + obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_lov_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. */ @@ -1499,14 +1532,14 @@ void ll_umount_begin(struct super_block *sb) EXIT; } -int ll_prep_inode(struct obd_export *osc_exp, struct obd_export *mdc_exp, +int ll_prep_inode(struct obd_export *lov_exp, struct obd_export *lmv_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(mdc_exp, req, offset, osc_exp, &md); + rc = mdc_req2lustre_md(lmv_exp, req, offset, lov_exp, &md); if (rc) RETURN(rc); @@ -1514,13 +1547,13 @@ int ll_prep_inode(struct obd_export *osc_exp, struct obd_export *mdc_exp, ll_update_inode(*inode, &md); } else { LASSERT(sb); - *inode = ll_iget(sb, md.body->ino, &md); + *inode = ll_iget(sb, id_ino(&md.body->id1), &md); if (*inode == NULL || is_bad_inode(*inode)) { /* free the lsm if we allocated one above */ if (md.lsm != NULL) - obd_free_memmd(osc_exp, &md.lsm); + obd_free_memmd(lov_exp, &md.lsm); if (md.mea != NULL) - obd_free_memmd(mdc_exp, + obd_free_memmd(lmv_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 7615751..d052b2d 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 ll_fid fid; + struct lustre_id id; 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_osc_exp, NULL); + eadatalen = obd_size_diskmd(sbi->ll_lov_exp, NULL); valid |= OBD_MD_FLEASIZE; } - fid.id = (__u64)ino; - fid.generation = generation; - fid.f_type = mode; + 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; - rc = md_getattr(sbi->ll_mdc_exp, &fid, valid, eadatalen, &req); + rc = md_getattr(sbi->ll_lmv_exp, &id, valid, eadatalen, &req); if (rc) { CERROR("failure %d inode %lu\n", rc, ino); return ERR_PTR(rc); } - rc = ll_prep_inode(sbi->ll_osc_exp, sbi->ll_mdc_exp, + rc = ll_prep_inode(sbi->ll_lov_exp, sbi->ll_lmv_exp, &inode, req, 0, sb); if (rc) { ptlrpc_req_finished(req); diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 6dd69d1..2c26a80 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -60,7 +60,8 @@ static int ll_test_inode(struct inode *inode, void *opaque) return 0; } - if (last_ino == md->body->ino && last_gen == md->body->generation && + if (last_ino == id_ino(&md->body->id1) && + last_gen == id_gen(&md->body->id1) && last_count < 500) { last_count++; } else { @@ -68,26 +69,25 @@ 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 = md->body->ino; - last_gen = md->body->generation; + last_ino = id_ino(&md->body->id1); + last_gen = id_gen(&md->body->id1); CDEBUG(D_VFSTRACE, - "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); + "comparing inode %p ino "DLID4" to body "DLID4"\n", + inode, OLID4(&ll_i2info(inode)->lli_id), + OLID4(&md->body->id1)); } #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) - if (inode->i_ino != md->body->ino) + if (inode->i_ino != id_ino(&md->body->id1)) return 0; #endif - if (inode->i_generation != md->body->generation) + if (inode->i_generation != id_gen(&md->body->id1)) return 0; - if (ll_i2info(inode)->lli_mds != md->body->mds) + if (id_group(&ll_i2info(inode)->lli_id) != id_group(&md->body->id1)) 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,8 +103,9 @@ 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) @@ -162,6 +163,7 @@ 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 @@ -174,10 +176,11 @@ 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] != 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 (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 lookup lock is cancelled, we just drop the dentry and @@ -211,8 +214,9 @@ 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 = {inode->i_ino, inode->i_generation} }; + { .name = {id_fid(&li->lli_id), id_group(&li->lli_id)} }; struct obd_device *obddev = class_conn2obd(conn); ENTRY; @@ -282,7 +286,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_osc_exp, sbi->ll_mdc_exp, + rc = ll_prep_inode(sbi->ll_lov_exp, sbi->ll_lmv_exp, &inode, request, offset, dentry->d_sb); if (rc) RETURN(rc); @@ -290,7 +294,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) { @@ -317,20 +321,18 @@ 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 ll_fid pfid; + struct lustre_id pid; struct it_cb_data icbd; struct ptlrpc_request *req = NULL; struct lookup_intent lookup_it = { .it_op = IT_LOOKUP }; @@ -354,9 +356,9 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, icbd.icbd_childp = &dentry; icbd.icbd_parent = parent; - ll_inode2fid(&pfid, parent); + ll_inode2id(&pid, parent); - rc = md_intent_lock(ll_i2mdcexp(parent), &pfid, + rc = md_intent_lock(ll_i2lmvexp(parent), &pid, dentry->d_name.name, dentry->d_name.len, NULL, 0, NULL, it, flags, &req, ll_mdc_blocking_ast); if (rc < 0) @@ -385,18 +387,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; } @@ -431,7 +433,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_osc_exp, sbi->ll_mdc_exp, + rc = ll_prep_inode(sbi->ll_lov_exp, sbi->ll_lmv_exp, &inode, request, 1, dir->i_sb); if (rc) GOTO(out, inode = ERR_PTR(rc)); @@ -469,7 +471,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 *mdc_exp = ll_i2mdcexp(dir); + struct obd_export *lmv_exp = ll_i2lmvexp(dir); int rc = 0; ENTRY; @@ -481,12 +483,11 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode, if (rc) RETURN(rc); - mdc_store_inode_generation(mdc_exp, request, MDS_REQ_INTENT_REC_OFF, 1); + mdc_store_inode_generation(lmv_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); @@ -544,8 +545,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_op_data(&op_data, dir, NULL, name, len, 0); - err = md_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode, + ll_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); + err = md_create(sbi->ll_lmv_exp, &op_data, NULL, 0, mode, current->fsuid, current->fsgid, rdev, &request); if (err == 0) ll_update_times(request, 0, dir); @@ -588,15 +589,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_op_data(&op_data, dir, NULL, name, len, 0); - err = md_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode, + ll_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); + err = md_create(sbi->ll_lmv_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_osc_exp, sbi->ll_mdc_exp, + err = ll_prep_inode(sbi->ll_lov_exp, sbi->ll_lmv_exp, &inode, request, 0, child->d_sb); if (err) GOTO(out_err, err); @@ -631,8 +632,8 @@ static int ll_symlink_raw(struct nameidata *nd, const char *tgt) if (dir->i_nlink >= EXT3_LINK_MAX) RETURN(err); - ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); - err = md_create(sbi->ll_mdc_exp, &op_data, + ll_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); + err = md_create(sbi->ll_lmv_exp, &op_data, tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO, current->fsuid, current->fsgid, 0, &request); if (err == 0) @@ -658,8 +659,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_op_data(&op_data, src, dir, name, len, 0); - err = md_link(sbi->ll_mdc_exp, &op_data, &request); + ll_prepare_mdc_data(&op_data, src, dir, name, len, 0); + err = md_link(sbi->ll_lmv_exp, &op_data, &request); if (err == 0) ll_update_times(request, 0, dir); ptlrpc_req_finished(request); @@ -681,8 +682,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_op_data(&op_data, dir, NULL, name, len, 0); - err = md_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode, + ll_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); + err = md_create(sbi->ll_lmv_exp, &op_data, NULL, 0, mode, current->fsuid, current->fsgid, 0, &request); if (err == 0) ll_update_times(request, 0, dir); @@ -702,8 +703,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_op_data(&op_data, dir, NULL, name, len, S_IFDIR); - rc = md_unlink(ll_i2sbi(dir)->ll_mdc_exp, &op_data, &request); + ll_prepare_mdc_data(&op_data, dir, NULL, name, len, S_IFDIR); + rc = md_unlink(ll_i2sbi(dir)->ll_lmv_exp, &op_data, &request); if (rc == 0) ll_update_times(request, 0, dir); ptlrpc_req_finished(request); @@ -802,8 +803,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_op_data(&op_data, dir, NULL, name, len, 0); - rc = md_unlink(ll_i2sbi(dir)->ll_mdc_exp, &op_data, &request); + ll_prepare_mdc_data(&op_data, dir, NULL, name, len, 0); + rc = md_unlink(ll_i2sbi(dir)->ll_lmv_exp, &op_data, &request); if (rc) GOTO(out, rc); ll_update_times(request, 0, dir); @@ -831,8 +832,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_op_data(&op_data, src, tgt, NULL, 0, 0); - err = md_rename(sbi->ll_mdc_exp, &op_data, + ll_prepare_mdc_data(&op_data, src, tgt, NULL, 0, 0); + err = md_rename(sbi->ll_lmv_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 abda07f..9a90d50 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -314,10 +314,11 @@ 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_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; + 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)); + oa->o_easize = ll_i2info(inode)->lli_io_epoch; valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME; } @@ -700,7 +701,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_osc_exp, + matches = obd_match(ll_i2sbi(inode)->ll_lov_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 c932752..cd3a552 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_mdc_exp, inode, filp); + err = ll_mdc_close(sbi->ll_lmv_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_mdc_exp, inode, filp); + ll_mdc_close(ll_i2sbi(inode)->ll_lmv_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 5f4a74c..9364ec8 100644 --- a/lustre/llite/symlink.c +++ b/lustre/llite/symlink.c @@ -30,11 +30,12 @@ #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 ll_fid fid; + struct lustre_id id; struct mds_body *body; int rc, symlen = inode->i_size + 1; ENTRY; @@ -47,8 +48,8 @@ static int ll_readlink_internal(struct inode *inode, RETURN(0); } - ll_inode2fid(&fid, inode); - rc = md_getattr(sbi->ll_mdc_exp, &fid, OBD_MD_LINKNAME, symlen, + ll_inode2id(&id, inode); + rc = md_getattr(sbi->ll_lmv_exp, &id, 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 baea244..c1cb22a 100644 --- a/lustre/lmv/lmv_intent.c +++ b/lustre/lmv/lmv_intent.c @@ -56,10 +56,9 @@ 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; @@ -72,16 +71,20 @@ int lmv_handle_remote_inode(struct obd_export *exp, 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; } @@ -89,23 +92,25 @@ int lmv_handle_remote_inode(struct obd_export *exp, 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; } - nfid = body->fid1; + nid = body->id1; it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE; - rc = md_intent_lock(lmv->tgts[nfid.mds].ltd_exp, &nfid, + rc = md_intent_lock(lmv->tgts[id_group(&nid)].ltd_exp, &nid, 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) @@ -117,48 +122,48 @@ int lmv_handle_remote_inode(struct obd_export *exp, RETURN(rc); } -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, +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, 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 ll_fid rpfid = *pfid; + struct lustre_id rpid = *pid; 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 - * (pfid) may be splitted dir */ + * (pid) may be splitted dir */ repeat: LASSERT(++loop <= 2); - mds = rpfid.mds; - obj = lmv_grab_obj(obd, &rpfid); + mds = id_group(&rpid); + obj = lmv_grab_obj(obd, &rpid); 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 (%lu/%lu/%lu)\n", mds, - (unsigned long) rpfid.mds, (unsigned long) rpfid.id, - (unsigned long) rpfid.generation); - rpfid = obj->objs[mds].fid; + 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; lmv_put_obj(obj); } - rc = md_intent_lock(lmv->tgts[rpfid.mds].ltd_exp, &rpfid, name, - len, lmm, lmmsize, cfid, it, flags, reqp, + rc = md_intent_lock(lmv->tgts[id_group(&rpid)].ltd_exp, &rpid, name, + len, lmm, lmmsize, cid, it, flags, reqp, cb_blocking); if (rc == -ERESTART) { - /* 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); + /* 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); if (rc == 0) { ptlrpc_req_finished(*reqp); goto repeat; @@ -173,14 +178,8 @@ repeat: flags, reqp, cb_blocking); if (rc != 0) { LASSERT(rc < 0); - 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, + CERROR("can't handle remote %s: dir "DLID4"("DLID4"):" + "%*s: %d\n", LL_IT2STR(it), OLID4(pid), OLID4(&rpid), len, name, rc); RETURN(rc); } @@ -190,27 +189,25 @@ repeat: body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body)); LASSERT(body != NULL); - cfid = &body->fid1; - obj = lmv_grab_obj(obd, cfid); - if (!obj && (mea = body_of_splitted_dir(*reqp, 1))) { + cid = &body->id1; + obj = lmv_grab_obj(obd, cid); + if (!obj && (mea = lmv_splitted_dir_body(*reqp, 1))) { /* wow! this is splitted dir, we'd like to handle it */ - obj = lmv_create_obj(exp, &body->fid1, mea); + obj = lmv_create_obj(exp, &body->id1, 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 %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); + CDEBUG(D_OTHER, "attrs from slaves for "DLID4"\n", + OLID4(cid)); + + rc = lmv_revalidate_slaves(exp, reqp, cid, it, 1, + cb_blocking); } else if (S_ISDIR(body->mode)) { - /*CWARN("hmmm, %lu/%lu/%lu has not lmv obj?!\n", - (unsigned long) cfid->mds, - (unsigned long) cfid->id, - (unsigned long) cfid->generation);*/ + CDEBUG(D_OTHER, "object "DLID4" has not lmv obj?\n", + OLID4(cid)); } if (obj) @@ -219,59 +216,55 @@ repeat: RETURN(rc); } -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, +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, 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 ll_fid rpfid = *pfid; + struct lustre_id rpid = *pid; struct lmv_obj *obj, *obj2; struct mea *mea; int rc = 0, mds; ENTRY; - if (cfid) { + if (cid) { /* caller wants to revalidate attrs of obj we have to revalidate * slaves if requested object is splitted directory */ - 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); + CDEBUG(D_OTHER, "revalidate attrs for "DLID4"\n", OLID4(cid)); + mds = id_group(cid); + obj = lmv_grab_obj(obd, cid); if (obj) { /* in fact, we need not this with current intent_lock(), * but it may change some day */ - if (!fid_equal(pfid, cfid)){ - rpfid = obj->objs[mds].fid; - mds = rpfid.mds; + if (!lmv_id_equal(pid, cid)){ + rpid = obj->objs[mds].id; + mds = id_group(&rpid); } lmv_put_obj(obj); } } else { - 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); + CDEBUG(D_OTHER, "INTENT getattr for %*s on "DLID4"\n", + len, name, OLID4(pid)); + mds = id_group(pid); + obj = lmv_grab_obj(obd, pid); if (obj && len) { /* directory is already splitted. calculate mds */ - mds = raw_name2idx(obj->hashtype, obj->objcount, (char *) name, len); - rpfid = obj->objs[mds].fid; - mds = rpfid.mds; + mds = raw_name2idx(obj->hashtype, obj->objcount, + (char *) name, len); + rpid = obj->objs[mds].id; + mds = id_group(&rpid); lmv_put_obj(obj); - 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); + CDEBUG(D_OTHER, "forward to MDS #%u (slave "DLID4")\n", + mds, OLID4(&rpid)); } } - rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &rpfid, name, - len, lmm, lmmsize, cfid, it, flags, reqp, + rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &rpid, name, + len, lmm, lmmsize, cid, it, flags, reqp, cb_blocking); if (rc < 0) RETURN(rc); @@ -284,14 +277,13 @@ int lmv_intent_getattr(struct obd_export *exp, * 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 %lu/%lu/%lu, rc %d\n", - (unsigned long)cfid->mds, (unsigned long)cfid->id, - (unsigned long)cfid->generation, rc); + "revalidate slaves for "DLID4", rc %d\n", + OLID4(cid), rc); - LASSERT(cfid != 0); - rc = lmv_revalidate_slaves(exp, reqp, cfid, it, rc, + LASSERT(cid != 0); + rc = lmv_revalidate_slaves(exp, reqp, cid, it, rc, cb_blocking); - RETURN(rc); + RETURN(rc); } if (*reqp == NULL) @@ -307,26 +299,25 @@ int lmv_intent_getattr(struct obd_export *exp, body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body)); LASSERT(body != NULL); - cfid = &body->fid1; - obj2 = lmv_grab_obj(obd, cfid); + cid = &body->id1; + obj2 = lmv_grab_obj(obd, cid); - if (!obj2 && (mea = body_of_splitted_dir(*reqp, 1))) { + if (!obj2 && (mea = lmv_splitted_dir_body(*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->fid1, mea); + obj2 = lmv_create_obj(exp, &body->id1, 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 %lu/%lu/%lu, rc %d\n", - (unsigned long)cfid->mds, (unsigned long)cfid->id, - (unsigned long)cfid->generation, rc); + CDEBUG(D_OTHER, "attrs from slaves for "DLID4", rc %d\n", + OLID4(cid), rc); - rc = lmv_revalidate_slaves(exp, reqp, cfid, it, 1, cb_blocking); + rc = lmv_revalidate_slaves(exp, reqp, cid, it, 1, cb_blocking); lmv_put_obj(obj2); } RETURN(rc); @@ -336,10 +327,6 @@ 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) @@ -370,34 +357,30 @@ 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->fid1); + obj = lmv_grab_obj(obd, &body->id1); LASSERT(obj != NULL); - 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); + CDEBUG(D_OTHER, "lookup slaves for "DLID4"\n", + OLID4(&body->id1)); lmv_lock_obj(obj); for (i = 0; i < obj->objcount; i++) { - struct ll_fid fid = obj->objs[i].fid; + struct lustre_id id = obj->objs[i].id; struct ptlrpc_request *req = NULL; struct lookup_intent it; - if (fid_equal(&fid, &obj->fid)) + if (lmv_id_equal(&id, &obj->id)) /* skip master obj */ continue; - CDEBUG(D_OTHER, "lookup slave %lu/%lu/%lu\n", - (unsigned long)fid.mds, (unsigned long)fid.id, - (unsigned long)fid.generation); + CDEBUG(D_OTHER, "lookup slave "DLID4"\n", OLID4(&id)); /* is obj valid? */ memset(&it, 0, sizeof(it)); it.it_op = IT_GETATTR; - rc = md_intent_lock(lmv->tgts[fid.mds].ltd_exp, &fid, - NULL, 0, NULL, 0, &fid, &it, 0, &req, + rc = md_intent_lock(lmv->tgts[id_group(&id)].ltd_exp, &id, + NULL, 0, NULL, 0, &id, &it, 0, &req, lmv_dirobj_blocking_ast); lockh = (struct lustre_handle *)&it.d.lustre.it_lock_handle; @@ -441,86 +424,86 @@ cleanup: RETURN(rc); } -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, +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, 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 ll_fid rpfid = *pfid; + struct lustre_id rpid = *pid; struct lmv_obj *obj; struct mea *mea; int rc, mds, loop = 0; ENTRY; - /* IT_LOOKUP is intended to produce name -> fid resolving (let's call + /* + * IT_LOOKUP is intended to produce name -> id resolving (let's call * this lookup below) or to confirm requested resolving is still valid - * (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); + * (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); if (obj) { - mds = raw_name2idx(obj->hashtype, obj->objcount, - (char *) name, len); - rpfid = obj->objs[mds].fid; + mds = raw_name2idx(obj->hashtype, obj->objcount, + (char *)name, len); + rpid = obj->objs[mds].id; lmv_put_obj(obj); } - mds = rpfid.mds; + mds = id_group(&rpid); - 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); + CDEBUG(D_OTHER, "revalidate lookup for "DLID4" to %d MDS\n", + OLID4(cid), mds); } else { - mds = pfid->mds; + mds = id_group(pid); 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, pfid); + obj = lmv_grab_obj(obd, pid); if (obj) { if (len) { /* directory is already splitted. calculate mds */ mds = raw_name2idx(obj->hashtype, obj->objcount, (char *)name, len); - rpfid = obj->objs[mds].fid; - mds = rpfid.mds; + rpid = obj->objs[mds].id; + mds = id_group(&rpid); } lmv_put_obj(obj); } } - rc = md_intent_lock(lmv->tgts[mds].ltd_exp, pfid, name, - len, lmm, lmmsize, cfid, it, flags, reqp, + rc = md_intent_lock(lmv->tgts[mds].ltd_exp, pid, name, + len, lmm, lmmsize, cid, it, flags, reqp, cb_blocking); if (rc > 0) { - LASSERT(cfid != 0); + LASSERT(cid != 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 %lu/%lu/%lu and data should be uptodate\n", - (unsigned long)rpfid.mds, (unsigned long)rpfid.id, - (unsigned long)rpfid.generation); + CDEBUG(D_OTHER, "lookup for "DLID4" and data should be uptodate\n", + OLID4(&rpid)); LASSERT(*reqp == NULL); RETURN(rc); } if (rc == 0 && *reqp == NULL) { /* once again, we're asked for lookup, not revalidate */ - 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); + CDEBUG(D_OTHER, "lookup for "DLID4" and data should be uptodate\n", + OLID4(&rpid)); RETURN(rc); } @@ -531,7 +514,7 @@ repeat: CWARN("we haven't knew about directory splitting!\n"); LASSERT(obj == NULL); - obj = lmv_create_obj(exp, &rpfid, NULL); + obj = lmv_create_obj(exp, &rpid, NULL); if (IS_ERR(obj)) RETURN(PTR_ERR(obj)); lmv_put_obj(obj); @@ -546,14 +529,14 @@ repeat: rc = lmv_handle_remote_inode(exp, lmm, lmmsize, it, flags, reqp, cb_blocking); - if (rc == 0 && (mea = body_of_splitted_dir(*reqp, 1))) { + if (rc == 0 && (mea = lmv_splitted_dir_body(*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->fid1); + obj = lmv_grab_obj(obd, &body->id1); if (!obj) { - obj = lmv_create_obj(exp, &body->fid1, mea); + obj = lmv_create_obj(exp, &body->id1, mea); if (IS_ERR(obj)) RETURN(PTR_ERR(obj)); } @@ -563,11 +546,10 @@ repeat: RETURN(rc); } -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, +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, ldlm_blocking_callback cb_blocking) { struct obd_device *obd = exp->exp_obd; @@ -575,27 +557,27 @@ int lmv_intent_lock(struct obd_export *exp, ENTRY; LASSERT(it); - LASSERT(pfid); + LASSERT(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); + 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)); rc = lmv_check_connect(obd); if (rc) RETURN(rc); if (it->it_op == IT_LOOKUP) - rc = lmv_intent_lookup(exp, pfid, name, len, lmm, - lmmsize, cfid, it, flags, reqp, + rc = lmv_intent_lookup(exp, pid, name, len, lmm, + lmmsize, cid, it, flags, reqp, cb_blocking); else if (it->it_op & IT_OPEN) - rc = lmv_intent_open(exp, pfid, name, len, lmm, - lmmsize, cfid, it, flags, reqp, + rc = lmv_intent_open(exp, pid, name, len, lmm, + lmmsize, cid, it, flags, reqp, cb_blocking); else if (it->it_op == IT_GETATTR || it->it_op == IT_CHDIR) - rc = lmv_intent_getattr(exp, pfid, name, len, lmm, - lmmsize, cfid, it, flags, reqp, + rc = lmv_intent_getattr(exp, pid, name, len, lmm, + lmmsize, cid, it, flags, reqp, cb_blocking); else LBUG(); @@ -603,7 +585,7 @@ int lmv_intent_lock(struct obd_export *exp, } int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, - struct ll_fid *mfid, struct lookup_intent *oit, + struct lustre_id *mid, struct lookup_intent *oit, int master_valid, ldlm_blocking_callback cb_blocking) { struct obd_device *obd = exp->exp_obd; @@ -623,7 +605,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, mfid); + obj = lmv_grab_obj(obd, mid); LASSERT(obj != NULL); master_lock_mode = 0; @@ -631,22 +613,21 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, lmv_lock_obj(obj); for (i = 0; i < obj->objcount; i++) { - struct ll_fid fid = obj->objs[i].fid; + struct lustre_id id = obj->objs[i].id; 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 %lu/%lu/%lu\n", - (unsigned long)fid.mds, (unsigned long)fid.id, - (unsigned long) fid.generation); + CDEBUG(D_OTHER, "revalidate subobj "DLID4"\n", + OLID4(&id)); memset(&it, 0, sizeof(it)); it.it_op = IT_GETATTR; cb = lmv_dirobj_blocking_ast; - if (fid_equal(&fid, &obj->fid)) { + if (lmv_id_equal(&id, &obj->id)) { if (master_valid) { /* lmv_intent_getattr() already checked * validness and took the lock */ @@ -668,8 +649,9 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, } /* is obj valid? */ - rc = md_intent_lock(lmv->tgts[fid.mds].ltd_exp, &fid, - NULL, 0, NULL, 0, &fid, &it, 0, &req, cb); + rc = md_intent_lock(lmv->tgts[id_group(&id)].ltd_exp, + &id, NULL, 0, NULL, 0, &id, &it, 0, + &req, cb); lockh = (struct lustre_handle *) &it.d.lustre.it_lock_handle; if (rc > 0 && req == NULL) { /* nice, this slave is valid */ @@ -698,8 +680,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; @@ -741,7 +723,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 = obj->fid.mds; +// body->mds = id_group(&obj->id); } 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 ccceb95..dfd698a 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 ll_fid) + sizeof(struct mea)) + sizeof(struct lustre_id) + sizeof(struct mea)) struct lmv_inode { - struct ll_fid fid; /* fid of dirobj */ + struct lustre_id id; /* id 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 ll_fid fid; /* master fid of dir */ + struct lustre_id id; /* master id of dir */ void *update; /* bitmap of status (uptodate) */ __u32 hashtype; int objcount; /* number of slaves */ @@ -60,48 +60,47 @@ 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 ll_fid *fid); + struct lustre_id *id); struct lmv_obj *lmv_alloc_obj(struct obd_device *obd, - struct ll_fid *fid, + struct lustre_id *id, struct mea *mea); struct lmv_obj *lmv_create_obj(struct obd_export *exp, - struct ll_fid *fid, + struct lustre_id *id, struct mea *mea); -int lmv_delete_obj(struct obd_export *exp, struct ll_fid *fid); +int lmv_delete_obj(struct obd_export *exp, struct lustre_id *id); -int lmv_intent_lock(struct obd_export *, - struct ll_fid *, const char *, int, void *, int, - struct ll_fid *, struct lookup_intent *, int, +int lmv_intent_lock(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_lookup(struct obd_export *, - struct ll_fid *, const char *, int, void *, int, - struct ll_fid *, struct lookup_intent *, int, +int lmv_intent_lookup(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_getattr(struct obd_export *, - struct ll_fid *, const char *, int, void *, int, - struct ll_fid *, struct lookup_intent *, int, +int lmv_intent_getattr(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_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_revalidate_slaves(struct obd_export *, struct ptlrpc_request **, - struct ll_fid *, struct lookup_intent *, int, + struct lustre_id *, struct lookup_intent *, int, ldlm_blocking_callback cb_blocking); -int lmv_get_mea_and_update_object(struct obd_export *, struct ll_fid *); +int lmv_get_mea_and_update_object(struct obd_export *, struct lustre_id *); int lmv_dirobj_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *, void *, int); static inline struct mea * -body_of_splitted_dir(struct ptlrpc_request *req, int offset) +lmv_splitted_dir_body(struct ptlrpc_request *req, int offset) { struct mds_body *body; struct mea *mea; @@ -113,8 +112,8 @@ body_of_splitted_dir(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) @@ -123,15 +122,18 @@ body_of_splitted_dir(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 -fid_equal(struct ll_fid *fid1, struct ll_fid *fid2) +lmv_id_equal(struct lustre_id *id1, struct lustre_id *id2) { - if (fid1->mds != fid2->mds) - return 0; - if (fid1->id != fid2->id) + if (id1->li_fid.lf_group != id2->li_fid.lf_group) return 0; - if (fid1->generation != fid2->generation) + + if (id1->li_fid.lf_id != id2->li_fid.lf_id) return 0; + return 1; } diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 286b031..86aad39 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -49,6 +49,17 @@ #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 @@ -73,16 +84,17 @@ 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, rc = -EINVAL); + GOTO(out_lmv_lock, rc = -EINVAL); obd = class_exp2obd(tgt->ltd_exp); if (obd == NULL) - GOTO(out, rc = -ENOTCONN); + GOTO(out_lmv_lock, 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, @@ -92,19 +104,17 @@ 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, rc); + GOTO(out_lmv_lock, rc); } - CDEBUG(D_INFO, "Marking OBD %p %sactive\n", obd, activate ? "" : "in"); + CDEBUG(D_INFO, "Marking OBD %p %sactive\n", + obd, activate ? "" : "in"); - tgt->active = activate; - if (activate) - lmv->desc.ld_active_tgt_count++; - else - lmv->desc.ld_active_tgt_count--; + lmv_activate_target(lmv, tgt, activate); EXIT; - out: + + out_lmv_lock: spin_unlock(&lmv->lmv_lock); return rc; } @@ -123,8 +133,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) { @@ -168,9 +178,8 @@ 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) { @@ -187,7 +196,8 @@ 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) { @@ -195,11 +205,11 @@ static int lmv_connect(struct lustre_handle *conn, struct obd_device *obd, RETURN(0); } - lmv->cluuid = *cluuid; - lmv->connect_flags = connect_flags; - lmv->connected = 0; lmv->exp = exp; + lmv->connected = 0; + lmv->cluuid = *cluuid; sema_init(&lmv->init_sem, 1); + lmv->connect_flags = connect_flags; lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry, NULL, NULL); @@ -229,25 +239,29 @@ 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 obd_uuid *cluuid; struct lmv_tgt_desc *tgts; - struct proc_dir_entry *lmv_proc_dir; + struct obd_uuid *cluuid; struct obd_export *exp; int rc, rc2, i; if (lmv->connected) return 0; - + down(&lmv->init_sem); if (lmv->connected) { up(&lmv->init_sem); @@ -262,8 +276,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); @@ -291,8 +305,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_osc_uuid, + + rc = obd_connect(&conn, tgt_obd, &lmv_mdc_uuid, lmv->connect_flags); if (rc) { CERROR("Target %s connect error %d\n", @@ -319,6 +333,7 @@ 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); @@ -343,6 +358,7 @@ int lmv_check_connect(struct obd_device *obd) lmv_proc_dir = NULL; } } +#endif } lmv_set_timeouts(obd); @@ -361,7 +377,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 MDT idx %d: " + CERROR("error: LMV target %s disconnect on MDC idx %d: " "error %d\n", uuid.uuid, i, rc2); } class_disconnect(exp, 0); @@ -373,7 +389,10 @@ 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; @@ -385,7 +404,9 @@ 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; @@ -394,6 +415,8 @@ 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; @@ -406,13 +429,8 @@ 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; } @@ -421,7 +439,6 @@ 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) { @@ -430,20 +447,19 @@ static int lmv_disconnect(struct obd_export *exp, int flags) } rc = 0; } - if (lmv->tgts[i].active) { - lmv->desc.ld_active_tgt_count--; - lmv->tgts[i].active = 0; - } + + lmv_activate_target(lmv, &lmv->tgts[i], 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 @@ -471,10 +487,8 @@ 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) { - CWARN("%s: NULL export for %d\n", obddev->obd_name, i); + if (lmv->tgts[i].ltd_exp == NULL) continue; - } err = obd_iocontrol(cmd, lmv->tgts[i].ltd_exp, len, karg, uarg); if (err) { @@ -529,8 +543,8 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf) RETURN(-EINVAL); } - lmv->bufsize = sizeof(struct lmv_tgt_desc) * desc->ld_tgt_count; - OBD_ALLOC(lmv->tgts, lmv->bufsize); + lmv->tgts_size = sizeof(struct lmv_tgt_desc) * desc->ld_tgt_count; + OBD_ALLOC(lmv->tgts, lmv->tgts_size); if (lmv->tgts == NULL) { CERROR("Out of memory\n"); RETURN(-ENOMEM); @@ -544,14 +558,14 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf) lmv->max_cookiesize = 0; - lmv->max_easize = sizeof(struct ll_fid) * + lmv->max_easize = sizeof(struct lustre_id) * 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->bufsize); + OBD_FREE(lmv->tgts, lmv->tgts_size); } tgt_obd = class_find_client_obd(&lmv->tgts->uuid, LUSTRE_MDC_NAME, @@ -564,6 +578,17 @@ 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) { @@ -600,36 +625,30 @@ static int lmv_statfs(struct obd_device *obd, struct obd_statfs *osfs, 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->bufsize); - RETURN(0); -} - -static int lmv_getstatus(struct obd_export *exp, struct ll_fid *fid) +static int lmv_getstatus(struct obd_export *exp, struct lustre_id *id) { 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, fid); - fid->mds = 0; + + rc = md_getstatus(lmv->tgts[0].ltd_exp, id); + id_group(id) = 0; + RETURN(rc); } -static int lmv_getattr(struct obd_export *exp, struct ll_fid *fid, +static int lmv_getattr(struct obd_export *exp, struct lustre_id *id, 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 = fid->mds; + int rc, i = id_group(id); struct lmv_obj *obj; ENTRY; @@ -639,16 +658,15 @@ static int lmv_getattr(struct obd_export *exp, struct ll_fid *fid, LASSERT(i < lmv->desc.ld_tgt_count); - rc = md_getattr(lmv->tgts[i].ltd_exp, fid, valid, + rc = md_getattr(lmv->tgts[i].ltd_exp, id, valid, ea_size, request); if (rc) RETURN(rc); - obj = lmv_grab_obj(obd, fid); + obj = lmv_grab_obj(obd, id); - CDEBUG(D_OTHER, "GETATTR for %lu/%lu/%lu %s\n", - (unsigned long)fid->mds, (unsigned long)fid->id, - (unsigned long)fid->generation, obj ? "(splitted)" : ""); + CDEBUG(D_OTHER, "GETATTR for "DLID4" %s\n", + OLID4(id), 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 @@ -678,7 +696,7 @@ static int lmv_getattr(struct obd_export *exp, struct ll_fid *fid, } /* skip master obj. */ - if (fid_equal(&obj->fid, &obj->objs[i].fid)) + if (lmv_id_equal(&obj->id, &obj->objs[i].id)) continue; body->size += obj->objs[i].size; @@ -691,8 +709,10 @@ static int lmv_getattr(struct obd_export *exp, struct ll_fid *fid, RETURN(rc); } -static int lmv_change_cbdata(struct obd_export *exp, struct ll_fid *fid, - ldlm_iterator_t it, void *data) +static int lmv_change_cbdata(struct obd_export *exp, + struct lustre_id *id, + ldlm_iterator_t it, + void *data) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -703,19 +723,19 @@ static int lmv_change_cbdata(struct obd_export *exp, struct ll_fid *fid, if (rc) RETURN(rc); - 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); + CDEBUG(D_OTHER, "CBDATA for "DLID4"\n", OLID4(id)); + LASSERT(id_group(id) < lmv->desc.ld_tgt_count); - rc = md_change_cbdata(lmv->tgts[fid->mds].ltd_exp, - fid, it, data); + rc = md_change_cbdata(lmv->tgts[id_group(id)].ltd_exp, + id, it, data); RETURN(rc); } -static int lmv_change_cbdata_name(struct obd_export *exp, struct ll_fid *pfid, - char *name, int len, struct ll_fid *cfid, +static int lmv_change_cbdata_name(struct obd_export *exp, + struct lustre_id *pid, + char *name, int len, + struct lustre_id *cid, ldlm_iterator_t it, void *data) { struct obd_device *obd = exp->exp_obd; @@ -728,41 +748,39 @@ static int lmv_change_cbdata_name(struct obd_export *exp, struct ll_fid *pfid, if (rc) RETURN(rc); - LASSERT(pfid->mds < lmv->desc.ld_tgt_count); - LASSERT(cfid->mds < lmv->desc.ld_tgt_count); + LASSERT(id_group(pid) < lmv->desc.ld_tgt_count); + LASSERT(id_group(cid) < lmv->desc.ld_tgt_count); - 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); + CDEBUG(D_OTHER, "CBDATA for "DLID4":%*s -> "DLID4"\n", + OLID4(pid), len, name, OLID4(cid)); /* this is default mds for directory name belongs to. */ - mds = pfid->mds; - obj = lmv_grab_obj(obd, pfid); + mds = id_group(pid); + obj = lmv_grab_obj(obd, pid); if (obj) { /* directory is splitted. look for right mds for this name. */ mds = raw_name2idx(obj->hashtype, obj->objcount, name, len); - mds = obj->objs[mds].fid.mds; + mds = id_group(&obj->objs[mds].id); lmv_put_obj(obj); } - rc = md_change_cbdata(lmv->tgts[mds].ltd_exp, cfid, it, data); + rc = md_change_cbdata(lmv->tgts[mds].ltd_exp, cid, it, data); RETURN(rc); } -static int lmv_valid_attrs(struct obd_export *exp, struct ll_fid *fid) +static int lmv_valid_attrs(struct obd_export *exp, struct lustre_id *id) { 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 %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); + + 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); RETURN(rc); } @@ -778,13 +796,14 @@ 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 ll_fid *fid) +int lmv_get_mea_and_update_object(struct obd_export *exp, + struct lustre_id *id) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -799,9 +818,9 @@ int lmv_get_mea_and_update_object(struct obd_export *exp, struct ll_fid *fid) valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA; - /* time to update mea of parent fid */ - rc = md_getattr(lmv->tgts[fid->mds].ltd_exp, fid, - valid, mealen, &req); + /* time to update mea of parent id */ + rc = md_getattr(lmv->tgts[id_group(id)].ltd_exp, + id, valid, mealen, &req); if (rc) { CERROR("md_getattr() failed, error %d\n", rc); GOTO(cleanup, rc); @@ -816,7 +835,7 @@ int lmv_get_mea_and_update_object(struct obd_export *exp, struct ll_fid *fid) if (md.mea == NULL) GOTO(cleanup, rc = -ENODATA); - obj = lmv_create_obj(exp, fid, md.mea); + obj = lmv_create_obj(exp, id, md.mea); if (IS_ERR(obj)) rc = PTR_ERR(obj); @@ -848,21 +867,19 @@ 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->fid1); + obj = lmv_grab_obj(obd, &op_data->id1); if (obj) { - mds = raw_name2idx(obj->hashtype, obj->objcount, op_data->name, - op_data->namelen); - op_data->fid1 = obj->objs[mds].fid; + mds = raw_name2idx(obj->hashtype, obj->objcount, + op_data->name, op_data->namelen); + op_data->id1 = obj->objs[mds].id; lmv_put_obj(obj); } - 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); + CDEBUG(D_OTHER, "CREATE '%*s' on "DLID4"\n", op_data->namelen, + op_data->name, OLID4(&op_data->id1)); - rc = md_create(lmv->tgts[op_data->fid1.mds].ltd_exp, op_data, data, - datalen, mode, uid, gid, rdev, request); + rc = md_create(lmv->tgts[id_group(&op_data->id1)].ltd_exp, + op_data, data, datalen, mode, uid, gid, rdev, request); if (rc == 0) { if (*request == NULL) RETURN(rc); @@ -871,16 +888,14 @@ repeat: sizeof(*body)); LASSERT(body != NULL); - 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); + CDEBUG(D_OTHER, "created. "DLID4"\n", OLID4(&op_data->id1)); - LASSERT(body->valid & OBD_MD_MDS || - body->mds == op_data->fid1.mds); +/* LASSERT(body->valid & OBD_MD_MDS || + body->mds == id_group(&op_data->id1));*/ } 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->fid1); + rc = lmv_get_mea_and_update_object(exp, &op_data->id1); if (rc == 0) { ptlrpc_req_finished(*request); goto repeat; @@ -908,7 +923,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_completion, + void *lmm, int lmmsize, ldlm_completion_callback cb_compl, ldlm_blocking_callback cb_blocking, void *cb_data) { struct obd_device *obd = exp->exp_obd; @@ -921,21 +936,18 @@ 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.fid1 = mea->mea_fids[i]; - mds = data2.fid1.mds; + data2.id1 = mea->mea_ids[i]; + mds = id_group(&data2.id1); 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_completion, - cb_blocking, cb_data); + rc = md_enqueue(lmv->tgts[mds].ltd_exp, locktype, it, + lockmode, &data2, lockh + i, lmm, lmmsize, + cb_compl, cb_blocking, cb_data); - 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); + CDEBUG(D_OTHER, "take lock on slave "DLID4" -> %d/%d\n", + OLID4(&mea->mea_ids[i]), rc, it->d.lustre.it_status); if (rc) GOTO(cleanup, rc); if (it->d.lustre.it_data) { @@ -962,7 +974,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_completion, + void *lmm, int lmmsize, ldlm_completion_callback cb_compl, ldlm_blocking_callback cb_blocking, void *cb_data) { struct obd_device *obd = exp->exp_obd; @@ -978,39 +990,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_completion, cb_blocking, cb_data); + cb_compl, cb_blocking, cb_data); RETURN(rc); } if (data->namelen) { - obj = lmv_grab_obj(obd, &data->fid1); + obj = lmv_grab_obj(obd, &data->id1); 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->fid1 = obj->objs[mds].fid; + data->id1 = obj->objs[mds].id; lmv_put_obj(obj); } } - CDEBUG(D_OTHER, "ENQUEUE '%s' on %lu/%lu\n", LL_IT2STR(it), - (unsigned long)data->fid1.id, (unsigned long)data->fid1.generation); + CDEBUG(D_OTHER, "ENQUEUE '%s' on "DLID4"\n", LL_IT2STR(it), + OLID4(&data->id1)); - 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); + 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); RETURN(rc); } -int lmv_getattr_name(struct obd_export *exp, struct ll_fid *fid, +int lmv_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) { + int rc, mds = id_group(id), loop = 0; struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - struct ll_fid rfid = *fid; - int rc, mds = fid->mds, loop = 0; + struct lustre_id rid = *id; struct mds_body *body; struct lmv_obj *obj; ENTRY; @@ -1019,22 +1031,20 @@ int lmv_getattr_name(struct obd_export *exp, struct ll_fid *fid, RETURN(rc); repeat: LASSERT(++loop <= 2); - obj = lmv_grab_obj(obd, fid); + obj = lmv_grab_obj(obd, id); if (obj) { /* directory is splitted. look for right mds for this name */ - mds = raw_name2idx(obj->hashtype, obj->objcount, filename, namelen - 1); - rfid = obj->objs[mds].fid; + mds = raw_name2idx(obj->hashtype, obj->objcount, + filename, namelen - 1); + rid = obj->objs[mds].id; lmv_put_obj(obj); } - 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); + 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); 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 @@ -1043,20 +1053,19 @@ repeat: LASSERT(body != NULL); if (body->valid & OBD_MD_MDS) { struct ptlrpc_request *req = NULL; - 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); + + 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); 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, &rfid); + rc = lmv_get_mea_and_update_object(exp, &rid); if (rc == 0) { ptlrpc_req_finished(*request); goto repeat; @@ -1065,10 +1074,9 @@ repeat: RETURN(rc); } - /* - * llite passes fid of an target inode in data->fid1 and fid of directory in - * data->fid2 + * llite passes id of an target inode in data->id1 and id of directory in + * data->id2 */ int lmv_link(struct obd_export *exp, struct mdc_op_data *data, struct ptlrpc_request **request) @@ -1085,32 +1093,25 @@ 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->fid1); + obj = lmv_grab_obj(obd, &data->id1); if (obj) { - rc = raw_name2idx(obj->hashtype, obj->objcount, data->name, - data->namelen); - data->fid1 = obj->objs[rc].fid; + rc = raw_name2idx(obj->hashtype, obj->objcount, + data->name, data->namelen); + data->id1 = obj->objs[rc].id; lmv_put_obj(obj); } - 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); + CDEBUG(D_OTHER,"link "DLID4":%*s to "DLID4"\n", + OLID4(&data->id2), data->namelen, data->name, + OLID4(&data->id1)); } else { - /* 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); + /* request from MDS to acquire i_links for inode by id1 */ + CDEBUG(D_OTHER, "inc i_nlinks for "DLID4"\n", + OLID4(&data->id1)); } - rc = md_link(lmv->tgts[data->fid1.mds].ltd_exp, data, request); + rc = md_link(lmv->tgts[id_group(&data->id1)].ltd_exp, + data, request); RETURN(rc); } @@ -1124,22 +1125,14 @@ int lmv_rename(struct obd_export *exp, struct mdc_op_data *data, int rc, mds; ENTRY; - 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); + CDEBUG(D_OTHER, "rename %*s in "DLID4" to %*s in "DLID4"\n", + oldlen, old, OLID4(&data->id1), newlen, new, OLID4(&data->id2)); - 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); + 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); + } rc = lmv_check_connect(obd); if (rc) @@ -1149,45 +1142,39 @@ 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 %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; + "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); goto request; } - obj = lmv_grab_obj(obd, &data->fid1); + obj = lmv_grab_obj(obd, &data->id1); 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->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); + 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)); lmv_put_obj(obj); } - obj = lmv_grab_obj(obd, &data->fid2); + obj = lmv_grab_obj(obd, &data->id2); 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->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); + 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)); lmv_put_obj(obj); } - mds = data->fid1.mds; + mds = id_group(&data->id1); request: rc = md_rename(lmv->tgts[mds].ltd_exp, data, old, oldlen, @@ -1211,21 +1198,19 @@ int lmv_setattr(struct obd_export *exp, struct mdc_op_data *data, if (rc) RETURN(rc); - obj = lmv_grab_obj(obd, &data->fid1); + obj = lmv_grab_obj(obd, &data->id1); - 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" : ""); + CDEBUG(D_OTHER, "SETATTR for "DLID4", valid 0x%x%s\n", + OLID4(&data->id1), iattr->ia_valid, obj ? ", splitted" : ""); if (obj) { for (i = 0; i < obj->objcount; i++) { - data->fid1 = obj->objs[i].fid; + data->id1 = obj->objs[i].id; - rc = md_setattr(lmv->tgts[data->fid1.mds].ltd_exp, data, - iattr, ea, ealen, ea2, ea2len, &req); + rc = md_setattr(lmv->tgts[id_group(&data->id1)].ltd_exp, + data, iattr, ea, ealen, ea2, ea2len, &req); - if (fid_equal(&obj->fid, &obj->objs[i].fid)) { + if (lmv_id_equal(&obj->id, &obj->objs[i].id)) { /* this is master object and this request should * be returned back to llite */ *request = req; @@ -1238,20 +1223,20 @@ int lmv_setattr(struct obd_export *exp, struct mdc_op_data *data, } lmv_put_obj(obj); } else { - 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); + 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); if (rc == 0) { body = lustre_msg_buf((*request)->rq_repmsg, 0, sizeof(*body)); LASSERT(body != NULL); - LASSERT(body->mds == data->fid1.mds); +// LASSERT(body->mds == id_group(&data->id1)); } } RETURN(rc); } -int lmv_sync(struct obd_export *exp, struct ll_fid *fid, +int lmv_sync(struct obd_export *exp, struct lustre_id *id, struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; @@ -1263,11 +1248,13 @@ int lmv_sync(struct obd_export *exp, struct ll_fid *fid, if (rc) RETURN(rc); - rc = md_sync(lmv->tgts[fid->mds].ltd_exp, fid, request); + rc = md_sync(lmv->tgts[id_group(id)].ltd_exp, + id, 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; @@ -1289,12 +1276,12 @@ int lmv_dirobj_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, obj = lock->l_ast_data; if (obj) { CDEBUG(D_OTHER, "cancel %s on "LPU64"/"LPU64 - ", master %u/"LPU64"/%u\n", + ", master "DLID4"\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], obj->fid.mds, - obj->fid.id, obj->fid.generation); + lock->l_resource->lr_name.name[1], + OLID4(&obj->id)); lmv_put_obj(obj); } break; @@ -1321,28 +1308,27 @@ void lmv_remove_dots(struct page *page) } } -int lmv_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, +int lmv_readpage(struct obd_export *exp, struct lustre_id *id, __u64 offset, struct page *page, struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - struct ll_fid rfid = *mdc_fid; + struct lustre_id rid = *id; 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(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); + LASSERT(id_group(id) < lmv->desc.ld_tgt_count); + CDEBUG(D_OTHER, "READPAGE at %llu from "DLID4"\n", + offset, OLID4(&rid)); - obj = lmv_grab_obj(obd, mdc_fid); + obj = lmv_grab_obj(obd, id); if (obj) { lmv_lock_obj(obj); @@ -1352,19 +1338,18 @@ int lmv_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, break; offset -= obj->objs[i].size; } - rfid = obj->objs[i].fid; + rid = obj->objs[i].id; lmv_unlock_obj(obj); lmv_put_obj(obj); - 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); + CDEBUG(D_OTHER, "forward to "DLID4" with offset %lu\n", + OLID4(&rid), (unsigned long)offset); } - rc = md_readpage(lmv->tgts[rfid.mds].ltd_exp, &rfid, offset, - page, request); + rc = md_readpage(lmv->tgts[id_group(&rid)].ltd_exp, &rid, + offset, page, request); - if (rc == 0 && !fid_equal(&rfid, mdc_fid)) + if (rc == 0 && !lmv_id_equal(&rid, id)) /* this page isn't from master object. To avoid "." and ".." * duplication in directory, we have to remove them from all * slave objects */ @@ -1386,18 +1371,17 @@ 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.fid1 = mea->mea_fids[i]; + data2.id1 = mea->mea_ids[i]; data2.create_mode = MDS_MODE_DONT_LOCK | S_IFDIR; - mds = data2.fid1.mds; + + mds = id_group(&data2.id1); if (lmv->tgts[mds].ltd_exp == NULL) continue; rc = md_unlink(lmv->tgts[mds].ltd_exp, &data2, req); - 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); + CDEBUG(D_OTHER, "unlink slave "DLID4" -> %d\n", + OLID4(&mea->mea_ids[i]), rc); if (*req) { ptlrpc_req_finished(*req); *req = NULL; @@ -1408,14 +1392,13 @@ int lmv_unlink_slaves(struct obd_export *exp, struct mdc_op_data *data, RETURN(rc); } -int lmv_delete_object(struct obd_export *exp, struct ll_fid *fid) +int lmv_delete_object(struct obd_export *exp, struct lustre_id *id) { ENTRY; - 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); + if (!lmv_delete_obj(exp, id)) { + CDEBUG(D_OTHER, "object "DLID4" is not found.\n", + OLID4(id)); } RETURN(0); @@ -1440,25 +1423,22 @@ 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->fid1); + obj = lmv_grab_obj(obd, &data->id1); if (obj) { - i = raw_name2idx(obj->hashtype, obj->objcount, data->name, - data->namelen); - data->fid1 = obj->objs[i].fid; + i = raw_name2idx(obj->hashtype, obj->objcount, + data->name, data->namelen); + data->id1 = obj->objs[i].id; lmv_put_obj(obj); } - 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); + CDEBUG(D_OTHER, "unlink '%*s' in "DLID4" -> %u\n", + data->namelen, data->name, OLID4(&data->id1), + i); } else { - 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); + CDEBUG(D_OTHER, "drop i_nlink on "DLID4"\n", + OLID4(&data->id1)); } - rc = md_unlink(lmv->tgts[data->fid1.mds].ltd_exp, data, request); + rc = md_unlink(lmv->tgts[id_group(&data->id1)].ltd_exp, + data, request); RETURN(rc); } @@ -1473,7 +1453,6 @@ 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; @@ -1534,17 +1513,27 @@ 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; @@ -1556,6 +1545,8 @@ 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); } @@ -1568,19 +1559,22 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, } if (*ea == NULL) - RETURN(-EINVAL); + RETURN(-ENOMEM); } 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; @@ -1588,21 +1582,22 @@ 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) { @@ -1611,12 +1606,18 @@ 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); @@ -1657,6 +1658,7 @@ 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); @@ -1670,8 +1672,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 ll_fid) * lmv->desc.ld_tgt_count - + sizeof(struct mea); + *mdsize = sizeof(struct lustre_id) * 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; @@ -1687,6 +1689,15 @@ 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"); @@ -1725,7 +1736,7 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, int mea_size; ENTRY; - mea_size = sizeof(struct ll_fid) * + mea_size = sizeof(struct lustre_id) * lmv->desc.ld_tgt_count + sizeof(struct mea); if (!lmmp) RETURN(mea_size); @@ -1760,7 +1771,7 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **mem_tgt, int mea_size; ENTRY; - mea_size = sizeof(struct ll_fid) * + mea_size = sizeof(struct lustre_id) * lmv->desc.ld_tgt_count + sizeof(struct mea); if (mem_tgt == NULL) return mea_size; @@ -1798,11 +1809,12 @@ 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 = 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); + 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); RETURN(err); } @@ -1826,6 +1838,7 @@ 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 9485f9d..1aa6b4c 100644 --- a/lustre/lmv/lmv_objmgr.c +++ b/lustre/lmv/lmv_objmgr.c @@ -51,9 +51,10 @@ static LIST_HEAD(lmv_obj_list); static spinlock_t lmv_obj_list_lock = SPIN_LOCK_UNLOCKED; -/* creates new obj on passed @fid and @mea. */ +/* creates new obj on passed @id and @mea. */ struct lmv_obj * -lmv_alloc_obj(struct obd_device *obd, struct ll_fid *fid, +lmv_alloc_obj(struct obd_device *obd, + struct lustre_id *id, struct mea *mea) { int i; @@ -62,17 +63,17 @@ lmv_alloc_obj(struct obd_device *obd, struct ll_fid *fid, 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; @@ -86,13 +87,12 @@ lmv_alloc_obj(struct obd_device *obd, struct ll_fid *fid, memset(obj->objs, 0, obj_size); - /* put all fids in */ + /* put all ids in */ for (i = 0; i < mea->mea_count; i++) { - 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]; + 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)); } return obj; @@ -102,7 +102,7 @@ err_obj: return NULL; } -/* destroys passed @obj. */ +/* destroy passed @obj. */ void lmv_free_obj(struct lmv_obj *obj) { @@ -173,10 +173,9 @@ __put_obj(struct lmv_obj *obj) LASSERT(obj); if (atomic_dec_and_test(&obj->count)) { - 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); + struct lustre_id *id = &obj->id; + CDEBUG(D_OTHER, "last reference to "DLID4" - " + "destroying\n", OLID4(id)); __del_obj(obj); } } @@ -190,7 +189,7 @@ lmv_put_obj(struct lmv_obj *obj) } static struct lmv_obj * -__grab_obj(struct obd_device *obd, struct ll_fid *fid) +__grab_obj(struct obd_device *obd, struct lustre_id *id) { struct lmv_obj *obj; struct list_head *cur; @@ -203,8 +202,8 @@ __grab_obj(struct obd_device *obd, struct ll_fid *fid) if (obj->state & O_FREEING) continue; - /* check if this is waht we're looking for. */ - if (fid_equal(&obj->fid, fid)) + /* check if this is what we're looking for. */ + if (lmv_id_equal(&obj->id, id)) return __get_obj(obj); } @@ -212,39 +211,39 @@ __grab_obj(struct obd_device *obd, struct ll_fid *fid) } struct lmv_obj * -lmv_grab_obj(struct obd_device *obd, struct ll_fid *fid) +lmv_grab_obj(struct obd_device *obd, struct lustre_id *id) { struct lmv_obj *obj; ENTRY; spin_lock(&lmv_obj_list_lock); - obj = __grab_obj(obd, fid); + obj = __grab_obj(obd, id); spin_unlock(&lmv_obj_list_lock); RETURN(obj); } -/* looks in objects list for an object that matches passed @fid. If it is not +/* looks in objects list for an object that matches passed @id. 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 ll_fid *fid, struct mea *mea) +__create_obj(struct obd_device *obd, struct lustre_id *id, struct mea *mea) { struct lmv_obj *new, *obj; ENTRY; - obj = lmv_grab_obj(obd, fid); + obj = lmv_grab_obj(obd, id); if (obj) RETURN(obj); /* no such object yet, allocate and initialize it. */ - new = lmv_alloc_obj(obd, fid, mea); + new = lmv_alloc_obj(obd, id, 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, fid); + obj = __grab_obj(obd, id); if (obj) { /* someone created it already - put @obj and getting out. */ lmv_free_obj(new); @@ -257,18 +256,17 @@ __create_obj(struct obd_device *obd, struct ll_fid *fid, struct mea *mea) spin_unlock(&lmv_obj_list_lock); - CDEBUG(D_OTHER, "new obj in lmv cache: %lu/%lu/%lu\n", - (unsigned long)fid->mds, (unsigned long)fid->id, - (unsigned long)fid->generation); + CDEBUG(D_OTHER, "new obj in lmv cache: "DLID4"\n", + OLID4(id)); RETURN(new); } -/* creates object from passed @fid and @mea. If @mea is NULL, it will be +/* creates object from passed @id 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 ll_fid *fid, struct mea *mea) +lmv_create_obj(struct obd_export *exp, struct lustre_id *id, struct mea *mea) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -278,9 +276,8 @@ lmv_create_obj(struct obd_export *exp, struct ll_fid *fid, struct mea *mea) int mealen, i, rc; ENTRY; - 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); + CDEBUG(D_OTHER, "get mea for "DLID4" and create lmv obj\n", + OLID4(id)); if (!mea) { unsigned long valid; @@ -288,13 +285,13 @@ lmv_create_obj(struct obd_export *exp, struct ll_fid *fid, 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 fid */ - i = fid->mds; + /* time to update mea of parent id */ + i = id->li_fid.lf_group; md.mea = NULL; valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA; - rc = md_getattr(lmv->tgts[fid->mds].ltd_exp, fid, - valid, mealen, &req); + rc = md_getattr(lmv->tgts[id->li_fid.lf_group].ltd_exp, + id, valid, mealen, &req); if (rc) { CERROR("md_getattr() failed, error %d\n", rc); GOTO(cleanup, obj = ERR_PTR(rc)); @@ -313,11 +310,10 @@ lmv_create_obj(struct obd_export *exp, struct ll_fid *fid, struct mea *mea) } /* got mea, now create obj for it. */ - obj = __create_obj(obd, fid, mea); + obj = __create_obj(obd, id, mea); if (!obj) { - CERROR("Can't create new object %lu/%lu/%lu\n", - (unsigned long)fid->mds, (unsigned long)fid->id, - (unsigned long)fid->generation); + CERROR("Can't create new object "DLID4"\n", + OLID4(id)); GOTO(cleanup, obj = ERR_PTR(-ENOMEM)); } cleanup: @@ -326,12 +322,12 @@ cleanup: RETURN(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(). */ +/* 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(). */ int -lmv_delete_obj(struct obd_export *exp, struct ll_fid *fid) +lmv_delete_obj(struct obd_export *exp, struct lustre_id *id) { struct obd_device *obd = exp->exp_obd; struct lmv_obj *obj; @@ -340,16 +336,13 @@ lmv_delete_obj(struct obd_export *exp, struct ll_fid *fid) spin_lock(&lmv_obj_list_lock); - obj = __grab_obj(obd, fid); + obj = __grab_obj(obd, id); if (obj) { obj->state |= O_FREEING; if (atomic_read(&obj->count) > 1) - 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)); + CERROR("obj "DLID4" has count > 2 (%d)\n", + OLID4(&obj->id), atomic_read(&obj->count)); __put_obj(obj); __put_obj(obj); rc = 1; @@ -362,7 +355,8 @@ lmv_delete_obj(struct obd_export *exp, struct ll_fid *fid) 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; } @@ -372,7 +366,8 @@ 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) { @@ -383,11 +378,8 @@ lmv_cleanup_mgr(struct obd_device *obd) obj->state |= O_FREEING; if (atomic_read(&obj->count) > 1) - 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)); + CERROR("obj "DLID4" has count > 1 (%d)\n", + OLID4(&obj->id), 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 fb34c8b..4f291df 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -118,12 +118,15 @@ 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 lov_obd *lov = &obd->u.lov; - 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 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_device *tgt_obd; int rc; ENTRY; @@ -176,6 +179,7 @@ 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); @@ -200,6 +204,7 @@ static int lov_connect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt, lov_proc_dir = NULL; } } +#endif RETURN(0); } @@ -207,10 +212,12 @@ 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; @@ -228,6 +235,7 @@ 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)) { @@ -235,6 +243,7 @@ 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; @@ -250,8 +259,10 @@ 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; @@ -272,12 +283,15 @@ 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; @@ -291,7 +305,8 @@ 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, @@ -302,7 +317,6 @@ 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) { @@ -324,9 +338,11 @@ 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; @@ -342,6 +358,8 @@ 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); @@ -349,7 +367,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 3d631dc..02609e0 100644 --- a/lustre/lvfs/fsfilt_ext3.c +++ b/lustre/lvfs/fsfilt_ext3.c @@ -59,14 +59,17 @@ 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_rcvd; /* MDS/OST last committed operation */ + __u64 cb_last_num; /* 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 @@ -441,6 +444,45 @@ 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) { @@ -451,44 +493,60 @@ 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); + inode->i_ino, inode->i_generation); - lock_kernel(); - rc = ext3_xattr_set_handle(handle, inode, EXT3_XATTR_INDEX_TRUSTED, - XATTR_LUSTRE_MDS_LOV_EA, lmm, lmm_size, 0); + rc = fsfilt_ext3_set_xattr(inode, handle, XATTR_LUSTRE_MDS_LOV_EA, + lmm, lmm_size); + return rc; +} - unlock_kernel(); +/* Must be called with i_sem held */ +static int fsfilt_ext3_get_md(struct inode *inode, void *lmm, int lmm_size) +{ + int rc; - if (rc) - CERROR("error adding MD data to inode %lu: rc = %d\n", - inode->i_ino, rc); + rc = fsfilt_ext3_get_xattr(inode, XATTR_LUSTRE_MDS_LOV_EA, + lmm, lmm_size); + return rc; +} + +static int fsfilt_ext3_set_mid(struct inode *inode, void *handle, + void *mid, int mid_size) +{ + int rc; + + rc = fsfilt_ext3_set_xattr(inode, handle, XATTR_LUSTRE_MDS_MID_EA, + mid, mid_size); return rc; } /* Must be called with i_sem held */ -static int fsfilt_ext3_get_md(struct inode *inode, void *lmm, int lmm_size) +static int fsfilt_ext3_get_mid(struct inode *inode, void *mid, int mid_size) { int rc; - LASSERT(down_trylock(&inode->i_sem) != 0); - lock_kernel(); + rc = fsfilt_ext3_get_xattr(inode, XATTR_LUSTRE_MDS_MID_EA, + mid, mid_size); + return rc; +} - rc = ext3_xattr_get(inode, EXT3_XATTR_INDEX_TRUSTED, - XATTR_LUSTRE_MDS_LOV_EA, lmm, lmm_size); - unlock_kernel(); +static int fsfilt_ext3_set_sid(struct inode *inode, void *handle, + void *sid, int sid_size) +{ + int rc; - /* This gives us the MD size */ - if (lmm == NULL) - return (rc == -ENODATA) ? 0 : rc; + rc = fsfilt_ext3_set_xattr(inode, handle, XATTR_LUSTRE_MDS_SID_EA, + sid, sid_size); + return 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; - } +/* Must be called with i_sem held */ +static int fsfilt_ext3_get_sid(struct inode *inode, void *sid, int sid_size) +{ + int rc; + rc = fsfilt_ext3_get_xattr(inode, XATTR_LUSTRE_MDS_SID_EA, + sid, sid_size); return rc; } @@ -602,7 +660,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_rcvd, fcb->cb_data, error); + fcb->cb_func(fcb->cb_obd, fcb->cb_last_num, fcb->cb_data, error); OBD_SLAB_FREE(fcb, fcb_cache, sizeof *fcb); atomic_dec(&fcb_cache_count); @@ -610,8 +668,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_rcvd, - void *handle, fsfilt_cb_t cb_func, + __u64 last_num, void *handle, + fsfilt_cb_t cb_func, void *cb_data) { struct fsfilt_cb_data *fcb; @@ -623,10 +681,11 @@ 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_rcvd = last_rcvd; + fcb->cb_last_num = last_num; fcb->cb_data = cb_data; - CDEBUG(D_EXT2, "set callback for last_rcvd: "LPD64"\n", last_rcvd); + CDEBUG(D_EXT2, "set callback for last_num: "LPD64"\n", last_num); + lock_kernel(); journal_callback_set(handle, fsfilt_ext3_cb_func, (struct journal_callback *)fcb); @@ -1034,7 +1093,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, block_count = 0, blocksize, size, boffs; + int err = 0, block_count = 0, blocksize, size, boffs; /* Determine how many transaction credits are needed */ blocksize = 1 << inode->i_blkbits; @@ -1165,11 +1224,12 @@ 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 mds) + struct dentry *parent, + char *name, int namelen, + unsigned long ino, + unsigned long generation, + unsigned long mds, + unsigned long fid) { #ifdef EXT3_FEATURE_INCOMPAT_MDSNUM struct dentry *dentry; @@ -1200,6 +1260,7 @@ 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(); @@ -1230,45 +1291,6 @@ 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) @@ -1363,33 +1385,37 @@ 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_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_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_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 b64cf91..b0b77b1 100644 --- a/lustre/lvfs/fsfilt_smfs.c +++ b/lustre/lvfs/fsfilt_smfs.c @@ -241,8 +241,12 @@ static int fsfilt_smfs_iocontrol(struct inode *inode, struct file *file, RETURN(rc); } -static int fsfilt_smfs_set_md(struct inode *inode, void *handle, - void *lmm, int lmm_size) +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) { struct fsfilt_operations *cache_fsfilt = I2FOPS(inode); struct inode *cache_inode = NULL; @@ -256,24 +260,22 @@ static int fsfilt_smfs_set_md(struct inode *inode, void *handle, if (!cache_inode) RETURN(-ENOENT); - pre_smfs_inode(inode, cache_inode); - - if (!cache_fsfilt->fs_set_md) + if (!set_ea_func) RETURN(-ENOSYS); + pre_smfs_inode(inode, cache_inode); + down(&cache_inode->i_sem); - rc = cache_fsfilt->fs_set_md(cache_inode, handle, lmm, lmm_size); + rc = set_ea_func(cache_inode, handle, ea, ea_size); up(&cache_inode->i_sem); post_smfs_inode(inode, cache_inode); - smfs_rec_md(inode, lmm, lmm_size); - RETURN(rc); } -/* Must be called with i_sem held */ -static int fsfilt_smfs_get_md(struct inode *inode, void *lmm, int lmm_size) +static int fsfilt_smfs_get_ea(struct inode *inode, void *ea, + int ea_size, get_ea_func_t get_ea_func) { struct fsfilt_operations *cache_fsfilt = I2FOPS(inode); struct inode *cache_inode = NULL; @@ -287,13 +289,13 @@ static int fsfilt_smfs_get_md(struct inode *inode, void *lmm, int lmm_size) if (!cache_inode) RETURN(-ENOENT); - pre_smfs_inode(inode, cache_inode); - - if (!cache_fsfilt->fs_get_md) + if (!get_ea_func) RETURN(-ENOSYS); + pre_smfs_inode(inode, cache_inode); + down(&cache_inode->i_sem); - rc = cache_fsfilt->fs_get_md(cache_inode, lmm, lmm_size); + rc = get_ea_func(cache_inode, ea, ea_size); up(&cache_inode->i_sem); post_smfs_inode(inode, cache_inode); @@ -301,6 +303,61 @@ static int fsfilt_smfs_get_md(struct inode *inode, void *lmm, int lmm_size) 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; @@ -1004,6 +1061,10 @@ 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, @@ -1016,9 +1077,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, @@ -1034,8 +1095,6 @@ 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 1aa8be9..1b533f4 100644 --- a/lustre/lvfs/llog_lvfs.c +++ b/lustre/lvfs/llog_lvfs.c @@ -517,12 +517,15 @@ 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 fidname[LL_FID_NAMELEN]; - int fidlen = 0; + char id_name[LL_ID_NAMELEN]; + int id_len = 0; down(&ctxt->loc_objects_dir->d_inode->i_sem); - fidlen = ll_fid2str(fidname, lgh_id->lgl_oid, lgh_id->lgl_ogen); - dchild = lookup_one_len(fidname, ctxt->loc_objects_dir, fidlen); + 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); if (IS_ERR(dchild)) { up(&ctxt->loc_objects_dir->d_inode->i_sem); RETURN((struct file *)dchild); @@ -561,8 +564,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", fidname, - 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); filp_close(filp, 0); up(&ctxt->loc_objects_dir->d_inode->i_sem); RETURN(ERR_PTR(-ENOENT)); @@ -573,13 +576,13 @@ llog_object_create_alone(struct llog_ctxt *ctxt, struct llog_logid *lgh_id) } else { unsigned int tmpname = ll_insecure_random_int(); - char fidname[LL_FID_NAMELEN]; + char id_name[LL_ID_NAMELEN]; struct dentry *new_child, *parent; + int err, id_len; void *handle; - int err, namelen; - sprintf(fidname, "OBJECTS/%u", tmpname); - filp = filp_open(fidname, O_CREAT | O_EXCL, 0644); + sprintf(id_name, "OBJECTS/%u", tmpname); + filp = filp_open(id_name, O_CREAT | O_EXCL, 0644); if (IS_ERR(filp)) { rc = PTR_ERR(filp); if (rc == -EEXIST) { @@ -591,11 +594,11 @@ llog_object_create_alone(struct llog_ctxt *ctxt, struct llog_logid *lgh_id) RETURN(filp); } - namelen = ll_fid2str(fidname, filp->f_dentry->d_inode->i_ino, - filp->f_dentry->d_inode->i_generation); + id_len = ll_id2str(id_name, 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(fidname, parent, namelen); + new_child = lookup_one_len(id_name, parent, id_len); if (IS_ERR(new_child)) { CERROR("getting neg dentry for obj rename: %d\n", rc); GOTO(out_close, rc = PTR_ERR(new_child)); @@ -657,8 +660,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_fid2dentry(ctxt->loc_exp, 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); if (IS_ERR(dchild) == -ENOENT) { OBD_ALLOC(oa, sizeof(*oa)); if (!oa) @@ -676,8 +679,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_fid2dentry(ctxt->loc_exp, 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); } 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); @@ -707,8 +710,8 @@ llog_object_create_generic(struct llog_ctxt *ctxt, struct llog_logid *lgh_id) if (rc) GOTO(out_free_oa, rc); - dchild = obd_lvfs_fid2dentry(ctxt->loc_exp, oa->o_id, - oa->o_generation, oa->o_gr); + dchild = obd_lvfs_id2dentry(ctxt->loc_exp, oa->o_id, + oa->o_generation, oa->o_gr); if (IS_ERR(dchild)) GOTO(out_free_oa, rc = PTR_ERR(dchild)); @@ -747,14 +750,14 @@ static int llog_add_link_object(struct llog_ctxt *ctxt, struct llog_logid logid, struct dentry *dentry) { struct dentry *new_child; - char fidname[LL_FID_NAMELEN]; + char id_name[LL_ID_NAMELEN]; void *handle; - int namelen, rc = 0, err; + int id_len, rc = 0, err; ENTRY; - namelen = ll_fid2str(fidname, logid.lgl_oid, logid.lgl_ogen); + id_len = ll_id2str(id_name, logid.lgl_oid, logid.lgl_ogen); down(&ctxt->loc_objects_dir->d_inode->i_sem); - new_child = lookup_one_len(fidname, ctxt->loc_objects_dir, namelen); + new_child = lookup_one_len(id_name, ctxt->loc_objects_dir, id_len); if (IS_ERR(new_child)) { CERROR("getting neg dentry for obj rename: %d\n", rc); GOTO(out, rc = PTR_ERR(new_child)); @@ -873,9 +876,9 @@ static int llog_lvfs_destroy(struct llog_handle *loghandle) struct lvfs_run_ctxt saved; struct dentry *fdentry; struct inode *parent_inode; - char fidname[LL_FID_NAMELEN]; + char id_name[LL_ID_NAMELEN]; void *handle; - int rc = -EINVAL, err, namelen; + int rc = -EINVAL, err, id_len; ENTRY; if (ctxt->loc_lvfs_ctxt) @@ -887,8 +890,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); - namelen = ll_fid2str(fidname, fdentry->d_inode->i_ino, - fdentry->d_inode->i_generation); + id_len = ll_id2str(id_name, fdentry->d_inode->i_ino, + fdentry->d_inode->i_generation); dget(fdentry); rc = llog_lvfs_close(loghandle); if (rc) { @@ -910,10 +913,11 @@ static int llog_lvfs_destroy(struct llog_handle *loghandle) if (!rc) { down(&ctxt->loc_objects_dir->d_inode->i_sem); - fdentry = lookup_one_len(fidname, ctxt->loc_objects_dir, - namelen); + fdentry = lookup_one_len(id_name, ctxt->loc_objects_dir, + id_len); if (fdentry == NULL || fdentry->d_inode == NULL) { - CERROR("destroy non_existent object %s\n", fidname); + CERROR("destroy non_existent object %s\n", + id_name); 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 d8ab4a3..caa6e01 100644 --- a/lustre/lvfs/lvfs_common.c +++ b/lustre/lvfs/lvfs_common.c @@ -27,9 +27,9 @@ #include -struct dentry *lvfs_fid2dentry(struct lvfs_run_ctxt *ctxt, __u64 id, - __u32 gen, __u64 gr, void *data) +struct dentry *lvfs_id2dentry(struct lvfs_run_ctxt *ctxt, __u64 id, + __u32 gen, __u64 gr, void *data) { - return ctxt->cb_ops.l_fid2dentry(id, gen, gr, data); + return ctxt->cb_ops.l_id2dentry(id, gen, gr, data); } -EXPORT_SYMBOL(lvfs_fid2dentry); +EXPORT_SYMBOL(lvfs_id2dentry); diff --git a/lustre/mdc/mdc_internal.h b/lustre/mdc/mdc_internal.h index 702d3c7..57e8d5d 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 ll_fid *mdc_fid); + __u64 offset, __u32 size, struct lustre_id *mdc_id); 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 74d3030..7658bc5 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 ll_fid *mdc_fid) + __u64 offset, __u32 size, struct lustre_id *mdc_id) { struct mds_body *b; b = lustre_msg_buf(req->rq_reqmsg, req_offset, sizeof (*b)); - b->fid1 = *mdc_fid; + b->id1 = *mdc_id; b->size = offset; /* !! */ b->nlink = size; /* !! */ } @@ -64,6 +64,7 @@ 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, @@ -76,8 +77,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_fid = op_data->fid1; - memset(&rec->cr_replayfid, 0, sizeof(rec->cr_replayfid)); + rec->cr_id = op_data->id1; + memset(&rec->cr_replayid, 0, sizeof(rec->cr_replayid)); rec->cr_mode = mode; rec->cr_flags = mds_pack_open_flags(flags); rec->cr_rdev = rdev; @@ -105,8 +106,8 @@ void mdc_getattr_pack(struct lustre_msg *msg, int offset, int valid, b->valid = valid; b->flags = flags; - b->fid1 = data->fid1; - b->fid2 = data->fid2; + b->id1 = data->id1; + b->id2 = data->id2; if (data->name) { char *tmp; tmp = lustre_msg_buf(msg, offset + 1, @@ -121,8 +122,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 7998565..ad5b95f 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -36,8 +36,6 @@ #include #include #include -//#include -//#include #include #include "mdc_internal.h" @@ -53,18 +51,20 @@ void it_set_disposition(struct lookup_intent *it, int flag) } EXPORT_SYMBOL(it_set_disposition); -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) +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) { LASSERT(data); LASSERT(f1); - data->fid1 = *f1; + data->id1 = *f1; if (f2) - data->fid2 = *f2; - else - memset(&data->fid2, 0, sizeof(data->fid2)); + data->id2 = *f2; + + data->valid = 0; 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 ll_fid *fid, +int mdc_change_cbdata(struct obd_export *exp, struct lustre_id *id, ldlm_iterator_t it, void *data) { struct ldlm_res_id res_id = { .name = {0} }; ENTRY; - res_id.name[0] = fid->id; - res_id.name[1] = fid->generation; + res_id.name[0] = id_fid(id); + res_id.name[1] = id_group(id); - 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,9 +188,10 @@ 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; @@ -242,13 +243,14 @@ 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 = OBD_MD_FLNOTOBD | OBD_MD_FLEASIZE; + int valid = data->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); @@ -263,6 +265,7 @@ 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); @@ -435,43 +438,42 @@ 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 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, +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, 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 inode "LPU64", intent: %s flags %#o\n", - len, name, pfid->id, ldlm_it2str(it->it_op), it->it_flags); + 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); - if (cfid && (it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR || - it->it_op == IT_CHDIR)) { + if (cid && (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 = {cfid->id, - cfid->generation}}; + struct ldlm_res_id res_id = {.name = {id_fid(cid), + id_group(cid)}}; 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 if cannot + queries - for LOOKUP and for UPDATE lock because it 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, @@ -505,13 +507,23 @@ int mdc_intent_lock(struct obd_export *exp, * never dropped its reference, so the refcounts are all OK */ if (!it_disposition(it, DISP_ENQ_COMPLETE)) { struct mdc_op_data op_data; - mdc_fid2mdc_op_data(&op_data, pfid, cfid, name, len, 0); + + 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; 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; @@ -545,20 +557,21 @@ int mdc_intent_lock(struct obd_export *exp, 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 (cfid != NULL) { + /* If we were revalidating a fid/name pair, mark the intent in case we + * fail and get called again from lookup */ + if (cid != 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 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) + + /* 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)) RETURN(-ESTALE); } @@ -566,8 +579,9 @@ int mdc_intent_lock(struct obd_export *exp, 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)) @@ -584,16 +598,27 @@ int mdc_intent_lock(struct obd_export *exp, 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 b34e1e1..3b5d382 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -36,9 +36,10 @@ #include #include "mdc_internal.h" -/* mdc_setattr does its own semaphore handling */ -int mdc_reint(struct ptlrpc_request *request, - struct mdc_rpc_lock *rpc_lock, int level) +/* this function actually sends request to desired target. */ +static int mdc_reint(struct ptlrpc_request *request, + struct mdc_rpc_lock *rpc_lock, + int level) { int rc; @@ -60,16 +61,16 @@ int mdc_reint(struct ptlrpc_request *request, } return rc; } -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 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; @@ -119,8 +120,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; @@ -142,8 +143,10 @@ 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); @@ -152,7 +155,8 @@ 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 4d0151a..f633ad3 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -45,25 +45,31 @@ 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; + sizeof(__u32) * ngroups; +#else + return 0; +#endif } /* - * 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; @@ -88,12 +94,13 @@ 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 ll_fid *rootfid, +static int send_getstatus(struct obd_import *imp, struct lustre_id *rootid, int level, int msg_flags) { struct ptlrpc_request *req; @@ -125,12 +132,11 @@ static int send_getstatus(struct obd_import *imp, struct ll_fid *rootfid, GOTO (out, rc = -EPROTO); } - memcpy(rootfid, &body->fid1, sizeof(*rootfid)); + memcpy(rootid, &body->id1, sizeof(*rootid)); CDEBUG(D_NET, "root ino="LPU64", last_committed="LPU64 - ", last_xid="LPU64"\n", - rootfid->id, req->rq_repmsg->last_committed, - req->rq_repmsg->last_xid); + ", last_xid="LPU64"\n", rootid->li_stc.u.e3s.l3s_ino, + req->rq_repmsg->last_committed, req->rq_repmsg->last_xid); } EXIT; @@ -139,11 +145,11 @@ static int send_getstatus(struct obd_import *imp, struct ll_fid *rootfid, return rc; } -/* This should be mdc_get_info("rootfid") */ -int mdc_getstatus(struct obd_export *exp, struct ll_fid *rootfid) +/* This should be mdc_get_info("rootid") */ +int mdc_getstatus(struct obd_export *exp, struct lustre_id *rootid) { - return send_getstatus(class_exp2cliimp(exp), rootfid, LUSTRE_IMP_FULL, - 0); + return send_getstatus(class_exp2cliimp(exp), rootid, + LUSTRE_IMP_FULL, 0); } int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, @@ -193,7 +199,7 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, RETURN (0); } -int mdc_getattr(struct obd_export *exp, struct ll_fid *fid, +int mdc_getattr(struct obd_export *exp, struct lustre_id *id, unsigned long valid, unsigned int ea_size, struct ptlrpc_request **request) { @@ -216,7 +222,7 @@ int mdc_getattr(struct obd_export *exp, struct ll_fid *fid, mdc_pack_secdesc(req, size[0]); body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body)); - memcpy(&body->fid1, fid, sizeof(*fid)); + memcpy(&body->id1, id, sizeof(*id)); body->valid = valid; body->eadatasize = ea_size; @@ -230,7 +236,7 @@ int mdc_getattr(struct obd_export *exp, struct ll_fid *fid, RETURN (rc); } -int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid, +int mdc_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) { @@ -249,7 +255,7 @@ int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid, mdc_pack_secdesc(req, size[0]); body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body)); - memcpy(&body->fid1, fid, sizeof(*fid)); + memcpy(&body->id1, id, sizeof(*id)); body->valid = valid; body->eadatasize = ea_size; @@ -284,9 +290,9 @@ int mdc_store_inode_generation(struct obd_export *exp, LASSERT (rec != NULL); LASSERT (body != NULL); - 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); + memcpy(&rec->cr_replayid, &body->id1, sizeof(rec->cr_replayid)); + DEBUG_REQ(D_HA, req, "storing generation for ino "DLID4, + OLID4(&rec->cr_replayid)); return 0; } @@ -331,6 +337,7 @@ 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); @@ -339,12 +346,33 @@ 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); - rc = obd_unpackmd(exp_mdc, (void *) &md->mea, - (void *) mea, mdsize); + /* + * 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); 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); } @@ -442,7 +470,7 @@ int mdc_set_open_replay_data(struct obd_export *exp, mod->mod_och = och; mod->mod_open_req = open_req; - memcpy(&rec->cr_replayfid, &body->fid1, sizeof rec->cr_replayfid); + memcpy(&rec->cr_replayid, &body->id1, sizeof rec->cr_replayid); open_req->rq_replay_cb = mdc_replay_open; open_req->rq_commit_cb = mdc_commit_open; open_req->rq_cb_data = mod; @@ -645,13 +673,16 @@ 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_fid(&body->fid1, obdo->o_id, 0, obdo->o_mode); + 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->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]); @@ -660,7 +691,8 @@ int mdc_done_writing(struct obd_export *exp, struct obdo *obdo) RETURN(rc); } -int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, +int mdc_readpage(struct obd_export *exp, + struct lustre_id *id, __u64 offset, struct page *page, struct ptlrpc_request **request) { @@ -671,7 +703,7 @@ int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, int rc, size[2] = {0, sizeof(*body)}; ENTRY; - CDEBUG(D_INODE, "inode: %ld\n", (long)mdc_fid->id); + CDEBUG(D_INODE, "inode: %ld\n", (long)id->li_stc.u.e3s.l3s_ino); size[0] = mdc_get_secdesc_size(); @@ -690,8 +722,7 @@ int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, /* 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, mdc_fid); + mdc_readdir_pack(req, 1, offset, PAGE_CACHE_SIZE, id); req->rq_replen = lustre_msg_size(1, &size[1]); rc = ptlrpc_queue_wait(req); @@ -738,6 +769,15 @@ 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) @@ -790,10 +830,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_num") && strcmp(key, "mds_num") == 0) { + } else if (keylen >= strlen("mds_type") && strcmp(key, "mds_type") == 0) { struct ptlrpc_request *req; - int rc, size[2] = {keylen, vallen}; char *bufs[2] = {key, val}; + int rc, size[2] = {keylen, vallen}; req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION, OST_SET_INFO, 2, size, bufs); @@ -872,8 +912,11 @@ 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)); - mdc_pack_fid(&body->fid1, ino, gen, type); + 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->flags = flag; req->rq_replen = lustre_msg_size(1, &size[1]); @@ -944,7 +987,7 @@ static int mdc_unpin(struct obd_export *exp, RETURN(rc); } -int mdc_sync(struct obd_export *exp, struct ll_fid *fid, +int mdc_sync(struct obd_export *exp, struct lustre_id *id, struct ptlrpc_request **request) { struct ptlrpc_request *req; @@ -962,10 +1005,10 @@ int mdc_sync(struct obd_export *exp, struct ll_fid *fid, //mdc_pack_secdesc(req, size[0]); - if (fid) { + if (id) { body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body)); - memcpy(&body->fid1, fid, sizeof(*fid)); + memcpy(&body->id1, id, sizeof(*id)); } req->rq_replen = lustre_msg_size(1, &size[1]); @@ -1137,40 +1180,56 @@ 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 *vallen, void *val) + void *key, __u32 *valsize, void *val) { + struct ptlrpc_request *req; + char *bufs[1] = {key}; + int rc = 0; ENTRY; - if (!vallen || !val) + + if (!valsize || !val) RETURN(-EFAULT); - 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("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, vallen); - rc = ptlrpc_queue_wait(req); - if (rc) - GOTO(out, rc); + req->rq_replen = lustre_msg_size(1, valsize); + rc = ptlrpc_queue_wait(req); + if (rc) + GOTO(out_req, rc); - /* FIXME: right swap routine here! */ - reply = lustre_swab_repbuf(req, 0, sizeof(*reply), NULL); + 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 mdsize\n"); - GOTO(out, rc = -EPROTO); + CERROR("Can't unpack %s\n", (char *)key); + GOTO(out_req, rc = -EPROTO); + } + + *(struct lustre_id *)val = *reply; + } else { + __u32 *reply; + + reply = lustre_swab_repbuf(req, 0, sizeof(*reply), + lustre_swab_generic_32s); + if (reply == NULL) { + CERROR("Can't unpack %s\n", (char *)key); + GOTO(out_req, rc = -EPROTO); } *((__u32 *)val) = *reply; - out: - ptlrpc_req_finished(req); - RETURN(rc); } - RETURN(-EINVAL); +out_req: + ptlrpc_req_finished(req); + RETURN(rc); } int mdc_obj_create(struct obd_export *exp, struct obdo *oa, @@ -1285,7 +1344,8 @@ int mdc_brw(int rw, struct obd_export *exp, struct obdo *oa, return 0; } -static int mdc_valid_attrs(struct obd_export *exp, struct ll_fid *fid) +static int mdc_valid_attrs(struct obd_export *exp, + struct lustre_id *id) { struct ldlm_res_id res_id = { .name = {0} }; struct obd_device *obd = exp->exp_obd; @@ -1294,11 +1354,12 @@ static int mdc_valid_attrs(struct obd_export *exp, struct ll_fid *fid) int flags; ENTRY; - res_id.name[0] = fid->id; - res_id.name[1] = fid->generation; + res_id.name[0] = id_fid(id); + res_id.name[1] = id_group(id); 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; @@ -1315,12 +1376,15 @@ static int mdc_valid_attrs(struct obd_export *exp, struct ll_fid *fid) } RETURN(0); } -static int mdc_change_cbdata_name(struct obd_export *exp, struct ll_fid *pfid, - char *name, int len, struct ll_fid *cfid, + +static int mdc_change_cbdata_name(struct obd_export *exp, + struct lustre_id *pid, + char *name, int len, + struct lustre_id *cid, ldlm_iterator_t it, void *data) { int rc; - rc = mdc_change_cbdata(exp, cfid, it, data); + rc = mdc_change_cbdata(exp, cid, it, data); RETURN(rc); } diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index d827236..a77cffe 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -178,16 +178,20 @@ 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 (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. */ + /* + * 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. + */ 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; @@ -198,20 +202,24 @@ 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 %u/%u\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 %lu/%lu\n", obd->obd_name, - (unsigned) dentry->d_inode->i_ino, - (unsigned) dentry->d_inode->i_generation); + (unsigned long)dentry->d_inode->i_ino, + (unsigned long)dentry->d_inode->i_generation); ret_mode = LCK_EX; } } @@ -220,24 +228,22 @@ int mds_lock_mode_for_dir(struct obd_device *obd, } /* only valid locked dentries or errors should be returned */ -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 *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 mds_obd *mds = &obd->u.mds; - struct dentry *de = mds_fid2dentry(mds, fid, mnt), *retval = de; + struct dentry *de = mds_id2dentry(obd, id, mnt), *retval = de; + ldlm_policy_data_t policy = { .l_inodebits = { lockpart } }; 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] = de->d_inode->i_ino; - res_id.name[1] = de->d_inode->i_generation; + res_id.name[0] = id_fid(id); + res_id.name[1] = id_group(id); lockh[1].cookie = 0; #ifdef S_PDIROPS if (name && IS_PDIROPS(de->d_inode)) { @@ -261,17 +267,16 @@ struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid, res_id.name[2] = full_name_hash(name, namelen); - CDEBUG(D_INFO, "take lock on %lu:%u:"LPX64"\n", - de->d_inode->i_ino, de->d_inode->i_generation, - res_id.name[2]); + CDEBUG(D_INFO, "take lock on "DLID4":"LPX64"\n", + OLID4(id), 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 */ @@ -289,29 +294,31 @@ struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid, #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_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, - 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_id2dentry(struct obd_device *obd, struct lustre_id *id, + struct vfsmount **mnt) { - char fid_name[32]; - unsigned long ino = fid->id; - __u32 generation = fid->generation; + char idname[32]; 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); - CDEBUG(D_DENTRY, "--> mds_fid2dentry: ino/gen %lu/%u, sb %p\n", + snprintf(idname, sizeof(idname), "0x%lx", ino); + + CDEBUG(D_DENTRY, "--> mds_id2dentry: 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(fid_name, mds->mds_fid_de, strlen(fid_name)); + /* 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)); if (IS_ERR(result)) RETURN(result); @@ -328,8 +335,8 @@ struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, /* here we disabled generation check, as root inode i_generation * of cache mds and real mds are different. */ - if (inode->i_ino != mds->mds_rootfid.id && generation && - inode->i_generation != generation) { + if (inode->i_ino != id_ino(&mds->mds_rootid) && 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, @@ -350,42 +357,45 @@ struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, /* 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 connect_flags) + struct obd_uuid *cluuid, unsigned long flags) { - struct obd_export *exp; - struct mds_export_data *med; /* */ + struct mds_obd *mds = &obd->u.mds; + struct mds_export_data *med; struct mds_client_data *mcd; + struct obd_export *exp; 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); + + LASSERT(exp != NULL); med = &exp->exp_mds_data; OBD_ALLOC(mcd, sizeof(*mcd)); if (!mcd) { - CERROR("mds: out of memory for client data\n"); + CERROR("%s: out of memory for client data.\n", + obd->obd_name); GOTO(out, rc = -ENOMEM); } @@ -395,9 +405,8 @@ 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 (!(connect_flags & OBD_OPT_MDS_CONNECTION)) { - struct mds_obd *mds = &obd->u.mds; + + if (!(flags & OBD_OPT_MDS_CONNECTION)) { 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", @@ -408,15 +417,16 @@ 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); } - class_export_put(exp); - - return rc; + RETURN(rc); } static int mds_init_export(struct obd_export *exp) @@ -484,15 +494,13 @@ 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); - class_export_get(exp); - + LASSERT(exp != NULL); obd = class_exp2obd(exp); if (obd == NULL) { CDEBUG(D_IOCTL, "invalid client cookie "LPX64"\n", @@ -501,14 +509,22 @@ 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", @@ -520,7 +536,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); @@ -538,8 +554,6 @@ 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); } @@ -547,9 +561,11 @@ static int mds_getstatus(struct ptlrpc_request *req) { struct mds_obd *mds = mds_req2mds(req); struct mds_body *body; - int rc, size = sizeof(*body); + int rc, size; 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); @@ -557,11 +573,14 @@ static int mds_getstatus(struct ptlrpc_request *req) RETURN(-ENOMEM); } - body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); - memcpy(&body->fid1, &mds->mds_rootfid, sizeof(body->fid1)); + body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); + + body->valid |= OBD_MD_FID; + memcpy(&body->id1, &mds->mds_rootid, sizeof(body->id1)); - /* 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); } @@ -579,11 +598,13 @@ 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); @@ -699,24 +720,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 mds_body *body; struct inode *inode = dentry->d_inode; + struct mds_body *body; int rc = 0; ENTRY; @@ -727,50 +748,49 @@ 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) { - 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; + mds_pack_dentry2body(obd, body, dentry, + (reqbody->valid & OBD_MD_FID)); + CDEBUG(D_OTHER, "cross reference: "DLID4"\n", + OLID4(&body->id1)); RETURN(0); } - mds_pack_inode2fid(obd, &body->fid1, inode); - mds_pack_inode2body(obd, body, inode); + + mds_pack_inode2body(obd, body, inode, (reqbody->valid & OBD_MD_FID)); 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) { - char *symname = lustre_msg_buf(req->rq_repmsg, reply_off + 1,0); - int len; + int len = req->rq_repmsg->buflens[reply_off + 1]; + char *symname = lustre_msg_buf(req->rq_repmsg, reply_off + 1, 0); - LASSERT (symname != NULL); /* caller prepped reply */ - len = req->rq_repmsg->buflens[reply_off + 1]; + LASSERT(symname != NULL); /* caller prepped reply */ - 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; + if (!inode->i_op->readlink) { + rc = -ENOSYS; } else { - 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; + 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; + } } } @@ -796,9 +816,8 @@ 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, @@ -856,9 +875,8 @@ 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, @@ -867,19 +885,21 @@ 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; - i = mea_name2idx(mea, name, namelen - 1); - if (mea->mea_master != mea->mea_fids[i].mds) { + /* + * 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])) { CDEBUG(D_OTHER, - "inapropriate MDS(%d) for %s. should be %d(%d)\n", - mea->mea_master, name, mea->mea_fids[i].mds, i); + "inapropriate MDS(%d) for %s. should be " + "%lu(%d)\n", mea->mea_master, name, + (unsigned long)id_group(&mea->mea_ids[i]), i); rc = -ERESTART; } } @@ -907,7 +927,6 @@ 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); @@ -917,7 +936,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) { @@ -939,7 +958,6 @@ 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; @@ -964,18 +982,21 @@ 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_fid2dentry(mds, &body->fid1, NULL); + + dparent = mds_id2dentry(obd, &body->id1, 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"); @@ -988,7 +1009,8 @@ 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)); - mds_reply->fid1.id = inum; + + id_ino(&mds_reply->id1) = inum; mds_reply->valid = OBD_MD_FLID; GOTO(cleanup, rc); } @@ -996,7 +1018,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->fid1, + rc = mds_get_parent_child_locked(obd, mds, &body->id1, parent_lockh, &dparent, LCK_PR, MDS_INODELOCK_LOOKUP, @@ -1009,20 +1031,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) body->fid1.id, - (unsigned long) body->fid1.generation); + obd->obd_name, (unsigned long)id_ino(&body->id1), + (unsigned long)id_gen(&body->id1)); #if 0 - dchild = mds_fid2locked_dentry(obd, &body->fid1, NULL, - LCK_PR, parent_lockh, - &update_mode, - NULL, 0, child_part); + dchild = mds_id2locked_dentry(obd, &body->id1, NULL, + LCK_PR, parent_lockh, + &update_mode, + NULL, 0, child_part); #else - dchild = mds_fid2locked_dentry(obd, &body->fid1, NULL, - LCK_PR, parent_lockh, - &update_mode, - NULL, 0, - MDS_INODELOCK_UPDATE); + dchild = mds_id2locked_dentry(obd, &body->id1, NULL, + LCK_PR, parent_lockh, + &update_mode, + NULL, 0, + MDS_INODELOCK_UPDATE); #endif if (IS_ERR(dchild)) { CERROR("can't find inode: %d\n", @@ -1047,31 +1069,33 @@ 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"/%u lockh "LPX64"\n", - body->fid1.id, body->fid1.generation, + LASSERTF(granted_lock != NULL, LPU64"/%lu lockh "LPX64"\n", + id_fid(&body->id1), (unsigned long)id_group(&body->id1), child_lockh->cookie); - 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); + 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; } 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 { @@ -1112,15 +1136,14 @@ 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; @@ -1135,7 +1158,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"); @@ -1151,7 +1174,7 @@ static int mds_getattr(struct ptlrpc_request *req, int offset) } push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc); - de = mds_fid2dentry(mds, &body->fid1, NULL); + de = mds_id2dentry(obd, &body->id1, NULL); if (IS_ERR(de)) { rc = req->rq_status = PTR_ERR(de); GOTO(out_pop, rc); @@ -1170,13 +1193,14 @@ 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); @@ -1184,7 +1208,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) @@ -1209,10 +1233,9 @@ 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) @@ -1233,8 +1256,8 @@ static int mds_sync(struct ptlrpc_request *req, int offset) GOTO(out, rc); } - if (body->fid1.id == 0) { - /* a fid of zero is taken to mean "sync whole filesystem" */ + if (id_ino(&body->id1) == 0) { + /* an id of zero is taken to mean "sync whole filesystem" */ rc = fsfilt_sync(obd, mds->mds_sb); if (rc) GOTO(out, rc); @@ -1243,22 +1266,21 @@ static int mds_sync(struct ptlrpc_request *req, int offset) struct file *file = mds->mds_rcvd_filp; struct dentry *de; - de = mds_fid2dentry(mds, &body->fid1, NULL); + de = mds_id2dentry(obd, &body->id1, 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_inode2fid(obd, &body->fid1, de->d_inode); - mds_pack_inode2body(obd, body, de->d_inode); + mds_pack_inode2body(obd, body, de->d_inode, 0); + l_dput(de); } out: req->rq_status = rc; - return 0; + RETURN(0); } /* mds_readpage does not take a DLM lock on the inode, because the client must @@ -1307,7 +1329,7 @@ static int mds_readpage(struct ptlrpc_request *req, int offset) } push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc); - de = mds_fid2dentry(mds, &body->fid1, &mnt); + de = mds_id2dentry(obd, &body->id1, &mnt); if (IS_ERR(de)) GOTO(out_pop, rc = PTR_ERR(de)); @@ -1352,11 +1374,95 @@ 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; /* 116 bytes on the stack? no sir! */ + struct mds_update_record *rec; struct mds_req_sec_desc *rsd; int rc; ENTRY; @@ -1386,7 +1492,6 @@ 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)); @@ -1431,19 +1536,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 ll_fid fid; + struct lustre_id id; + int rc; ENTRY; /* copy rc, transno and disp; steal locks */ @@ -1453,22 +1558,22 @@ static void reconstruct_create(struct ptlrpc_request *req) return; } - fid.mds = 0; - fid.id = mcd->mcd_last_data; - fid.generation = 0; + id_gen(&id) = 0; + id_group(&id) = 0; - LASSERT(fid.id != 0); + id_ino(&id) = mcd->mcd_last_data; + LASSERT(id_ino(&id) != 0); - dentry = mds_fid2dentry(mds, &fid, NULL); + dentry = mds_id2dentry(req2obd(req), &id, NULL); if (IS_ERR(dentry)) { - CERROR("can't find inode "LPU64"\n", fid.id); + CERROR("can't find inode "LPU64"\n", id_ino(&id)); req->rq_status = PTR_ERR(dentry); EXIT; return; } CWARN("reconstruct reply for x"LPU64" (remote ino) "LPU64" -> %lu/%u\n", - req->rq_xid, fid.id, dentry->d_inode->i_ino, + req->rq_xid, id_ino(&id), dentry->d_inode->i_ino, dentry->d_inode->i_generation); body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); @@ -1476,10 +1581,21 @@ 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) @@ -1487,13 +1603,16 @@ 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 fidname[LL_FID_NAMELEN]; + char idname[LL_ID_NAMELEN]; + int size = sizeof(*repbody); 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, rc, size = sizeof(*repbody), cleanup_phase = 0; + int mealen, flags = 0; struct lvfs_ucred uc; + struct lustre_id id; struct mea *mea; void *handle = NULL; unsigned long cr_inum = 0; @@ -1503,7 +1622,8 @@ 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); @@ -1525,32 +1645,57 @@ 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/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); + * 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); if (!IS_ERR(new) && new->d_inode) { - CDEBUG(D_HA, "mkdir() repairing is on its way: %lu/%lu\n", - (unsigned long) fid.id, - (unsigned long) fid.generation); + struct lustre_id sid; + + CWARN("mkdir() repairing is on its way: %lu/%lu\n", + (unsigned long)id_ino(&id), (unsigned long)id_gen(&id)); + 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("hmm. for some reason dir %lu/%lu (or reply) got lost\n", - (unsigned long) fid.id, (unsigned long) fid.generation); + CWARN("for some reason dir %lu/%lu (or reply) got lost\n", + (unsigned long)id_ino(&id), (unsigned long)id_gen(&id)); + LASSERT(new->d_inode == NULL || - new->d_inode->i_generation != fid.generation); + new->d_inode->i_generation != id_gen(&id)); + l_dput(new); } @@ -1558,16 +1703,18 @@ 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(fidname, "%u.%u", ll_insecure_random_int(), current->pid); - new = lookup_one_len(fidname, mds->mds_unnamed_dir, rc); + rc = sprintf(idname, "%u.%u", ll_insecure_random_int(), current->pid); + new = lookup_one_len(idname, mds->mds_unnamed_dir, rc); if (IS_ERR(new)) { CERROR("%s: can't lookup new inode (%s) for mkdir: %d\n", - obd->obd_name, fidname, (int) PTR_ERR(new)); + obd->obd_name, idname, (int) PTR_ERR(new)); fsfilt_commit(obd, mds->mds_sb, new->d_inode, handle, 0); up(&parent_inode->i_sem); RETURN(PTR_ERR(new)); @@ -1576,53 +1723,95 @@ 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); - 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); + + /* + * 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); + } } - + 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); @@ -1630,18 +1819,24 @@ 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, @@ -1650,7 +1845,14 @@ 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 */ - mds_try_to_split_dir(obd, new, NULL, body->oa.o_easize, LCK_EX); + 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; + } } cleanup: @@ -1659,7 +1861,8 @@ 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); @@ -1670,10 +1873,9 @@ cleanup: static int mdt_get_info(struct ptlrpc_request *req) { - char *key; struct obd_export *exp = req->rq_export; - int keylen, rc = 0, size = sizeof(obd_id); - obd_id *reply; + int keylen, rc = 0; + char *key; ENTRY; key = lustre_msg_buf(req->rq_reqmsg, 0, 1); @@ -1683,15 +1885,33 @@ static int mdt_get_info(struct ptlrpc_request *req) } keylen = req->rq_reqmsg->buflens[0]; - if (keylen < strlen("mdsize") || memcmp(key, "mdsize", 6) != 0) + if ((keylen < strlen("mdsize") || strcmp(key, "mdsize") != 0) && + (keylen < strlen("mdsnum") || strcmp(key, "mdsnum") != 0) && + (keylen < strlen("rootid") || strcmp(key, "rootid") != 0)) RETURN(-EPROTO); - rc = lustre_pack_reply(req, 1, &size, NULL); - if (rc) - RETURN(rc); + 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); + } - 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); } @@ -1701,7 +1921,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); @@ -1711,21 +1931,22 @@ 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 (KEY_IS("mds_num")) { + if (keylen >= strlen("mds_type") && + memcmp(key, "mds_type", keylen) == 0) { int valsize; __u32 group; - CDEBUG(D_IOCTL, "set mds num %d\n", *(int*)val); - mds->mds_num = *(int*)val; - group = FILTER_GROUP_FIRST_MDS + mds->mds_num; + + 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; valsize = sizeof(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); + + /* 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); RETURN(rc); } CDEBUG(D_IOCTL, "invalid key\n"); @@ -1746,27 +1967,19 @@ static int mdt_set_info(struct ptlrpc_request *req) } keylen = req->rq_reqmsg->buflens[0]; - if (keylen == strlen("mds_num") && - memcmp(key, "mds_num", keylen) == 0) { + if (keylen == strlen("mds_type") && + memcmp(key, "mds_type", 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); } @@ -1972,7 +2185,6 @@ 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)); @@ -2163,10 +2375,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). */ @@ -2193,6 +2405,187 @@ 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) { @@ -2223,9 +2616,11 @@ 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) @@ -2259,22 +2654,18 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf) } } - /* 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 && + mds->mds_obd_type = MDS_MASTER_OBD; + + if (lcfg->lcfg_inllen6 > 0 && lcfg->lcfg_inlbuf6 && strcmp(lcfg->lcfg_inlbuf6, "dumb")) { - 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; + 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; } } - 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)) { @@ -2285,11 +2676,12 @@ 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); @@ -2306,13 +2698,15 @@ 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; @@ -2326,6 +2720,20 @@ 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, @@ -2394,7 +2802,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_osc); + rc = mds_lov_connect(obd, lprof->lp_lov); if (rc) GOTO(err_cleanup, rc); @@ -2440,7 +2848,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_osc_exp, strlen("mds_conn"), "mds_conn", + rc = obd_set_info(mds->mds_lov_exp, strlen("mds_conn"), "mds_conn", valsize, &group); if (rc) GOTO(out, rc); @@ -2477,8 +2885,9 @@ int mds_lov_clean(struct obd_device *obd) if (mds->mds_profile) { char * cln_prof; - struct config_llog_instance cfg; + struct llog_ctxt *llctx; struct lvfs_run_ctxt saved; + struct config_llog_instance cfg; int len = strlen(mds->mds_profile) + sizeof("-clean") + 1; OBD_ALLOC(cln_prof, len); @@ -2488,8 +2897,9 @@ int mds_lov_clean(struct obd_device *obd) cfg.cfg_uuid = mds->mds_lov_uuid; push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - class_config_process_llog(llog_get_context(&obd->obd_llogs, LLOG_CONFIG_ORIG_CTXT), - cln_prof, &cfg); + llctx = llog_get_context(&obd->obd_llogs, + LLOG_CONFIG_ORIG_CTXT); + class_config_process_llog(llctx, cln_prof, &cfg); pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); OBD_FREE(cln_prof, len); @@ -2530,23 +2940,27 @@ 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) { - OBD_FREE(mds->mds_lov_objids, - mds->mds_lov_desc.ld_tgt_count * sizeof(obd_id)); + int size = mds->mds_lov_desc.ld_tgt_count * + sizeof(obd_id); + OBD_FREE(mds->mds_lov_objids, size); } 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); @@ -2676,9 +3090,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)); - intent_set_disposition(rep, DISP_IT_EXECD); + rep = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*rep)); + LASSERT(rep != NULL); + intent_set_disposition(rep, DISP_IT_EXECD); /* execute policy */ switch ((long)it->opc) { @@ -2754,7 +3169,6 @@ 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 @@ -2905,24 +3319,27 @@ static int mdt_cleanup(struct obd_device *obd, int flags) RETURN(0); } -static struct dentry *mds_lvfs_fid2dentry(__u64 id, __u32 gen, __u64 gr, - void *data) +static struct dentry *mds_lvfs_id2dentry(__u64 ino, __u32 gen, + __u64 gr, void *data) { + struct lustre_id id; struct obd_device *obd = data; - struct ll_fid fid; - fid.id = id; - fid.generation = gen; - return mds_fid2dentry(&obd->u.mds, &fid, NULL); + + id_ino(&id) = ino; + id_gen(&id) = gen; + return mds_id2dentry(obd, &id, NULL); } static int mds_get_info(struct obd_export *exp, __u32 keylen, - void *key, __u32 *vallen, void *val) + void *key, __u32 *valsize, 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); @@ -2930,34 +3347,47 @@ 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; - *vallen = sizeof(unsigned long); + *valsize = 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; - *vallen = sizeof(unsigned long); + *valsize = 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; - *vallen = sizeof(*mdsize); + *valsize = 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_fid2dentry: mds_lvfs_fid2dentry, + l_id2dentry: mds_lvfs_id2dentry, }; int mds_preprw(int cmd, struct obd_export *exp, struct obdo *oa, @@ -2965,6 +3395,7 @@ 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, @@ -3002,8 +3433,6 @@ 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 712b206..8c84f25 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -50,6 +50,7 @@ #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). @@ -189,6 +190,46 @@ 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; @@ -220,7 +261,8 @@ 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, LAST_RCVD); + CWARN("%s: initializing new %s\n", obd->obd_name, + file->f_dentry->d_name.name); memcpy(msd->msd_uuid, obd->obd_uuid.uuid,sizeof(msd->msd_uuid)); msd->msd_last_transno = 0; @@ -232,7 +274,8 @@ 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", LAST_RCVD, rc); + CERROR("error reading MDS %s: rc = %d\n", + file->f_dentry->d_name.name, rc); GOTO(err_msd, rc); } if (strcmp(msd->msd_uuid, obd->obd_uuid.uuid) != 0) { @@ -300,7 +343,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", - LAST_RCVD, cl_idx, off, rc); + file->f_dentry->d_name.name, cl_idx, off, rc); break; /* read error shouldn't cause startup to fail */ } @@ -374,26 +417,143 @@ 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 *de = mds_fid2dentry(mds, &mds->mds_rootfid, NULL); - int rc = 0; + struct dentry *dentry; + int rc = 0; - rc = fsfilt_post_setup(obd, de); + dentry = mds_id2dentry(obd, &mds->mds_rootid, NULL); + rc = fsfilt_post_setup(obd, dentry); if (rc) - GOTO(out, rc); + GOTO(out_dentry, rc); - fsfilt_set_fs_flags(obd, de->d_inode, - SM_DO_REC | SM_DO_COW); + fsfilt_set_fs_flags(obd, dentry->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: - l_dput(de); +out_dentry: + l_dput(dentry); 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; @@ -420,6 +580,7 @@ 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); @@ -427,12 +588,11 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt) GOTO(err_pop, rc); } - 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; + mdc_pack_id(&mds->mds_rootid, dentry->d_inode->i_ino, + dentry->d_inode->i_generation, S_IFDIR, 0, 0); dput(dentry); - + dentry = lookup_one_len("__iopen__", current->fs->pwd, strlen("__iopen__")); if (IS_ERR(dentry)) { @@ -440,18 +600,19 @@ 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_fid, rc); + GOTO(err_id_de, 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_fid, rc); + GOTO(err_id_de, rc); } mds->mds_pending_dir = dentry; @@ -475,9 +636,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_fids, rc); + GOTO(err_objects, rc); } - mds->mds_fids_dir = dentry; + mds->mds_id_dir = dentry; dentry = simple_mkdir(current->fs->pwd, "UNNAMED", 0777, 1); if (IS_ERR(dentry)) { @@ -492,9 +653,10 @@ 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_objects, rc = PTR_ERR(file)); + GOTO(err_id_dir, 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); @@ -507,12 +669,33 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt) GOTO(err_last_rcvd, rc); } - /* open and test the lov objd file */ + /* 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 */ 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_client, rc = PTR_ERR(file)); + GOTO(err_last_fid, rc = PTR_ERR(file)); } mds->mds_lov_objid_filp = file; if (!S_ISREG(file->f_dentry->d_inode->i_mode)) { @@ -532,6 +715,9 @@ 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: @@ -539,16 +725,16 @@ err_last_rcvd: CERROR("can't close %s after error\n", LAST_RCVD); err_unnamed: dput(mds->mds_unnamed_dir); -err_fids: - dput(mds->mds_fids_dir); +err_id_dir: + dput(mds->mds_id_dir); err_objects: dput(mds->mds_objects_dir); err_logs: dput(mds->mds_logs_dir); err_pending: dput(mds->mds_pending_dir); -err_fid: - dput(mds->mds_fid_de); +err_id_de: + dput(mds->mds_id_de); goto err_pop; } @@ -574,11 +760,17 @@ 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); @@ -590,9 +782,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_fids_dir != NULL) { - l_dput(mds->mds_fids_dir); - mds->mds_fids_dir = NULL; + if (mds->mds_id_dir != NULL) { + l_dput(mds->mds_id_dir); + mds->mds_id_dir = NULL; } if (mds->mds_objects_dir != NULL) { l_dput(mds->mds_objects_dir); @@ -609,15 +801,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_fid_de); - dput(mds->mds_fid_de); + shrink_dcache_parent(mds->mds_id_de); + dput(mds->mds_id_de); return rc; } -/* Creates an object with the same name as its fid. Because this is not at all +/* Creates an object with the same name as its id. Because this is not at all * performance sensitive, it is accomplished by creating a file, checking the - * fid, and renaming it. */ + * id, and renaming it. */ int mds_obd_create(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md **ea, struct obd_trans_info *oti) { @@ -626,17 +818,16 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa, struct file *filp; struct dentry *dchild; struct lvfs_run_ctxt saved; - char fidname[LL_FID_NAMELEN]; + char idname[LL_ID_NAMELEN]; + int rc = 0, err, idlen; 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) { - namelen = ll_fid2str(fidname, oa->o_id, oa->o_generation); - - dchild = lookup_one_len(fidname, mds->mds_objects_dir, namelen); + idlen = ll_id2str(idname, oa->o_id, oa->o_generation); + dchild = lookup_one_len(idname, mds->mds_objects_dir, idlen); if (IS_ERR(dchild)) GOTO(out_pop, rc = PTR_ERR(dchild)); @@ -669,16 +860,17 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa, GOTO(out_pop, rc); } - sprintf(fidname, "OBJECTS/%u.%u",ll_insecure_random_int(),current->pid); - filp = filp_open(fidname, O_CREAT | O_EXCL, 0644); + sprintf(idname, "OBJECTS/%u.%u", ll_insecure_random_int(), current->pid); + filp = filp_open(idname, O_CREAT | O_EXCL, 0644); if (IS_ERR(filp)) { rc = PTR_ERR(filp); if (rc == -EEXIST) { CERROR("impossible object name collision %s\n", - fidname); + idname); LBUG(); } - CERROR("error creating tmp object %s: rc %d\n", fidname, rc); + CERROR("error creating tmp object %s: rc %d\n", + idname, rc); GOTO(out_pop, rc); } @@ -686,11 +878,12 @@ 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; - 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); + idlen = ll_id2str(idname, oa->o_id, oa->o_generation); + + CWARN("created log anonymous "LPU64"/%u\n", + oa->o_id, oa->o_generation); + 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)); @@ -726,7 +919,7 @@ out_dput: out_close: err = filp_close(filp, 0); if (err) { - CERROR("closing tmpfile %s: rc %d\n", fidname, rc); + CERROR("closing tmpfile %s: rc %d\n", idname, rc); if (!rc) rc = err; } @@ -743,22 +936,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 fidname[LL_FID_NAMELEN]; + char idname[LL_ID_NAMELEN]; struct dentry *de; void *handle; - int err, namelen, rc = 0; + int err, idlen, rc = 0; ENTRY; push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - namelen = ll_fid2str(fidname, oa->o_id, oa->o_generation); + idlen = ll_id2str(idname, oa->o_id, oa->o_generation); down(&parent_inode->i_sem); - de = lookup_one_len(fidname, mds->mds_objects_dir, namelen); + de = lookup_one_len(idname, mds->mds_objects_dir, idlen); 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, fidname, rc); + oa->o_id, idname, 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 5231255..33aba61 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,18 +172,17 @@ 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 *hash = &_group_hash; struct mds_grp_hash_entry *entry = NULL, *new = NULL, *next; + struct mds_grp_hash *hash = &_group_hash; 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); @@ -224,7 +223,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); @@ -236,8 +235,10 @@ 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); @@ -267,15 +268,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); @@ -290,7 +291,6 @@ 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 3d4750e..19fd8cd 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 ll_fid *fid, + struct lustre_id *id, struct lustre_handle *parent_lockh, struct dentry **dparentp, int parent_mode, __u64 parent_lockpart, int *update_mode, @@ -187,20 +187,59 @@ 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); -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 *); + +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); #endif /* mds/mds_lmv.c */ diff --git a/lustre/mds/mds_lib.c b/lustre/mds/mds_lib.c index 0e2f69d..b4449eb 100644 --- a/lustre/mds/mds_lib.c +++ b/lustre/mds/mds_lib.c @@ -49,8 +49,6 @@ #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) { @@ -145,7 +143,6 @@ int groups_search(struct group_info *ginfo, gid_t grp) } return 0; } - #endif void groups_from_buffer(struct group_info *ginfo, __u32 *gids) @@ -161,48 +158,74 @@ void groups_from_buffer(struct group_info *ginfo, __u32 *gids) } } -void mds_pack_dentry2fid(struct ll_fid *fid, struct dentry *dentry) +void mds_pack_dentry2id(struct obd_device *obd, + struct lustre_id *id, + struct dentry *dentry, + int read_fid) { - fid->id = dentry->d_inum; - fid->generation = dentry->d_generation; - fid->mds = dentry->d_mdsnum; + 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; + } } -void mds_pack_dentry2body(struct mds_body *b, struct dentry *dentry) +void mds_pack_dentry2body(struct obd_device *obd, + struct mds_body *b, + struct dentry *dentry, + int 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; + 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); } -void mds_pack_inode2fid(struct obd_device *obd, struct ll_fid *fid, - struct inode *inode) +int mds_pack_inode2id(struct obd_device *obd, + struct lustre_id *id, + struct inode *inode, + int read_fid) { - if (!obd || !fid || !inode) { - printk("obd %p, fid %p, inode %p\n", obd, fid, inode); - LBUG(); + 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); } - 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; + RETURN(rc); } /* 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) + struct inode *inode, int read_fid) { 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; - - b->ino = inode->i_ino; + 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->atime = LTIME_S(inode->i_atime); b->mtime = LTIME_S(inode->i_mtime); b->ctime = LTIME_S(inode->i_ctime); @@ -213,6 +236,7 @@ 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; @@ -221,8 +245,9 @@ void mds_pack_inode2body(struct obd_device *obd, struct mds_body *b, } else { b->nlink = inode->i_nlink; } - b->generation = inode->i_generation; - b->mds = obd->u.mds.mds_num; + if (read_fid) + b->valid |= OBD_MD_FID; + mds_pack_inode2id(obd, &b->id1, inode, read_fid); } /* unpacking */ @@ -238,7 +263,7 @@ static int mds_setattr_unpack(struct ptlrpc_request *req, int offset, if (rec == NULL) RETURN (-EFAULT); - r->ur_fid1 = &rec->sa_fid; + r->ur_id1 = &rec->sa_id; attr->ia_valid = rec->sa_valid; attr->ia_mode = rec->sa_mode; attr->ia_uid = rec->sa_uid; @@ -259,7 +284,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); @@ -280,8 +305,8 @@ static int mds_create_unpack(struct ptlrpc_request *req, int offset, if (rec == NULL) RETURN (-EFAULT); - r->ur_fid1 = &rec->cr_fid; - r->ur_fid2 = &rec->cr_replayfid; + r->ur_id1 = &rec->cr_id; + r->ur_id2 = &rec->cr_replayid; r->ur_mode = rec->cr_mode; r->ur_rdev = rec->cr_rdev; r->ur_time = rec->cr_time; @@ -331,8 +356,8 @@ static int mds_link_unpack(struct ptlrpc_request *req, int offset, if (rec == NULL) RETURN (-EFAULT); - r->ur_fid1 = &rec->lk_fid1; - r->ur_fid2 = &rec->lk_fid2; + r->ur_id1 = &rec->lk_id1; + r->ur_id2 = &rec->lk_id2; r->ur_time = rec->lk_time; LASSERT_REQSWAB (req, offset + 1); @@ -355,8 +380,8 @@ static int mds_unlink_unpack(struct ptlrpc_request *req, int offset, RETURN(-EFAULT); r->ur_mode = rec->ul_mode; - r->ur_fid1 = &rec->ul_fid1; - r->ur_fid2 = &rec->ul_fid2; + r->ur_id1 = &rec->ul_id1; + r->ur_id2 = &rec->ul_id2; r->ur_time = rec->ul_time; LASSERT_REQSWAB (req, offset + 1); @@ -378,8 +403,8 @@ static int mds_rename_unpack(struct ptlrpc_request *req, int offset, if (rec == NULL) RETURN(-EFAULT); - r->ur_fid1 = &rec->rn_fid1; - r->ur_fid2 = &rec->rn_fid2; + r->ur_id1 = &rec->rn_id1; + r->ur_id2 = &rec->rn_id2; r->ur_time = rec->rn_time; LASSERT_REQSWAB (req, offset + 1); @@ -407,8 +432,8 @@ static int mds_open_unpack(struct ptlrpc_request *req, int offset, if (rec == NULL) RETURN (-EFAULT); - r->ur_fid1 = &rec->cr_fid; - r->ur_fid2 = &rec->cr_replayfid; + r->ur_id1 = &rec->cr_id; + r->ur_id2 = &rec->cr_replayid; r->ur_mode = rec->cr_mode; r->ur_rdev = rec->cr_rdev; r->ur_time = rec->cr_time; @@ -450,10 +475,12 @@ 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); @@ -467,7 +494,10 @@ 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 df80c75..34a6178 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,7 +71,8 @@ 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); @@ -90,8 +91,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); @@ -99,8 +100,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); @@ -132,9 +133,11 @@ 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); } @@ -145,24 +148,52 @@ 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 != 0); - mds->mds_lmv_connected = 0; + LASSERT(mds->mds_lmv_connected); + obd_register_observer(mds->mds_lmv_obd, NULL); - /* if obd_disconnect fails (probably because the export was - * disconnected by class_disconnect_exports) then we just need - * to drop our ref. */ + 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; 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); } @@ -200,12 +231,13 @@ 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) + 12 + DIR_ROUND) & ~DIR_ROUND) +#define DIR_REC_LEN(name_len) (((name_len) + 16 + DIR_ROUND) & ~DIR_ROUND) /* this struct holds dir entries for particular MDS to be flushed */ struct dir_cache { @@ -249,26 +281,43 @@ 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->mds = dentry->d_mdsnum; + de->fid = dentry->d_fid; de->ino = dentry->d_inum; + de->mds = dentry->d_mdsnum; de->generation = dentry->d_generation; } else { CERROR("can't lookup %*s\n", de->namelen, de->name); @@ -343,11 +392,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); @@ -360,8 +409,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; @@ -371,8 +420,8 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset, 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); } @@ -415,7 +464,7 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset, } 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; @@ -427,7 +476,9 @@ 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)) { @@ -489,9 +540,8 @@ 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) { @@ -501,7 +551,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) @@ -516,7 +566,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 == mds->mds_rootfid.id) + if (dentry->d_inode->i_ino == id_ino(&mds->mds_rootid)) return MDS_NO_SPLITTABLE; /* large enough to be splitted? */ @@ -529,14 +579,13 @@ 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; } - if (mea) - OBD_FREE(mea, size); - RETURN(rc); + return rc; } /* @@ -550,11 +599,13 @@ 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) @@ -584,7 +635,7 @@ int mds_try_to_split_dir(struct obd_device *obd, struct dentry *dentry, RETURN(rc); } if (*mea == NULL) - RETURN(-EINVAL); + RETURN(-ENOMEM); (*mea)->mea_count = nstripes; @@ -605,14 +656,27 @@ 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) + if (rc) { + CERROR("Can't create remote inode, rc = %d\n", 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 */ @@ -624,7 +688,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); @@ -673,9 +737,9 @@ static int filter_start_page_write(struct inode *inode, return 0; } -struct dentry *filter_fid2dentry(struct obd_device *obd, - struct dentry *dir_dentry, - obd_gr group, obd_id id); +struct dentry *filter_id2dentry(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, @@ -683,25 +747,28 @@ 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 ll_fid fid; + struct lustre_id id; ENTRY; LASSERT(objcount == 1); LASSERT(obj->ioo_bufcnt > 0); memset(res, 0, niocount * sizeof(*res)); - fid.id = obj->ioo_id; - fid.generation = obj->ioo_gr; - dentry = mds_fid2dentry(mds, &fid, NULL); + 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); if (IS_ERR(dentry)) { CERROR("can't get dentry for "LPU64"/%u: %d\n", - fid.id, fid.generation, (int) PTR_ERR(dentry)); + id.li_stc.u.e3s.l3s_ino, id.li_stc.u.e3s.l3s_gen, + (int)PTR_ERR(dentry)); GOTO(cleanup, rc = (int) PTR_ERR(dentry)); } @@ -777,12 +844,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->generation, de->mds, + de->fid); 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, @@ -828,6 +895,8 @@ 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); @@ -835,38 +904,44 @@ 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); - OBD_ALLOC(*rlockh, sizeof(struct lustre_handle) * mea->mea_count); + handle_size = sizeof(struct lustre_handle) * + mea->mea_count; + + OBD_ALLOC(*rlockh, handle_size); 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); @@ -1035,12 +1110,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 %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); + 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); if (IS_ERR(dentry)) { CERROR("can't find inode: %d\n", (int) PTR_ERR(dentry)); GOTO(cleanup, rc = PTR_ERR(dentry)); @@ -1091,7 +1166,10 @@ int mds_convert_mea_ea(struct obd_device *obd, struct inode *inode, RETURN(0); old = (struct mea_old *) lmm; - rc = sizeof(struct ll_fid) * old->mea_count + sizeof(struct mea_old); + + rc = sizeof(struct lustre_id) * 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"); @@ -1101,9 +1179,12 @@ 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 ll_fid) * old->mea_count + sizeof(struct mea); + size = sizeof(struct lustre_id) * old->mea_count + + sizeof(struct mea); + OBD_ALLOC(new, size); if (new == NULL) RETURN(-ENOMEM); @@ -1112,7 +1193,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_fids[i] = old->mea_fids[i]; + new->mea_ids[i] = old->mea_ids[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 e2f4a96..8b95969 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_osc_obd; + struct obd_device *lov_obd = obd->u.mds.mds_lov_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_osc_obd; + struct obd_device *lov_obd = obd->u.mds.mds_lov_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_osc_obd; + struct obd_device *lov_obd = obd->u.mds.mds_lov_obd; struct llog_ctxt *lctxt; int rc; ENTRY; @@ -97,13 +97,12 @@ int mds_log_op_unlink(struct obd_device *obd, struct inode *inode, int lock_count = 0; ENTRY; - if (IS_ERR(mds->mds_osc_obd)) - RETURN(PTR_ERR(mds->mds_osc_obd)); + if (IS_ERR(mds->mds_lov_obd)) + RETURN(PTR_ERR(mds->mds_lov_obd)); RETURN(0); - rc = obd_unpackmd(mds->mds_osc_exp, &lsm, - lmm, lmm_size); + rc = obd_unpackmd(mds->mds_lov_exp, &lsm, lmm, lmm_size); if (rc < 0) RETURN(rc); @@ -123,7 +122,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_osc_exp, &lsm); + obd_free_memmd(mds->mds_lov_exp, &lsm); if (res && (rc <= 0 || lock_count == 0)) { OBD_FREE(lcl, size); @@ -145,7 +144,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_osc_obd; + struct obd_device *lov_obd = obd->u.mds.mds_lov_obd; int rc; ENTRY; @@ -168,7 +167,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_osc_obd; + struct obd_device *lov_obd = obd->u.mds.mds_lov_obd; int rc; ENTRY; diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index 322109d..e616677 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_osc_exp, &oa, &empty_ea, &oti); + rc = obd_create(mds->mds_lov_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_osc_exp, strlen("next_id"), "next_id", + rc = obd_set_info(mds->mds_lov_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_osc_exp, strlen("growth_count"), + rc = obd_set_info(mds->mds_lov_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_osc_obd)) - RETURN(PTR_ERR(mds->mds_osc_obd)); + if (IS_ERR(mds->mds_lov_obd)) + RETURN(PTR_ERR(mds->mds_lov_obd)); - if (mds->mds_osc_obd) + if (mds->mds_lov_obd) RETURN(0); spin_lock_init(&mds->mds_lov_lock); - mds->mds_osc_obd = class_name2obd(lov_name); - if (!mds->mds_osc_obd) { + mds->mds_lov_obd = class_name2obd(lov_name); + if (!mds->mds_lov_obd) { CERROR("MDS cannot locate LOV %s\n", lov_name); - mds->mds_osc_obd = ERR_PTR(-ENOTCONN); + mds->mds_lov_obd = ERR_PTR(-ENOTCONN); RETURN(-ENOTCONN); } CDEBUG(D_HA, "obd: %s osc: %s lov_name: %s\n", - obd->obd_name, mds->mds_osc_obd->obd_name, lov_name); + obd->obd_name, mds->mds_lov_obd->obd_name, lov_name); - rc = obd_connect(&conn, mds->mds_osc_obd, &obd->obd_uuid, + rc = obd_connect(&conn, mds->mds_lov_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_osc_obd = ERR_PTR(rc); + mds->mds_lov_obd = ERR_PTR(rc); RETURN(rc); } - mds->mds_osc_exp = class_conn2export(&conn); + mds->mds_lov_exp = class_conn2export(&conn); - rc = obd_register_observer(mds->mds_osc_obd, obd); + rc = obd_register_observer(mds->mds_lov_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_osc_exp); + rc = mds_lov_update_desc(obd, mds->mds_lov_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_osc_exp, strlen("last_id"), + rc = obd_get_info(mds->mds_lov_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_osc_obd, NULL); + obd_register_observer(mds->mds_lov_obd, NULL); err_discon: - obd_disconnect(mds->mds_osc_exp, 0); - mds->mds_osc_exp = NULL; - mds->mds_osc_obd = ERR_PTR(rc); + obd_disconnect(mds->mds_lov_exp, 0); + mds->mds_lov_exp = NULL; + mds->mds_lov_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_osc_obd) && mds->mds_osc_exp != NULL) { + if (!IS_ERR(mds->mds_lov_obd) && mds->mds_lov_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_osc_obd, NULL); + obd_register_observer(mds->mds_lov_obd, NULL); - rc = obd_disconnect(mds->mds_osc_exp, flags); + rc = obd_disconnect(mds->mds_lov_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_osc_exp); - mds->mds_osc_exp = NULL; - mds->mds_osc_obd = NULL; + class_export_put(mds->mds_lov_exp); + mds->mds_lov_exp = NULL; + mds->mds_lov_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_osc_exp, strlen("mds_conn"), + rc2 = obd_set_info(mds->mds_lov_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_osc_exp); + rc = mds_lov_update_desc(obd, mds->mds_lov_exp); if (rc) RETURN(rc); @@ -776,9 +776,8 @@ 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); @@ -810,11 +809,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_osc_exp, &lsm, lmm, lmm_size); + rc = obd_unpackmd(obd->u.mds.mds_lov_exp, &lsm, lmm, lmm_size); if (rc < 0) GOTO(conv_end, rc); - rc = obd_packmd(obd->u.mds.mds_osc_exp, &lmm, lsm); + rc = obd_packmd(obd->u.mds.mds_lov_exp, &lmm, lsm); if (rc < 0) GOTO(conv_free, rc); lmm_size = rc; @@ -832,7 +831,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_osc_exp, &lsm); + obd_free_memmd(obd->u.mds.mds_lov_exp, &lsm); conv_end: return rc; } @@ -842,7 +841,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_osc_exp; + struct obd_export *osc_exp = mds->mds_lov_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 eb0abeb..e9edf4a 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 (rec->ur_fid2->id); + LASSERT(id_ino(rec->ur_id2)); 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_osc_exp, + mds->mds_lov_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_osc_exp, oa, &lsm, &oti); + rc = obd_create(mds->mds_lov_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_osc_exp, + rc = obd_iocontrol(OBD_IOC_LOV_SETEA, mds->mds_lov_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_osc_exp, oa, lsm, &oti); + rc = obd_setattr(mds->mds_lov_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_osc_exp, &lmm, lsm); - if (!rec->ur_fid2->id) - obd_free_memmd(mds->mds_osc_exp, &lsm); + rc = obd_packmd(mds->mds_lov_exp, &lmm, lsm); + if (!id_ino(rec->ur_id2)) + obd_free_memmd(mds->mds_lov_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_osc_exp, &lmm); + obd_free_diskmd(mds->mds_lov_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_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)); + parent = mds_id2dentry(obd, rec->ur_id1, NULL); + LASSERTF(!IS_ERR(parent), "lid "DLID4" rc %ld\n", + OLID4(rec->ur_id1), PTR_ERR(parent)); - 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)); + 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)); 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); - mds_pack_inode2fid(obd, &body->fid1, dchild->d_inode); - mds_pack_inode2body(obd, body, dchild->d_inode); + /* get lock (write for O_CREAT, read otherwise) */ + mds_pack_inode2body(obd, body, dchild->d_inode, 0); if (S_ISREG(dchild->d_inode->i_mode)) { rc = mds_pack_md(obd, req->rq_repmsg, 2, body, dchild->d_inode, 1); @@ -690,50 +690,56 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild, RETURN(rc); } -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) +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) { struct mds_obd *mds = mds_req2mds(req); struct inode *pending_dir = mds->mds_pending_dir->d_inode; struct dentry *dchild; - char fidname[LL_FID_NAMELEN]; - int fidlen = 0, rc; + char idname[LL_ID_NAMELEN]; + int idlen = 0, rc; void *handle = NULL; ENTRY; down(&pending_dir->i_sem); - fidlen = ll_fid2str(fidname, fid->id, fid->generation); - dchild = lookup_one_len(fidname, mds->mds_pending_dir, fidlen); + + idlen = ll_id2str(idname, id_ino(id), id_gen(id)); + + dchild = lookup_one_len(idname, mds->mds_pending_dir, + idlen); if (IS_ERR(dchild)) { up(&pending_dir->i_sem); rc = PTR_ERR(dchild); - CERROR("error looking up %s in PENDING: rc = %d\n",fidname, rc); + CERROR("error looking up %s in PENDING: rc = %d\n", + idname, rc); RETURN(rc); } if (dchild->d_inode != NULL) { up(&pending_dir->i_sem); mds_inode_set_orphan(dchild->d_inode); - mds_pack_inode2fid(req2obd(req), &body->fid1, dchild->d_inode); - mds_pack_inode2body(req2obd(req), body, dchild->d_inode); + mds_pack_inode2body(req2obd(req), body, dchild->d_inode, 0); intent_set_disposition(rep, DISP_LOOKUP_EXECD); intent_set_disposition(rep, DISP_LOOKUP_POS); CWARN("Orphan %s found and opened in PENDING directory\n", - fidname); + idname); 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_fid2dentry(mds, fid, 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_id2dentry(req2obd(req), id, NULL); if (IS_ERR(dchild)) RETURN(PTR_ERR(dchild)); - mds_pack_inode2fid(req2obd(req), &body->fid1, dchild->d_inode); - mds_pack_inode2body(req2obd(req), body, dchild->d_inode); + mds_pack_inode2body(req2obd(req), body, dchild->d_inode, 0); intent_set_disposition(rep, DISP_LOOKUP_EXECD); intent_set_disposition(rep, DISP_LOOKUP_POS); @@ -764,13 +770,14 @@ 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_fid(req, &request_body->fid1, reply_body, - request_body->flags, NULL, NULL); + rc = mds_open_by_id(req, &request_body->id1, 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. */ @@ -796,6 +803,7 @@ int mds_lock_new_child(struct obd_device *obd, struct inode *inode, RETURN(rc); } +#endif static int is_mount_object(struct dentry *dparent) { @@ -831,9 +839,9 @@ int mds_open(struct mds_update_record *rec, int offset, int mea_size, update_mode; ENTRY; - 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); + 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); parent_lockh[0].cookie = 0; parent_lockh[1].cookie = 0; @@ -849,28 +857,30 @@ 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 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). */ + /* + * 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). + */ if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) { - 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); + 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); - LASSERT(rec->ur_fid2->id); + LASSERT(id_ino(rec->ur_id2)); - rc = mds_open_by_fid(req, rec->ur_fid2, body, rec->ur_flags, - rec, rep); + rc = mds_open_by_id(req, rec->ur_id2, 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(!rec->ur_fid2->id); + LASSERT(!id_ino(rec->ur_id2)); } LASSERT(offset == 3); /* If we got here, we must be called via intent */ @@ -892,24 +902,20 @@ int mds_open(struct mds_update_record *rec, int offset, } if (rec->ur_namelen == 1) { - /* 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); + /* 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); if (IS_ERR(dchild)) { rc = PTR_ERR(dparent); - CERROR("child lookup by a fid error %d\n", rc); + CERROR("child lookup by an id error %d\n", rc); GOTO(cleanup, rc); } goto got_child; } - 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); + 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); if (IS_ERR(dparent)) { rc = PTR_ERR(dparent); if (rc != -ENOENT) @@ -926,17 +932,19 @@ 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 != mea->mea_fids[i].mds) { + if (mea->mea_master != id_group(&mea->mea_ids[i])) { CDEBUG(D_OTHER, "%s: inapropriate MDS(%d) for %lu/%u:%s." - " should be %d(%d)\n", obd->obd_name, + " should be %lu(%d)\n", obd->obd_name, mea->mea_master, dparent->d_inode->i_ino, dparent->d_inode->i_generation, rec->ur_name, - mea->mea_fids[i].mds, i); + (unsigned long)id_group(&mea->mea_ids[i]), i); GOTO(cleanup, rc = -ERESTART); } } @@ -958,22 +966,20 @@ got_child: struct ldlm_res_id res_id = { . name = {0} }; ldlm_policy_data_t policy; int flags = 0; - 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; + + mds_pack_dentry2body(obd, body, dchild, 1); intent_set_disposition(rep, DISP_LOOKUP_POS); - res_id.name[0] = dchild->d_inum; - res_id.name[1] = dchild->d_generation; + + CDEBUG(D_OTHER, "cross reference: "DLID4"\n", + OLID4(&body->id1)); + + res_id.name[0] = dchild->d_fid; + res_id.name[1] = dchild->d_mdsnum; + 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 @@ -993,15 +999,21 @@ 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 = rec->ur_fid2->id; + unsigned long ino; struct iattr iattr; struct inode *inode; - rc = mds_try_to_split_dir(obd, dparent, &mea, 0, update_mode); + + ino = (unsigned long)id_ino(rec->ur_id2); + + 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); @@ -1011,7 +1023,10 @@ got_child: } if (!(rec->ur_flags & MDS_OPEN_CREAT)) { - /* It's negative and we weren't supposed to create it */ + /* + * dentry is negative and we weren't supposed to create + * object, get out of here. + */ GOTO(cleanup, rc = -ENOENT); } @@ -1027,7 +1042,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; @@ -1038,22 +1053,23 @@ got_child: inode = dchild->d_inode; if (ino) { LASSERT(ino == inode->i_ino); - /* Written as part of setattr */ - inode->i_generation = rec->ur_fid2->generation; + + /* written as part of setattr */ + inode->i_generation = id_gen(rec->ur_id2); CDEBUG(D_HA, "recreated ino %lu with gen %u\n", inode->i_ino, inode->i_generation); } created = 1; - LTIME_S(iattr.ia_atime) = rec->ur_time; - LTIME_S(iattr.ia_ctime) = rec->ur_time; - LTIME_S(iattr.ia_mtime) = rec->ur_time; + 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); - 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; @@ -1070,6 +1086,30 @@ 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); @@ -1077,14 +1117,20 @@ 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); @@ -1136,8 +1182,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: @@ -1192,8 +1238,8 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset, int unlink_orphan) { struct inode *inode = mfd->mfd_dentry->d_inode; - char fidname[LL_FID_NAMELEN]; - int last_orphan, fidlen, rc = 0, cleanup_phase = 0; + char idname[LL_ID_NAMELEN]; + int last_orphan, idlen, 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; @@ -1211,11 +1257,12 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset, reply_body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*reply_body)); - 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)); + 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)); + 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" */ @@ -1233,24 +1280,26 @@ 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", fidname); + " is over\n", idname); GOTO(out, rc); } - CDEBUG(D_HA, "destroying orphan object %s\n", fidname); + CDEBUG(D_HA, "destroying orphan object %s\n", idname); 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", - 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. */ + 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. + */ down(&pending_dir->i_sem); - cleanup_phase = 1; /* up(&pending_dir->i_sem) when finished */ - pending_child = lookup_one_len(fidname, mds->mds_pending_dir, - fidlen); + cleanup_phase = 1; /* up(i_sem) when finished */ + pending_child = lookup_one_len(idname, mds->mds_pending_dir, + idlen); if (IS_ERR(pending_child)) GOTO(cleanup, rc = PTR_ERR(pending_child)); LASSERT(pending_child->d_inode != NULL); @@ -1277,7 +1326,8 @@ 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",fidname,rc); + CERROR("error unlinking orphan %s: rc %d\n", + idname, rc); if (req != NULL && req->rq_repmsg != NULL && (reply_body->valid & OBD_MD_FLEASIZE) && @@ -1342,7 +1392,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", fidname, rc); + CERROR("error in setattr(%s): rc %d\n", idname, rc); } out: /* If other clients have this file open for write, rc will be > 0 */ @@ -1419,7 +1469,8 @@ 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->fid1.id, body->handle.cookie); + ": cookie "LPX64, body->id1.li_stc.u.e3s.l3s_ino, + body->handle.cookie); req->rq_status = -ESTALE; RETURN(-ESTALE); } @@ -1431,8 +1482,7 @@ int mds_close(struct ptlrpc_request *req, int offset) body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); LASSERT(body != NULL); - mds_pack_inode2fid(obd, &body->fid1, inode); - mds_pack_inode2body(obd, body, inode); + mds_pack_inode2body(obd, body, inode, 0); 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 1de982c..13e807a 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -44,12 +44,6 @@ #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; @@ -58,7 +52,6 @@ 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) { @@ -72,7 +65,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_osc_exp, &lsm, mlcd->mlcd_lmm, + rc = obd_unpackmd(obd->u.mds.mds_lov_exp, &lsm, mlcd->mlcd_lmm, mlcd->mlcd_eadatalen); if (rc < 0) { CERROR("bad LSM cancelling %d log cookies: rc %d\n", @@ -101,17 +94,16 @@ 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 log_pri = D_HA; + int err, 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(commit, rc); + GOTO(out_commit, rc); RETURN(rc); } @@ -149,9 +141,8 @@ 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_cb, NULL); + transno, handle, mds_commit_last_transno_cb, NULL); err = fsfilt_write_record(obd, mds->mds_rcvd_filp, mcd, sizeof(*mcd), &off, 0); @@ -166,6 +157,25 @@ 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; @@ -174,7 +184,7 @@ int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle, } CDEBUG(log_pri, "wrote objids: err = %d\n", err); -commit: +out_commit: err = fsfilt_commit(obd, mds->mds_sb, inode, handle, 0); if (err) { CERROR("error committing transaction: %d\n", err); @@ -214,7 +224,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); } @@ -346,21 +356,19 @@ 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_obd *obd = &req->rq_export->exp_obd->u.mds; - struct dentry *de; struct mds_body *body; + struct dentry *de; mds_req_from_mcd(req, med->med_mcd); - de = mds_fid2dentry(obd, rec->ur_fid1, NULL); + de = mds_id2dentry(req2obd(req), rec->ur_id1, 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_inode2fid(req2obd(req), &body->fid1, de->d_inode); - mds_pack_inode2body(req2obd(req), body, de->d_inode); + body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); + mds_pack_inode2body(req2obd(req), body, de->d_inode, 0); /* Don't return OST-specific attributes if we didn't just set them */ if (rec->ur_iattr.ia_valid & ATTR_SIZE) @@ -379,8 +387,7 @@ 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; @@ -391,28 +398,30 @@ 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, locked = 0; + int rc = 0, cleanup_phase = 0, err; + int locked = 0; ENTRY; LASSERT(offset == 1); - DEBUG_REQ(D_INODE, req, "setattr "LPU64"/%u %x", rec->ur_fid1->id, - rec->ur_fid1->generation, rec->ur_iattr.ia_valid); + DEBUG_REQ(D_INODE, req, "setattr "LPU64"/%u %x", + id_ino(rec->ur_id1), id_gen(rec->ur_id1), + 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_fid2dentry(mds, rec->ur_fid1, NULL); + de = mds_id2dentry(obd, rec->ur_id1, 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_fid2locked_dentry(obd, rec->ur_fid1, NULL, LCK_PW, - lockh, &parent_mode, NULL, 0, lockpart); + de = mds_id2locked_dentry(obd, rec->ur_id1, NULL, LCK_PW, + lockh, &parent_mode, NULL, 0, lockpart); if (IS_ERR(de)) GOTO(cleanup, rc = PTR_ERR(de)); locked = 1; @@ -454,12 +463,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_osc_exp, 0, &lsm, rec->ur_eadata); + rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, mds->mds_lov_exp, + 0, &lsm, rec->ur_eadata); if (rc) GOTO(cleanup, rc); - obd_free_memmd(mds->mds_osc_exp, &lsm); + obd_free_memmd(mds->mds_lov_exp, &lsm); rc = fsfilt_set_md(obd, inode, handle, rec->ur_eadata, rec->ur_eadatalen); @@ -468,8 +477,7 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset, } body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); - mds_pack_inode2fid(obd, &body->fid1, inode); - mds_pack_inode2body(obd, body, inode); + mds_pack_inode2body(obd, body, inode, 0); /* Don't return OST-specific attributes if we didn't just set them */ if (rec->ur_iattr.ia_valid & ATTR_SIZE) @@ -479,7 +487,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_osc_obd)) { + if (rc == 0 && rec->ur_cookielen && !IS_ERR(mds->mds_lov_obd)) { OBD_ALLOC(mlcd, sizeof(*mlcd) + rec->ur_cookielen + rec->ur_eadatalen); if (mlcd) { @@ -536,7 +544,6 @@ 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; @@ -548,25 +555,22 @@ static void reconstruct_reint_create(struct mds_update_record *rec, int offset, return; } - parent = mds_fid2dentry(obd, rec->ur_fid1, NULL); + parent = mds_id2dentry(req2obd(req), rec->ur_id1, 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_dentry2fid(&body->fid1, child); - mds_pack_dentry2body(body, child); - body->valid |= OBD_MD_MDS; + body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); + mds_pack_dentry2body(req2obd(req), body, child, 1); } else if (child->d_inode == NULL) { - 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); + DEBUG_REQ(D_ERROR, req, "parent "DLID4" name %s mode %o", + OLID4(rec->ur_id1), 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_inode2fid(req2obd(req), &body->fid1, child->d_inode); - mds_pack_inode2body(req2obd(req), body, child->d_inode); + body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); + mds_pack_inode2body(req2obd(req), body, child->d_inode, 1); } l_dput(parent); l_dput(child); @@ -593,21 +597,22 @@ 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", - rec->ur_fid1->id, rec->ur_fid1->generation, + id_ino(rec->ur_id1), id_gen(rec->ur_id1), 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_fid2locked_dentry(obd, rec->ur_fid1, NULL, LCK_PW, lockh, - &parent_mode, rec->ur_name, - rec->ur_namelen - 1, MDS_INODELOCK_UPDATE); + dparent = mds_id2locked_dentry(obd, rec->ur_id1, 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); @@ -625,24 +630,27 @@ 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; - i = mea_name2idx(mea, rec->ur_name, rec->ur_namelen - 1); - if (mea->mea_master != mea->mea_fids[i].mds) { + /* + * 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])) { CDEBUG(D_OTHER, "inapropriate MDS(%d) for %lu/%u:%s." - " should be %d(%d)\n", + " should be %lu(%d)\n", mea->mea_master, dparent->d_inode->i_ino, dparent->d_inode->i_generation, rec->ur_name, - mea->mea_fids[i].mds, i); + (unsigned long)id_group(&mea->mea_ids[i]), 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("child lookup error %d\n", rc); + CERROR("Can't find "DLID4"/%s, error %d\n", + OLID4(rec->ur_id1), rec->ur_name, rc); GOTO(cleanup, rc); } @@ -669,8 +677,13 @@ 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)rec->ur_fid2->id; + dp.p_inum = (unsigned long)id_ino(rec->ur_id2); dp.p_ptr = req; switch (type) { @@ -683,13 +696,15 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, break; } case S_IFDIR:{ - int nstripes = 0; - int i; + int i, nstripes = 0; + struct lustre_id sid; - /* 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) { @@ -699,15 +714,50 @@ 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 - * signalthat we have exclusive access - * to the directory. simple because - * nobody knows it already exists -bzzz */ + /* 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, dchild, NULL, nstripes, LCK_EX); @@ -727,9 +777,12 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, /* first, create that inode */ oa = obdo_alloc(); - LASSERT(oa != NULL); + if (!oa) + GOTO(cleanup, rc = -ENOMEM); + 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); @@ -738,24 +791,35 @@ 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) rec->ur_fid2->id, - (unsigned) rec->ur_fid2->generation); - oa->o_id = rec->ur_fid2->id; - oa->o_generation = rec->ur_fid2->generation; + 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); 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", - rec->ur_fid1->id, rec->ur_fid1->generation, + id_ino(rec->ur_id1), id_gen(rec->ur_id1), rec->ur_name, rec->ur_mode); obdo_free(oa); GOTO(cleanup, rc); @@ -767,19 +831,29 @@ 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); - LASSERT(rc == 0); + 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); + } /* fill reply */ - 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; + 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; obdo_free(oa); } else { /* requested name exists in the directory */ @@ -818,7 +892,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)rec->ur_fid2->id) + if (dchild->d_fsdata == (void *)(unsigned long)id_ino(rec->ur_id2)) dchild->d_fsdata = NULL; if (rc) { @@ -826,25 +900,48 @@ static int mds_reint_create(struct mds_update_record *rec, int offset, GOTO(cleanup, rc); } else if (dchild->d_inode) { struct iattr iattr; - struct inode *inode = dchild->d_inode; struct mds_body *body; + struct inode *inode = dchild->d_inode; created = 1; - 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; + 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); + 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 (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. */ + 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. */ CDEBUG(D_INODE, "recreated ino %lu with gen %u\n", inode->i_ino, inode->i_generation); } else { @@ -856,12 +953,14 @@ 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: " @@ -870,6 +969,24 @@ 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); @@ -883,9 +1000,8 @@ 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_inode2fid(obd, &body->fid1, inode); - mds_pack_inode2body(obd, body, inode); + body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body)); + mds_pack_inode2body(obd, body, inode, 1); } EXIT; @@ -938,19 +1054,13 @@ cleanup: return 0; } -static int res_gt(struct ldlm_res_id *res1, struct ldlm_res_id *res2, - ldlm_policy_data_t *p1, ldlm_policy_data_t *p2) +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) { 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]) @@ -979,19 +1089,20 @@ 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 (res_gt(p1_res_id, p2_res_id, p1_policy, p2_policy)) { + if (p2_res_id->name[0] != 0 && + 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; @@ -1150,8 +1261,11 @@ 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) + struct ldlm_res_id *maxres, + unsigned long child_ino, + __u32 child_gen) { + struct lustre_id sid; struct dentry *vchild, *dchild = *dchildp; int rc = 0, cleanup_phase = 2; /* parent, child locks */ ENTRY; @@ -1161,9 +1275,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_res_id->name[0] == vchild->d_inum && - child_res_id->name[1] == vchild->d_generation) { - if (dchild != NULL) + if (child_gen == vchild->d_generation && + child_ino == vchild->d_inum) { + if (dchild) l_dput(dchild); *dchildp = vchild; RETURN(0); @@ -1173,12 +1287,11 @@ 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_res_id->name[0] == vchild->d_inode->i_ino && - child_res_id->name[1] == vchild->d_inode->i_generation))) { - if (dchild != NULL) + child_gen == vchild->d_inode->i_generation && + child_ino == vchild->d_inode->i_ino))) { + if (dchild) l_dput(dchild); *dchildp = vchild; - RETURN(0); } @@ -1187,6 +1300,7 @@ 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) @@ -1197,12 +1311,21 @@ changed: if (dchild->d_inode || (dchild->d_flags & DCACHE_CROSS_REF)) { int flags = 0; + if (dchild->d_inode) { - child_res_id->name[0] = dchild->d_inode->i_ino; - child_res_id->name[1] = dchild->d_inode->i_generation; + 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); } else { - child_res_id->name[0] = dchild->d_inum; - child_res_id->name[1] = dchild->d_generation; + child_res_id->name[0] = dchild->d_fid; + child_res_id->name[1] = dchild->d_mdsnum; } if (res_gt(parent_res_id, child_res_id, NULL, NULL) || @@ -1225,7 +1348,6 @@ changed: memset(child_res_id, 0, sizeof(*child_res_id)); } - EXIT; cleanup: if (rc) { switch(cleanup_phase) { @@ -1236,11 +1358,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 ll_fid *fid, + struct lustre_id *id, struct lustre_handle *parent_lockh, struct dentry **dparentp, int parent_mode, __u64 parent_lockpart, int *update_mode, @@ -1249,16 +1371,19 @@ 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 inode *inode; + 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; ENTRY; /* Step 1: Lookup parent */ - *dparentp = mds_fid2dentry(mds, fid, NULL); + *dparentp = mds_id2dentry(obd, id, NULL); if (IS_ERR(*dparentp)) { rc = PTR_ERR(*dparentp); *dparentp = NULL; @@ -1268,19 +1393,22 @@ 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] = (*dparentp)->d_inode->i_ino; - parent_res_id.name[1] = (*dparentp)->d_inode->i_generation; + parent_res_id.name[0] = id_fid(id); + parent_res_id.name[1] = id_group(id); + #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] = (*dparentp)->d_inode->i_ino; - res_id.name[1] = (*dparentp)->d_inode->i_generation; + res_id.name[0] = id_fid(id); + res_id.name[1] = id_group(id); policy.l_inodebits.bits = MDS_INODELOCK_UPDATE; + rc = ldlm_cli_enqueue(NULL, NULL, obd->obd_namespace, res_id, LDLM_IBITS, &policy, *update_mode, &flags, @@ -1293,9 +1421,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:%u:"LPX64"\n", - (*dparentp)->d_inode->i_ino, - (*dparentp)->d_inode->i_generation, + + CDEBUG(D_INFO, "take lock on %lu:%lu:"LPX64"\n", + (unsigned long)id_fid(id), (unsigned long)id_group(id), parent_res_id.name[2]); } #endif @@ -1311,12 +1439,17 @@ 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 * mds/ino/gen - * and LOOKUP lock. drop possible UPDATE lock! */ + /* + * inode lives on another MDS: return * fid/mdsnum 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_inum; - child_res_id.name[1] = (*dchildp)->d_generation; + + 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; goto retry_locks; } @@ -1326,17 +1459,27 @@ int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds, if (inode == NULL) goto retry_locks; - child_res_id.name[0] = inode->i_ino; - child_res_id.name[1] = 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); + } + + 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; 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) @@ -1351,7 +1494,8 @@ 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); + name, namelen, &parent_res_id, + child_ino, child_gen); if (rc > 0) goto retry_locks; if (rc < 0) { @@ -1374,10 +1518,9 @@ 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) @@ -1406,8 +1549,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 fidname[LL_FID_NAMELEN]; - int fidlen = 0, rc, mode; + char idname[LL_ID_NAMELEN]; + int idlen = 0, rc, mode; ENTRY; LASSERT(inode != NULL); @@ -1417,17 +1560,18 @@ static int mds_orphan_add_link(struct mds_update_record *rec, #endif LASSERT(down_trylock(&pending_dir->i_sem) != 0); - fidlen = ll_fid2str(fidname, inode->i_ino, inode->i_generation); + idlen = ll_id2str(idname, 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,fidname); + S_ISREG(inode->i_mode) ? "file" : "other", + rec->ur_name, idname); if (mds_orphan_open_count(inode) == 0 || inode->i_nlink != 0) RETURN(0); - pending_child = lookup_one_len(fidname, mds->mds_pending_dir, fidlen); + pending_child = lookup_one_len(idname, mds->mds_pending_dir, idlen); if (IS_ERR(pending_child)) RETURN(PTR_ERR(pending_child)); @@ -1467,41 +1611,58 @@ 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 *fids_dir = mds->mds_fids_dir->d_inode; - int fidlen = 0, rc, cleanup_phase = 0; + struct inode *id_dir = mds->mds_id_dir->d_inode; + int idlen = 0, rc, cleanup_phase = 0; struct dentry *new_child = NULL; - char *fidname = rec->ur_name; + char *idname = rec->ur_name; struct dentry *child = NULL; struct lustre_handle lockh[2] = {{0}, {0}}; + struct lustre_id sid; void *handle; ENTRY; - 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); + 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)); - new_child = lookup_one_len(fidname, mds->mds_fids_dir, fidlen); - up(&fids_dir->i_sem); + new_child = ll_lookup_one_len(idname, mds->mds_id_dir, + idlen); + up(&id_dir->i_sem); if (IS_ERR(new_child)) { - CERROR("can't lookup %s: %d\n", fidname, - (int) PTR_ERR(new_child)); + CERROR("can't lookup %s: %d\n", idname, + (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); - rec->ur_fid1->id = fids_dir->i_ino; - rec->ur_fid1->generation = fids_dir->i_generation; - rec->ur_namelen = fidlen + 1; + (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); + GOTO(cleanup, rc = 0); } @@ -1509,11 +1670,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_fid2dentry(mds, rec->ur_fid1, NULL); + child = mds_id2dentry(obd, rec->ur_id1, NULL); } else { - child = mds_fid2locked_dentry(obd, rec->ur_fid1, NULL, - LCK_EX, lockh, NULL, NULL, 0, - MDS_INODELOCK_UPDATE); + child = mds_id2locked_dentry(obd, rec->ur_id1, NULL, + LCK_EX, lockh, NULL, NULL, 0, + MDS_INODELOCK_UPDATE); } if (IS_ERR(child)) { @@ -1524,30 +1685,33 @@ int mds_create_local_dentry(struct mds_update_record *rec, } cleanup_phase = 2; - handle = fsfilt_start(obd, fids_dir, FSFILT_OP_LINK, NULL); + handle = fsfilt_start(obd, id_dir, FSFILT_OP_LINK, NULL); if (IS_ERR(handle)) GOTO(cleanup, rc = PTR_ERR(handle)); - rc = fsfilt_add_dir_entry(obd, mds->mds_fids_dir, fidname, fidlen, - rec->ur_fid1->id, rec->ur_fid1->generation, - mds->mds_num); + 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)); 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)) { - fids_dir->i_nlink++; - mark_inode_dirty(fids_dir); + id_dir->i_nlink++; + mark_inode_dirty(id_dir); } mark_inode_dirty(child->d_inode); } - fsfilt_commit(obd, mds->mds_sb, fids_dir, handle, 0); + fsfilt_commit(obd, mds->mds_sb, id_dir, handle, 0); - rec->ur_fid1->id = fids_dir->i_ino; - rec->ur_fid1->generation = fids_dir->i_generation; - rec->ur_namelen = fidlen + 1; + 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); cleanup: switch(cleanup_phase) { case 2: @@ -1563,7 +1727,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; @@ -1577,9 +1741,8 @@ 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; @@ -1619,11 +1782,10 @@ 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) { @@ -1637,21 +1799,27 @@ static int mds_reint_unlink_remote(struct mds_update_record *rec, int offset, LASSERT(offset == 1 || offset == 3); - 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); + 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); + if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) - DEBUG_REQ(D_HA, req, "unlink %*s (remote inode %u/%u/%u)", + DEBUG_REQ(D_HA, req, "unlink %*s (remote inode %u/%u/%u/%u)", rec->ur_namelen - 1, rec->ur_name, (unsigned)dchild->d_mdsnum, - (unsigned) dchild->d_inum, - (unsigned) dchild->d_generation); + (unsigned)dchild->d_fid, + (unsigned)dchild->d_inum, + (unsigned)dchild->d_generation); /* time to drop i_nlink on remote MDS */ memset(&op_data, 0, sizeof(op_data)); - op_data.fid1.mds = dchild->d_mdsnum; - op_data.fid1.id = dchild->d_inum; - op_data.fid1.generation = dchild->d_generation; + 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.create_mode = rec->ur_mode; if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) op_data.create_mode |= MDS_MODE_REPLAY; @@ -1703,19 +1871,20 @@ 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; + struct lustre_handle *slave_lockh = NULL; + char idname[LL_ID_NAMELEN]; struct llog_create_locks *lcl = NULL; - char fidname[LL_FID_NAMELEN]; void *handle = NULL; int rc = 0, cleanup_phase = 0; - int unlink_by_fid = 0; + int unlink_by_id = 0; int update_mode; ENTRY; LASSERT(offset == 1 || offset == 3); DEBUG_REQ(D_INODE, req, "parent ino "LPU64"/%u, child %s", - rec->ur_fid1->id, rec->ur_fid1->generation, rec->ur_name); + id_ino(rec->ur_id1), id_gen(rec->ur_id1), + rec->ur_name); MDS_CHECK_RESENT(req, mds_reconstruct_generic(req)); @@ -1734,31 +1903,29 @@ 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_fid = 1; - rec->ur_name = fidname; + unlink_by_id = 1; + rec->ur_name = idname; 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 %u/%u/%u (replay)", - (unsigned) rec->ur_fid1->mds, - (unsigned) rec->ur_fid1->id, - (unsigned) rec->ur_fid1->generation); + "drop nlink on inode "DLID4" (replay)", + OLID4(rec->ur_id1)); 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_fid2locked_dentry(obd, rec->ur_fid1, NULL, + /* master mds for directory asks slave removing inode is already + * locked */ + dparent = mds_id2locked_dentry(obd, rec->ur_id1, 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)); @@ -1767,7 +1934,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_fid1, + rc = mds_get_parent_child_locked(obd, mds, rec->ur_id1, parent_lockh, &dparent, LCK_PW, MDS_INODELOCK_UPDATE, &update_mode, rec->ur_name, @@ -1781,7 +1948,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_fid == 0); + LASSERT(unlink_by_id == 0); LASSERT(dchild->d_mdsnum != mds->mds_num); mds_reint_unlink_remote(rec, offset, req, parent_lockh, update_mode, dparent, &child_lockh, dchild); @@ -1853,10 +2020,9 @@ 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_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); + mds_pack_inode2body(obd, body, child_inode, 0); + mds_pack_md(obd, req->rq_repmsg, offset + 1, + body, child_inode, MDS_PACK_MD_LOCK); } } @@ -1944,7 +2110,7 @@ cleanup: rc = mds_finish_transno(mds, dparent ? dparent->d_inode : NULL, handle, req, rc, 0); if (!rc) - (void)obd_set_info(mds->mds_osc_exp, strlen("unlinked"), + (void)obd_set_info(mds->mds_lov_exp, strlen("unlinked"), "unlinked", 0, NULL); switch(cleanup_phase) { case 5: /* pending_dir semaphore */ @@ -1999,8 +2165,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} }; @@ -2012,26 +2178,24 @@ 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 %u/%u/%u\n", - obd->obd_name, (unsigned) rec->ur_fid1->mds, - (unsigned) rec->ur_fid1->id, - (unsigned) rec->ur_fid1->generation); + DEBUG_REQ(D_INODE, req, "%s: request to acquire i_nlinks "DLID4"\n", + obd->obd_name, OLID4(rec->ur_id1)); - /* Step 1: Lookup the source inode and target directory by FID */ - de_src = mds_fid2dentry(mds, rec->ur_fid1, NULL); + /* Step 1: Lookup the source inode and target directory by ID */ + de_src = mds_id2dentry(obd, rec->ur_id1, NULL); if (IS_ERR(de_src)) GOTO(cleanup, rc = PTR_ERR(de_src)); cleanup_phase = 1; /* source dentry */ - src_res_id.name[0] = de_src->d_inode->i_ino; - src_res_id.name[1] = de_src->d_inode->i_generation; + src_res_id.name[0] = id_fid(rec->ur_id1); + src_res_id.name[1] = id_group(rec->ur_id1); 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 */ @@ -2087,25 +2251,20 @@ static int mds_reint_link_to_remote(struct mds_update_record *rec, int update_mode; ENTRY; -#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); + 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); if (IS_ERR(de_tgt_dir)) GOTO(cleanup, rc = PTR_ERR(de_tgt_dir)); cleanup_phase = 1; - op_data.fid1 = *(rec->ur_fid1); + op_data.id1 = *(rec->ur_id1); op_data.namelen = 0; op_data.name = NULL; rc = md_link(mds->mds_lmv_exp, &op_data, &request); @@ -2125,8 +2284,9 @@ 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, rec->ur_fid1->id, - rec->ur_fid1->generation, rec->ur_fid1->mds); + rec->ur_namelen - 1, id_ino(rec->ur_id1), + id_gen(rec->ur_id1), id_group(rec->ur_id1), + id_fid(rec->ur_id1)); cleanup_phase = 3; cleanup: @@ -2188,18 +2348,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", - rec->ur_fid1->id, rec->ur_fid1->generation, - rec->ur_fid2->id, rec->ur_fid2->generation, rec->ur_name); + id_ino(rec->ur_id1), id_gen(rec->ur_id1), + id_ino(rec->ur_id2), id_gen(rec->ur_id2), + 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 (rec->ur_fid1->mds != mds->mds_num) { + if (id_group(rec->ur_id1) != mds->mds_num) { rc = mds_reint_link_to_remote(rec, offset, req, lh); RETURN(rc); } @@ -2209,14 +2369,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 FID */ - de_src = mds_fid2dentry(mds, rec->ur_fid1, NULL); + /* Step 1: Lookup the source inode and target directory by ID */ + de_src = mds_id2dentry(obd, rec->ur_id1, NULL); if (IS_ERR(de_src)) GOTO(cleanup, rc = PTR_ERR(de_src)); cleanup_phase = 1; /* source dentry */ - de_tgt_dir = mds_fid2dentry(mds, rec->ur_fid2, NULL); + de_tgt_dir = mds_id2dentry(obd, rec->ur_id2, NULL); if (IS_ERR(de_tgt_dir)) { rc = PTR_ERR(de_tgt_dir); de_tgt_dir = NULL; @@ -2226,14 +2386,15 @@ 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] = 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; + 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); + #ifdef S_PDIROPS if (IS_PDIROPS(de_tgt_dir->d_inode)) { int flags = 0; @@ -2251,23 +2412,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:%u:"LPX64"\n", - de_tgt_dir->d_inode->i_ino, - de_tgt_dir->d_inode->i_generation, + CDEBUG(D_INFO, "take lock on %lu:%lu:"LPX64"\n", + (unsigned long)id_fid(rec->ur_id2), + (unsigned long)id_group(rec->ur_id2), 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) @@ -2355,9 +2516,9 @@ cleanup: */ static int mds_get_parents_children_locked(struct obd_device *obd, struct mds_obd *mds, - struct ll_fid *p1_fid, + struct lustre_id *p1_id, struct dentry **de_srcdirp, - struct ll_fid *p2_fid, + struct lustre_id *p2_id, struct dentry **de_tgtdirp, int parent_mode, const char *old_name, int old_len, @@ -2381,24 +2542,28 @@ 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_fid2dentry(mds, p1_fid, NULL); + *de_srcdirp = mds_id2dentry(obd, p1_id, NULL); if (IS_ERR(*de_srcdirp)) GOTO(cleanup, rc = PTR_ERR(*de_srcdirp)); cleanup_phase = 1; /* source directory dentry */ - p1_res_id.name[0] = (*de_srcdirp)->d_inode->i_ino; - p1_res_id.name[1] = (*de_srcdirp)->d_inode->i_generation; + p1_res_id.name[0] = id_fid(p1_id); + p1_res_id.name[1] = id_group(p1_id); /* Step 2: Lookup the target directory */ - if (memcmp(p1_fid, p2_fid, sizeof(*p1_fid)) == 0) { + if (id_equal(p1_id, p2_id)) { *de_tgtdirp = dget(*de_srcdirp); } else { - *de_tgtdirp = mds_fid2dentry(mds, p2_fid, NULL); + *de_tgtdirp = mds_id2dentry(obd, p2_id, NULL); if (IS_ERR(*de_tgtdirp)) { rc = PTR_ERR(*de_tgtdirp); *de_tgtdirp = NULL; @@ -2408,22 +2573,26 @@ static int mds_get_parents_children_locked(struct obd_device *obd, cleanup_phase = 2; /* target directory dentry */ - p2_res_id.name[0] = (*de_tgtdirp)->d_inode->i_ino; - p2_res_id.name[1] = (*de_tgtdirp)->d_inode->i_generation; + p2_res_id.name[0] = id_fid(p2_id); + p2_res_id.name[1] = id_group(p2_id); #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 ino, gen 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 fid, group 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], @@ -2434,7 +2603,8 @@ 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", @@ -2447,20 +2617,39 @@ 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); - c1_res_id.name[0] = inode->i_ino; - c1_res_id.name[1] = 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); + } + + 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; iput(inode); } else if ((*de_oldp)->d_flags & DCACHE_CROSS_REF) { - c1_res_id.name[0] = (*de_oldp)->d_inum; - c1_res_id.name[1] = (*de_oldp)->d_generation; + 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); } /* 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", @@ -2476,16 +2665,31 @@ 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; - c2_res_id.name[0] = inode->i_ino; - c2_res_id.name[1] = 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); + } + + 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; iput(inode); } else if ((*de_newp)->d_flags & DCACHE_CROSS_REF) { - c2_res_id.name[0] = (*de_newp)->d_inum; - c2_res_id.name[1] = (*de_newp)->d_generation; + 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; } retry_locks: @@ -2494,12 +2698,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, @@ -2516,7 +2720,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); + maxres_tgt, child1_ino, child1_gen); if (rc) { if (c2_res_id.name[0] != 0) ldlm_lock_decref(&dlm_handles[3], child_mode); @@ -2534,7 +2738,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); + new_len, maxres_src, child2_ino, child2_gen); if (rc) { ldlm_lock_decref(&dlm_handles[2], child_mode); ldlm_lock_decref(&dlm_handles[0], parent_mode); @@ -2553,8 +2757,10 @@ cleanup: ldlm_lock_decref(&dlm_handles[3], child_mode); if (c1_res_id.name[0] != 0) ldlm_lock_decref(&dlm_handles[2], child_mode); - ldlm_lock_decref(&dlm_handles[1], parent_mode); - ldlm_lock_decref(&dlm_handles[0], parent_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); case 5: /* target dentry */ l_dput(*de_newp); case 4: /* source dentry */ @@ -2578,8 +2784,7 @@ 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); @@ -2593,8 +2798,7 @@ 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); @@ -2607,8 +2811,7 @@ 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)) @@ -2623,20 +2826,21 @@ 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_generation, dentry->d_mdsnum, + dentry->d_fid); 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); } @@ -2650,13 +2854,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, @@ -2664,34 +2868,31 @@ 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 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}; + struct dentry *de_srcdir = NULL; + struct dentry *de_new = NULL; 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 %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); + CDEBUG(D_OTHER, "%s: request to create name %s for "DLID4"\n", + obd->obd_name, rec->ur_tgt, OLID4(rec->ur_id1)); /* first, lookup the target */ child_lockh.cookie = 0; - rc = mds_get_parent_child_locked(obd, mds, rec->ur_fid2, parent_lockh, + rc = mds_get_parent_child_locked(obd, mds, rec->ur_id2, parent_lockh, &de_srcdir,LCK_PW,MDS_INODELOCK_UPDATE, &update_mode, rec->ur_tgt, rec->ur_tgtlen, &child_lockh, &de_new, LCK_EX, @@ -2706,12 +2907,14 @@ 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)) @@ -2723,9 +2926,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, @@ -2733,11 +2936,12 @@ 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, rec->ur_fid1->id, - rec->ur_fid1->generation, rec->ur_fid1->mds); + rec->ur_tgtlen - 1, id_ino(rec->ur_id1), + id_gen(rec->ur_id1), id_group(rec->ur_id1), + id_fid(rec->ur_id1)); if (rc) CERROR("add_dir_entry() returned error %d\n", rc); cleanup: @@ -2762,7 +2966,6 @@ cleanup: } req->rq_status = rc; - RETURN(0); } @@ -2780,13 +2983,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%u\n", - obd->obd_name, rec->ur_name, rec->ur_fid2->mds + 1); + 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)); memset(&opdata, 0, sizeof(opdata)); child_lockh.cookie = 0; - rc = mds_get_parent_child_locked(obd, mds, rec->ur_fid1, parent_lockh, - &de_srcdir,LCK_PW,MDS_INODELOCK_UPDATE, + rc = mds_get_parent_child_locked(obd, mds, rec->ur_id1, 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); @@ -2795,38 +2998,53 @@ 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 fid */ + /* prepare source id */ if (de_old->d_flags & DCACHE_CROSS_REF) { LASSERT(de_old->d_inode == NULL); CDEBUG(D_OTHER, "request to move remote name\n"); - opdata.fid1.mds = de_old->d_mdsnum; - opdata.fid1.id = de_old->d_inum; - opdata.fid1.generation = de_old->d_generation; + mds_pack_dentry2id(obd, &opdata.id1, de_old, 1); } else if (de_old->d_inode == NULL) { /* oh, source doesn't exist */ GOTO(cleanup, rc = -ENOENT); } else { - LASSERT(de_old->d_inode != NULL); + struct lustre_id sid; + struct inode *inode = de_old->d_inode; + + LASSERT(inode != NULL); CDEBUG(D_OTHER, "request to move local name\n"); - opdata.fid1.mds = mds->mds_num; - opdata.fid1.id = de_old->d_inode->i_ino; - opdata.fid1.generation = de_old->d_inode->i_generation; + 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.fid2 = *(rec->ur_fid2); - rc = md_rename(mds->mds_lmv_exp, &opdata, NULL, 0, rec->ur_tgt, - rec->ur_tgtlen - 1, &req2); + opdata.id2 = *(rec->ur_id2); + 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); @@ -2843,7 +3061,6 @@ cleanup: req->rq_status = rc; RETURN(0); - } static int mds_reint_rename(struct mds_update_record *rec, int offset, @@ -2861,15 +3078,14 @@ 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 "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); + 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); MDS_CHECK_RESENT(req, mds_reconstruct_generic(req)); @@ -2887,13 +3103,14 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, RETURN(rc); } - if (rec->ur_fid2->mds != mds->mds_num) { + /* check if new name should be located on remote target. */ + if (id_group(rec->ur_id2) != mds->mds_num) { rc = mds_reint_rename_to_remote(rec, offset, req); RETURN(rc); } - rc = mds_get_parents_children_locked(obd, mds, rec->ur_fid1, &de_srcdir, - rec->ur_fid2, &de_tgtdir, LCK_PW, + rc = mds_get_parents_children_locked(obd, mds, rec->ur_id1, &de_srcdir, + rec->ur_id2, &de_tgtdir, LCK_PW, rec->ur_name, rec->ur_namelen, &de_old, rec->ur_tgt, rec->ur_tgtlen, &de_new, @@ -2937,7 +3154,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, @@ -2959,8 +3176,10 @@ 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); @@ -2977,10 +3196,9 @@ 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_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); + mds_pack_inode2body(obd, body, new_inode, 0); + mds_pack_md(obd, req->rq_repmsg, 1, body, + new_inode, MDS_PACK_MD_LOCK); } } @@ -3042,8 +3260,10 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, GOTO(cleanup, rc); cleanup: - rc = mds_finish_transno(mds, de_tgtdir ? de_tgtdir->d_inode : NULL, + EXIT; + 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 20191c6..b52f1e5 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_osc_exp, &lsm, lmm, lmm_size); + rc = obd_unpackmd(mds->mds_lov_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_osc_exp, oa, lsm, &oti); + rc = obd_destroy(mds->mds_lov_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_osc_exp, &lsm); + obd_free_memmd(mds->mds_lov_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_osc_obd != NULL); + LASSERT(mds->mds_lov_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_FID_NAMELEN]; + char d_name[LL_ID_NAMELEN]; __u64 i = 0; int rc = 0, item = 0, namlen; ENTRY; diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index e464b58..3706464 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -484,6 +484,7 @@ 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); @@ -656,7 +657,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 == 0x5a5a5a5a5a5a5a5a) { + if (export->exp_handle.h_cookie == LL_POISON) { CERROR("disconnecting freed export %p, ignoring\n", export); } else { class_unlink_export(export); @@ -667,9 +668,9 @@ int class_disconnect(struct obd_export *export, int flags) static void class_disconnect_export_list(struct list_head *list, int flags) { - int rc; - struct lustre_handle fake_conn; struct obd_export *fake_exp, *exp; + struct lustre_handle fake_conn; + int rc; ENTRY; /* Move all of the exports from obd_exports to a work list, en masse. */ @@ -684,8 +685,10 @@ 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; @@ -697,6 +700,7 @@ 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 d685687..8c2e1b1 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -45,7 +45,6 @@ #include #if defined(LPROCFS) && defined(__KERNEL__) - struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head, const char *name) { @@ -65,7 +64,6 @@ 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) { @@ -661,13 +659,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 ec276fe8..8dffec3 100644 --- a/lustre/obdclass/mea.c +++ b/lustre/obdclass/mea.c @@ -93,4 +93,3 @@ 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 325c2c1..b61a28e 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -433,8 +433,9 @@ struct lustre_profile *class_get_profile(char * prof) RETURN(NULL); } -int class_add_profile(int proflen, char *prof, int osclen, char *osc, - int mdclen, char *mdc) +int class_add_profile(int proflen, char *prof, + int lovlen, char *lov, + int lmvlen, char *lmv) { struct lustre_profile *lprof; int err = 0; @@ -450,18 +451,18 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, GOTO(out, err = -ENOMEM); memcpy(lprof->lp_profile, prof, proflen); - LASSERT(osclen == (strlen(osc) + 1)); - OBD_ALLOC(lprof->lp_osc, osclen); + LASSERT(lovlen == (strlen(lov) + 1)); + OBD_ALLOC(lprof->lp_lov, lovlen); if (lprof->lp_profile == NULL) GOTO(out, err = -ENOMEM); - memcpy(lprof->lp_osc, osc, osclen); + memcpy(lprof->lp_lov, lov, lovlen); - if (mdclen > 0) { - LASSERT(mdclen == (strlen(mdc) + 1)); - OBD_ALLOC(lprof->lp_mdc, mdclen); - if (lprof->lp_mdc == NULL) + if (lmvlen > 0) { + LASSERT(lmvlen == (strlen(lmv) + 1)); + OBD_ALLOC(lprof->lp_lmv, lmvlen); + if (lprof->lp_lmv == NULL) GOTO(out, err = -ENOMEM); - memcpy(lprof->lp_mdc, mdc, mdclen); + memcpy(lprof->lp_lmv, lmv, lmvlen); } list_add(&lprof->lp_list, &lustre_profile_list); @@ -478,9 +479,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_osc, strlen(lprof->lp_osc) + 1); - if (lprof->lp_mdc) - OBD_FREE(lprof->lp_mdc, strlen(lprof->lp_mdc) + 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, sizeof *lprof); } } diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c index e5e9ce8..dbbdba1 100644 --- a/lustre/obdecho/echo.c +++ b/lustre/obdecho/echo.c @@ -69,7 +69,6 @@ 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 ab194ce..b6446a9 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 id's. +/* How to get files, dentries, inodes from object store cookie. * * 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_fid2dentry(struct obd_device *obd, - struct dentry *dir_dentry, - obd_gr group, obd_id id) +struct dentry *filter_id2dentry(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,11 +1963,10 @@ 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 */ @@ -1986,7 +1985,7 @@ struct dentry *__filter_oa2dentry(struct obd_device *obd, if (oa->o_valid & OBD_MD_FLGROUP) group = oa->o_gr; - dchild = filter_fid2dentry(obd, NULL, group, oa->o_id); + dchild = filter_id2dentry(obd, NULL, group, oa->o_id); if (IS_ERR(dchild)) { CERROR("%s error looking up object: "LPU64"\n", what, oa->o_id); @@ -2315,8 +2314,7 @@ 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_fid2dentry(obd, dparent, group, next_id); + dchild = filter_id2dentry(obd, dparent, group, next_id); if (IS_ERR(dchild)) GOTO(cleanup, rc = PTR_ERR(dchild)); cleanup_phase = 2; @@ -2522,7 +2520,7 @@ static int filter_destroy(struct obd_export *exp, struct obdo *oa, GOTO(cleanup, rc = PTR_ERR(dparent)); cleanup_phase = 1; - dchild = filter_fid2dentry(obd, dparent, oa->o_gr, oa->o_id); + dchild = filter_id2dentry(obd, dparent, oa->o_gr, oa->o_id); if (IS_ERR(dchild)) GOTO(cleanup, rc = -ENOENT); cleanup_phase = 2; @@ -2958,14 +2956,14 @@ static int filter_llog_connect(struct obd_export *exp, RETURN(rc); } -static struct dentry *filter_lvfs_fid2dentry(__u64 id, __u32 gen, __u64 gr, - void *data) +static struct dentry *filter_lvfs_id2dentry(__u64 id, __u32 gen, + __u64 gr, void *data) { - return filter_fid2dentry(data, NULL, gr, id); + return filter_id2dentry(data, NULL, gr, id); } static struct lvfs_callback_ops filter_lvfs_ops = { - l_fid2dentry: filter_lvfs_fid2dentry, + l_id2dentry: filter_lvfs_id2dentry, }; static struct obd_ops filter_obd_ops = { diff --git a/lustre/obdfilter/filter_internal.h b/lustre/obdfilter/filter_internal.h index 12ad087..f6e0628 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_fid2dentry(struct obd_device *, struct dentry *dir, - obd_gr group, obd_id id); +struct dentry *filter_id2dentry(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 ll_fid *mds_fid, - __u32 io_epoch, + struct lustre_id *id, __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 8b09fc7..6c32ebb 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_fid2dentry(exp->exp_obd, NULL, obj->ioo_gr, - obj->ioo_id); + dentry = filter_id2dentry(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_fid2dentry(exp->exp_obd, NULL, obj->ioo_gr, - obj->ioo_id); + dentry = filter_id2dentry(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,9 +842,8 @@ 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_fid2dentry(exp->exp_obd, NULL, obj->ioo_gr, - obj->ioo_id); + dentry = filter_id2dentry(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 386da62..c271382 100644 --- a/lustre/obdfilter/filter_log.c +++ b/lustre/obdfilter/filter_log.c @@ -38,8 +38,7 @@ #include "filter_internal.h" int filter_log_sz_change(struct llog_handle *cathandle, - struct ll_fid *mds_fid, - __u32 io_epoch, + struct lustre_id *id, __u32 io_epoch, struct llog_cookie *logcookie, struct inode *inode) { @@ -77,7 +76,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_fid = *mds_fid; + lsc->lsc_id = *id; 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 fbd698f..b23327d 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(-EINVAL); + RETURN(-EPROTO); } static int osc_set_info(struct obd_export *exp, obd_count keylen, @@ -2926,10 +2926,9 @@ 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) @@ -2937,6 +2936,7 @@ 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 db63a08..de642bd 100644 --- a/lustre/portals/include/linux/kp30.h +++ b/lustre/portals/include/linux/kp30.h @@ -728,4 +728,13 @@ 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 d1a5c44..17d5a11 100644 --- a/lustre/portals/include/linux/libcfs.h +++ b/lustre/portals/include/linux/libcfs.h @@ -145,6 +145,13 @@ 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 438edc6..d25d201 100644 --- a/lustre/portals/knals/qswnal/qswnal.h +++ b/lustre/portals/knals/qswnal/qswnal.h @@ -79,6 +79,7 @@ #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 1bde59f..0e109cb 100644 --- a/lustre/portals/utils/portals.c +++ b/lustre/portals/utils/portals.c @@ -37,10 +37,8 @@ #include #ifdef __CYGWIN__ - #include - -#endif /* __CYGWIN__ */ +#endif #include #include @@ -54,12 +52,7 @@ unsigned int portal_printk; static unsigned int g_nal = 0; -static int g_socket_txmem = 0; -static int g_socket_rxmem = 0; -static int g_socket_nonagle = 1; - -typedef struct -{ +typedef struct { char *name; int num; } name2num_t; diff --git a/lustre/ptlbd/client.c b/lustre/ptlbd/client.c index 633d64f..6a1d759 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 failover) +int ptlbd_cl_disconnect(struct obd_export *exp, int flags) { 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 24806f1..d2ccb41 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,7 +515,6 @@ 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); @@ -526,7 +525,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) { @@ -649,7 +648,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 3b853dd..bb9b1e9 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -380,21 +380,23 @@ 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_fid = op_data->fid1; - memset(&rec->cr_replayfid, 0, sizeof(rec->cr_replayfid)); + rec->cr_id = op_data->id1; + memset(&rec->cr_replayid, 0, sizeof(rec->cr_replayid)); rec->cr_mode = mode; rec->cr_rdev = rdev; rec->cr_time = op_data->mod_time; @@ -417,7 +419,7 @@ void *mdc_setattr_pack(struct lustre_msg *msg, int offset, char *tmp = NULL; rec->sa_opcode = REINT_SETATTR; - rec->sa_fid = data->fid1; + rec->sa_id = data->id1; if (iattr) { rec->sa_valid = iattr->ia_valid; @@ -436,20 +438,18 @@ 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; - tmp += size_round(ea2len); memcpy(lustre_msg_buf(msg, offset + 2, ea2len), ea2, ea2len); - + tmp += size_round(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_fid1 = data->fid1; - rec->ul_fid2 = data->fid2; + rec->ul_id1 = data->id1; + rec->ul_id2 = data->id2; 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_fid1 = data->fid1; - rec->lk_fid2 = data->fid2; + rec->lk_id1 = data->id1; + rec->lk_id2 = data->id2; rec->lk_time = data->mod_time; tmp = lustre_msg_buf(msg, offset + 1, data->namelen + 1); @@ -490,7 +490,8 @@ 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; @@ -499,8 +500,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_fid1 = data->fid1; - rec->rn_fid2 = data->fid2; + rec->rn_id1 = data->id1; + rec->rn_id2 = data->id2; rec->rn_time = data->mod_time; tmp = lustre_msg_buf(msg, offset + 1, oldlen + 1); @@ -551,6 +552,11 @@ 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); @@ -560,11 +566,24 @@ void lustre_swab_ost_lvb(struct ost_lvb *lvb) __swab64s(&lvb->lvb_blocks); } -void lustre_swab_ll_fid (struct ll_fid *fid) +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) { - __swab64s (&fid->id); - __swab32s (&fid->generation); - __swab32s (&fid->f_type); + lustre_swab_lustre_stc(&id->li_stc); + lustre_swab_lustre_fid(&id->li_fid); } void lustre_swab_mds_status_req (struct mds_status_req *r) @@ -616,12 +635,11 @@ struct mds_req_sec_desc *lustre_swab_mds_secdesc(struct ptlrpc_request *req, void lustre_swab_mds_body (struct mds_body *b) { - lustre_swab_ll_fid (&b->fid1); - lustre_swab_ll_fid (&b->fid2); + lustre_swab_lustre_id (&b->id1); + lustre_swab_lustre_id (&b->id2); /* handle is opaque */ __swab64s (&b->size); __swab64s (&b->blocks); - __swab32s (&b->ino); __swab32s (&b->valid); __swab32s (&b->mode); __swab32s (&b->uid); @@ -632,15 +650,13 @@ 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_ll_fid (&sa->sa_fid); + lustre_swab_lustre_id (&sa->sa_id); __swab32s (&sa->sa_mode); __swab32s (&sa->sa_uid); __swab32s (&sa->sa_gid); @@ -656,8 +672,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_ll_fid (&cr->cr_fid); - lustre_swab_ll_fid (&cr->cr_replayfid); + lustre_swab_lustre_id (&cr->cr_id); + lustre_swab_lustre_id (&cr->cr_replayid); __swab64s (&cr->cr_time); __swab64s (&cr->cr_rdev); } @@ -665,23 +681,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_ll_fid (&lk->lk_fid1); - lustre_swab_ll_fid (&lk->lk_fid2); + lustre_swab_lustre_id (&lk->lk_id1); + lustre_swab_lustre_id (&lk->lk_id2); } void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul) { __swab32s (&ul->ul_opcode); __swab32s (&ul->ul_mode); - lustre_swab_ll_fid (&ul->ul_fid1); - lustre_swab_ll_fid (&ul->ul_fid2); + lustre_swab_lustre_id (&ul->ul_id1); + lustre_swab_lustre_id (&ul->ul_id2); } void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn) { __swab32s (&rn->rn_opcode); - lustre_swab_ll_fid (&rn->rn_fid1); - lustre_swab_ll_fid (&rn->rn_fid2); + lustre_swab_lustre_id (&rn->rn_id1); + lustre_swab_lustre_id (&rn->rn_id2); } void lustre_swab_lov_desc (struct lov_desc *ld) @@ -820,1393 +836,5 @@ 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 5c59f02..5cbdf4f 100644 --- a/lustre/ptlrpc/ptlrpc_module.c +++ b/lustre/ptlrpc/ptlrpc_module.c @@ -166,7 +166,10 @@ 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_ll_fid); +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_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 674a264..e42156f 100644 --- a/lustre/smfs/cache_space.c +++ b/lustre/smfs/cache_space.c @@ -31,13 +31,14 @@ #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; @@ -121,7 +122,8 @@ 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); @@ -135,6 +137,7 @@ 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) || @@ -156,38 +159,45 @@ 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 ll_fid cfid, struct ll_fid pfid) +static int try2purge_from_cache(struct lustre_id cid, + struct lustre_id pid) { 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, cfid.id); + inode = iget(sb, cid.li_stc.u.e3s.l3s_ino); if (IS_ERR(inode)) { CERROR("not existent inode: "LPX64"/%u\n", - cfid.id, cfid.generation); + cid.li_stc.u.e3s.l3s_ino, + cid.li_stc.u.e3s.l3s_gen); RETURN(-ENOENT); } - parent = iget(sb, pfid.id); + parent = iget(sb, pid.li_stc.u.e3s.l3s_ino); if (IS_ERR(parent)) { CERROR("not existent inode: "LPX64"/%u\n", - pfid.id, pfid.generation); + pid.li_stc.u.e3s.l3s_ino, + pid.li_stc.u.e3s.l3s_gen); iput(inode); RETURN(-ENOENT); } @@ -229,9 +239,10 @@ static int cache_lru_get_rec_cb(struct llog_handle *llh, llr = (struct llog_lru_rec *)rec; - if (try2purge_from_cache(llr->llr_cfid, llr->llr_pfid)==1){ + if (try2purge_from_cache(llr->llr_cid, llr->llr_pid)==1){ CDEBUG(D_INODE, "purge ino/gen "LPX64"/%u from cache\n", - llr->llr_cfid.id, llr->llr_cfid.generation); + llr->llr_cid.li_stc.u.e3s.l3s_ino, + llr->llr_cid.li_stc.u.e3s.l3s_gen); count --; if (count == 0) rc = LLOG_PROC_BREAK; @@ -295,13 +306,16 @@ 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) + if (state < 0) { + EXIT; return; + } wakeup_cpurge(); @@ -309,6 +323,7 @@ static void check_cache_space(void) int count = CFLUSH_NR; purge_some_cache(&count); } + EXIT; } void cache_space_pre(struct inode *inode, int op) @@ -317,10 +332,12 @@ 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; @@ -373,12 +390,15 @@ insert: llr->llr_hdr.lrh_len = llr->llr_tail.lrt_len = sizeof(*llr); llr->llr_hdr.lrh_type = CACHE_LRU_REC; - 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; + + /* 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; rc = llog_add(ctxt, &llr->llr_hdr, NULL, logcookie, 1, NULL, NULL, NULL); @@ -440,7 +460,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) @@ -496,6 +516,7 @@ 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); @@ -508,6 +529,7 @@ 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, @@ -526,24 +548,28 @@ 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, @@ -553,7 +579,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); } @@ -565,12 +591,14 @@ 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, @@ -591,27 +619,31 @@ 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, @@ -623,12 +655,14 @@ 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)) @@ -661,14 +695,17 @@ 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); } @@ -692,8 +729,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 85fb5b4..685d6ff 100644 --- a/lustre/smfs/dir.c +++ b/lustre/smfs/dir.c @@ -67,8 +67,9 @@ 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); @@ -76,6 +77,7 @@ 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, @@ -88,13 +90,14 @@ 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); @@ -168,20 +171,19 @@ 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); @@ -189,8 +191,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); @@ -198,7 +200,8 @@ 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); @@ -216,8 +219,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); @@ -481,8 +484,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); @@ -509,18 +512,22 @@ 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); @@ -628,10 +635,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 3a79ddd..f427884b 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 2f2f4d2..c7fff18 100644 --- a/lustre/smfs/inode.c +++ b/lustre/smfs/inode.c @@ -37,27 +37,36 @@ #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) { - struct smfs_iget_args *sargs = (struct smfs_iget_args*)opaque; - struct inode *cache_inode = NULL; + 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)); - 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; + 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); + + if (sargs) { + struct inode *dir = sargs->s_inode; + if (dir) + I2SMI(inode)->smi_flags = I2SMI(dir)->smi_flags; + } } } @@ -65,15 +74,19 @@ 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(I2SMI(inode), sizeof(struct smfs_inode_info)); - I2SMI(inode) = NULL; + + OBD_FREE(inode->u.generic_ip, + sizeof(struct smfs_inode_info)); + inode->u.generic_ip = NULL; } } @@ -81,20 +94,21 @@ static void smfs_read_inode2(struct inode *inode, void *opaque) { ENTRY; - if (!inode) + if (!inode) { + EXIT; 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 @@ -102,25 +116,32 @@ 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; } @@ -135,16 +156,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; @@ -157,10 +178,8 @@ 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); @@ -170,48 +189,37 @@ 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_index = index; - sargs.s_inode = dir; sargs.s_ino = hash; + sargs.s_inode = dir; + sargs.s_index = index; inode = smfs_iget(sb, hash, &sargs); - + RETURN(inode); } static void smfs_delete_inode(struct inode *inode) { - struct inode *cache_inode; - ENTRY; - 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; + clear_inode(inode); + EXIT; } static void smfs_write_inode(struct inode *inode, int wait) { struct inode *cache_inode; - 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); @@ -223,12 +231,13 @@ static void smfs_write_inode(struct inode *inode, int wait) static void smfs_dirty_inode(struct inode *inode) { struct inode *cache_inode; - ENTRY; - cache_inode = I2CI(inode); - if (!cache_inode || !S2CSB(inode->i_sb)) + cache_inode = I2CI(inode); + if (!cache_inode || !S2CSB(inode->i_sb)) { + EXIT; return; + } pre_smfs_inode(inode, cache_inode); if (S2CSB(inode->i_sb)->s_op->dirty_inode) @@ -241,57 +250,50 @@ static void smfs_dirty_inode(struct inode *inode) static void smfs_put_inode(struct inode *inode) { struct inode *cache_inode; - ENTRY; + cache_inode = I2CI(inode); + LASSERT(cache_inode != NULL); - if (!cache_inode) { - CWARN("cache inode null\n"); - return; - } - - if (atomic_read(&cache_inode->i_count) > 1) { + if (atomic_read(&cache_inode->i_count) > 1) iput(cache_inode); - } - - 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 && + + /* + * 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 && cache_inode->i_sb->s_root->d_inode != cache_inode) smfs_clear_inode_info(inode); EXIT; } -static void smfs_write_super(struct super_block *sb) +static void smfs_clear_inode(struct inode *inode) { ENTRY; - - if (!S2CSB(sb)) - return; - - if (S2CSB(sb)->s_op->write_super) - S2CSB(sb)->s_op->write_super(S2CSB(sb)); - duplicate_sb(sb, S2CSB(sb)); + smfs_clear_inode_info(inode); EXIT; - return; } -static void smfs_clear_inode(struct inode *inode) +static void smfs_write_super(struct super_block *sb) { - struct inode *cache_inode; - ENTRY; - if (!inode) return; - - cache_inode = I2CI(inode); + if (!S2CSB(sb)) { + EXIT; + return; + } - smfs_clear_inode_info(inode); - + 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_write_super_lockfs(struct super_block *sb) @@ -300,8 +302,10 @@ static void smfs_write_super_lockfs(struct super_block *sb) ENTRY; cache_sb = S2CSB(sb); - if (!cache_sb) + if (!cache_sb) { + EXIT; return; + } if (cache_sb->s_op->write_super_lockfs) cache_sb->s_op->write_super_lockfs(cache_sb); @@ -316,8 +320,10 @@ static void smfs_unlockfs(struct super_block *sb) ENTRY; cache_sb = S2CSB(sb); - if (!cache_sb) + if (!cache_sb) { + EXIT; return; + } if (cache_sb->s_op->unlockfs) cache_sb->s_op->unlockfs(cache_sb); @@ -344,7 +350,6 @@ 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) @@ -364,6 +369,7 @@ 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 f9d9c2c..4faae61 100644 --- a/lustre/smfs/ioctl.c +++ b/lustre/smfs/ioctl.c @@ -168,10 +168,11 @@ 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 81a7e1c..6ddf777 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); - int index = GET_REC_PACK_TYPE_INDEX(smsi->smsi_flags); - - return smsi->smsi_pack_rec[index]; + idx = GET_REC_PACK_TYPE_INDEX(smsi->smsi_flags); + return smsi->smsi_pack_rec[idx]; } static int smfs_post_kml_rec(struct inode *dir, void *de, void *data1, @@ -78,16 +78,22 @@ 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); - ost_rec_pack_init(smfs_info); - mds_rec_pack_init(smfs_info); + rc = ost_rec_pack_init(smfs_info); + if (rc) + return rc; + + rc = mds_rec_pack_init(smfs_info); + if (rc) + return rc; rec_hops = smfs_alloc_hook_ops(KML_HOOK, NULL, smfs_rec_post_hook); if (!rec_hops) { @@ -113,7 +119,8 @@ 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; @@ -139,11 +146,12 @@ 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); @@ -157,10 +165,11 @@ 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(rc); + + return 0; } EXPORT_SYMBOL(smfs_rec_unpack); @@ -264,7 +273,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; @@ -322,9 +331,8 @@ 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); @@ -435,8 +443,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; @@ -475,10 +483,10 @@ exit: static int smfs_post_rec_link(struct inode *dir, struct dentry *dentry, void *data1, void *data2) { - struct smfs_super_info *sinfo; - struct dentry *old_dentry = (struct dentry *)data1; - char *buffer = NULL, *pbuf = NULL; + 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; sinfo = S2SMI(dir->i_sb); if (!sinfo) @@ -489,6 +497,7 @@ 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); @@ -496,13 +505,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->d_parent, - old_dentry->d_parent, REINT_LINK); + rc = smfs_pack_rec(pbuf, dentry, dir, dentry, + new_dentry, REINT_LINK); if (rc <= 0) GOTO(exit, rc); - else - length += rc; - rc = smfs_llog_add_rec(sinfo, (void*)buffer, length); + + length += rc; + rc = smfs_llog_add_rec(sinfo, (void *)buffer, length); exit: if (buffer) OBD_FREE(buffer, PAGE_SIZE); @@ -574,8 +583,9 @@ 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 7bc87d7..7b9de0f 100644 --- a/lustre/smfs/mds_kml.c +++ b/lustre/smfs/mds_kml.c @@ -40,61 +40,56 @@ static int mds_rec_link_pack(char *buffer, struct dentry *dentry, struct inode *dir, void *data1, void *data2) { - struct mdc_op_data op_data; + struct dentry *src = (struct dentry *)data1; + struct dentry *tgt = (struct dentry *)data2; 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; - int rc = 0; + struct mdc_op_data op_data; + void *tmp = NULL; + int rc = 0; - ll_prepare_mdc_op_data(&op_data, src->d_inode, dir, tgt->d_name.name, - tgt->d_name.len, 0); + mdc_prepare_mdc_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 - *opcode + mkpi + request - */ + /* the mds reint log format is: 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; - char *ea = NULL; - void *tmp = NULL; - int rc = 0, ealen = 0; + struct mdc_op_data op_data; + int rc = 0, ealen = 0; + char *ea = NULL; + void *tmp = NULL; - ll_prepare_mdc_op_data(&op_data, dir, NULL, NULL, 0, 0); + mdc_prepare_mdc_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); @@ -105,9 +100,8 @@ static int mds_rec_setattr_pack(char *buffer, struct dentry *dentry, tmp = mdc_setattr_pack(msg, 0, &op_data, iattr, ea, ealen, NULL, 0); - /*There are maybe some better ways - *to set the time attr FIXME WANGDI later - */ + /* FIXME-WANGDI: there are maybe some better ways to set the time + * attr. */ rec = (struct mds_rec_setattr *)lustre_msg_buf(msg, 0, 0); if (rec->sa_valid & ATTR_CTIME) rec->sa_valid |= ATTR_CTIME_SET; @@ -116,38 +110,41 @@ 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; - struct mds_kml_pack_info *mkpi; - void *tmp = NULL; - int rc = 0, tgt_len = 0; + 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); - 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); @@ -156,31 +153,32 @@ 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_replayfid = op_data.fid2; + rec->cr_replayid = op_data.id2; 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 mdc_op_data op_data; struct mds_kml_pack_info *mkpi; - int mode = *(int*)data1; - void *tmp = NULL; - int rc = 0; + struct mdc_op_data op_data; + int mode = *(int*)data1; + void *tmp = NULL; + int rc = 0; - ll_prepare_mdc_op_data(&op_data, dir, NULL, dentry->d_name.name, - dentry->d_name.len, mode); + mdc_prepare_mdc_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->mpi_bufcount = 2; mkpi->mpi_size[0] = sizeof(struct mds_rec_unlink); mkpi->mpi_size[1] = op_data.namelen + 1; @@ -199,20 +197,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 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 inode *new_dir = (struct inode *)data1; struct mds_kml_pack_info *mkpi; + struct lustre_msg *msg = NULL; + struct mdc_op_data op_data; struct mds_rec_rename *rec; - void *tmp = NULL; - int rc = 0; + void *tmp = NULL; + int rc = 0; - ll_prepare_mdc_op_data(&op_data, dir, new_dir->d_inode, NULL, 0, 0); + mdc_prepare_mdc_data(&op_data, dir, new_dir, NULL, 0, 0); PACK_KML_REC_INIT(buffer, MDS_REINT); - 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; @@ -220,6 +218,7 @@ 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); @@ -234,6 +233,7 @@ 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,7 +252,6 @@ 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 c334aff..c0dd244 100644 --- a/lustre/smfs/ost_kml.c +++ b/lustre/smfs/ost_kml.c @@ -51,6 +51,7 @@ 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) @@ -166,6 +167,7 @@ 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] = { @@ -187,6 +189,5 @@ 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 ebca06e..5b73d03 100644 --- a/lustre/smfs/smfs_internal.h +++ b/lustre/smfs/smfs_internal.h @@ -292,8 +292,9 @@ 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 b4561c7..f47f869 100644 --- a/lustre/smfs/smfs_lib.c +++ b/lustre/smfs/smfs_lib.c @@ -45,8 +45,9 @@ #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; @@ -74,7 +75,7 @@ static char *smfs_options(char *data, char **devstr, char **namestr, 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); @@ -85,6 +86,35 @@ static char *smfs_options(char *data, char **devstr, char **namestr, } 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; @@ -94,14 +124,16 @@ static struct smfs_super_info *smfs_init_smb(struct super_block *sb) if (!smb) RETURN(NULL); - S2SMI(sb) = smb; + S2FSI(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); @@ -109,7 +141,8 @@ 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); @@ -137,11 +170,10 @@ 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)); } @@ -185,11 +217,10 @@ 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; @@ -206,7 +237,6 @@ 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) @@ -218,8 +248,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) { @@ -243,7 +273,6 @@ 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) @@ -273,7 +302,8 @@ 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) @@ -282,7 +312,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; @@ -294,17 +324,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 mandatory\n"); + CERROR("mount options name and dev are mandatory\n"); free_page(page); GOTO(out_err, err = -EINVAL); } - err = smfs_mount_cache(smb, devstr, typestr, opts); + 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, 0); + GOTO(out_err, err); } duplicate_sb(sb, smb->smsi_sb); @@ -313,9 +343,11 @@ 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); - GOTO(out_err, 0); + smfs_umount_cache(smb); + GOTO(out_err, err); } - /*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); @@ -327,13 +359,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=-EINVAL); + GOTO(out_err, err = -ENOMEM); } err = smfs_init_hooks(sb); if (err) { smfs_umount_cache(smb); - GOTO(out_err, err=-EINVAL); + GOTO(out_err, err); } #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) CDEBUG(D_SUPER, "sb %lx, &sb->u.generic_sbp: %lx\n", @@ -348,6 +380,7 @@ 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) { @@ -402,6 +435,7 @@ 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 cfecc3e..5e6ffe0 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 dd92c0b..0f03e0f 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 99e839f..69496e5 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 new file mode 100644 index 0000000..35d25f1 --- /dev/null +++ b/lustre/tests/cmobd.sh @@ -0,0 +1,122 @@ +#!/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 983df93..728407d 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 --real_obd obd1 --cache_obd obd2 +${LMC} --add cobd --node localhost --master_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 08b9de8..68da2b5 100644 --- a/lustre/tests/cobd_test.sh +++ b/lustre/tests/cobd_test.sh @@ -1,5 +1,4 @@ -#export PATH=`dirname $0`/../utils:/r/sbin/:/r/usr/bin/:$PATH -export PATH=./../utils:/r/sbin/:/r/usr/bin/:$PATH +export PATH="$PATH:./../utils:/r/sbin:/r/usr/bin" LCTL=${LCTL:-"lctl"} TMP=${TMP:-"/tmp"} @@ -9,11 +8,11 @@ MNTPATH=${MNTPATH:-"/mnt/lustre"} TARCMD=${TARCMD:-"tar"} UNTARCMD=${UNTARCMD:-"tar -zxvf"} CPCMD=${CPCMD:-"cp -f"} -CACHEMDS=${CACHEMDS:-$TMP/mds1-uml} -REALMDS=${REALMDS:-$TMP/mds2-uml} +CACHEMDS=${CACHEMDS:-$TMP/mds1-`hostname`} +REALMDS=${REALMDS:-$TMP/mds3-`hostname`} -CACHEOST=${CACHEOST:-$TMP/ost1-uml} -REALOST=${REALOST:-$TMP/ost2-uml} +CACHEOST=${CACHEOST:-$TMP/ost1-`hostname`} +REALOST=${REALOST:-$TMP/ost3-`hostname`} MDS_CMOBD_INDEX=${MDS_CMOBD_INDEX:-12} OST_CMOBD_INDEX=${OST_CMOBD_INDEX:-14} @@ -22,8 +21,8 @@ MDS_COBD_INDEX=${MDS_COBD_INDEX:-22} OST_COBD_INDEX=${OST_COBD_INDEX:-19} -if ! [ -e "$TMP/$TARBALL" ]; then - echo "$TARBALL did not exist, please give a tar ball for test in your $TMP" +if ! [ -e "$TARBALL" ]; then + echo "$TARBALL does not exist" fi show_filesystem() { @@ -61,14 +60,12 @@ 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 ...." @@ -76,8 +73,9 @@ show_filesystem $CACHEMDS $CACHEOST #first step cp the tar to cache dev and untar it echo "cp $TARBALL to lustre dir and untar ..." -${CPCMD} $TMP/${TARBALL} ${MNTPATH} || exit 1 -${UNTARCMD} ${MNTPATH}/${TARBALL} -C ${MNTPATH} > /dev/null || exit 2 +${CPCMD} ${TARBALL} ${MNTPATH} || exit 1 +${UNTARCMD} ${MNTPATH}/`basename ${TARBALL}` -C ${MNTPATH} > /dev/null || exit 2 + #show status of the filesystem echo after cp show the filsystem.... show_filesystem $CACHEMDS $CACHEOST @@ -92,10 +90,7 @@ echo .... done! #third step and write files to real dev mkdir -p $MNTPATH/new -$CPCMD -f $TMP/$TARBALL $MNTPATH/new || exit 1 -$UNTARCMD $MNTPATH/new/$TARBALL -C $MNTPATH/new > /dev/null || exit 2 +$CPCMD -f $TARBALL $MNTPATH/new || exit 1 +$UNTARCMD $MNTPATH/new/`basename $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 0d8cbb1..586e870 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 f3d7d2e..13886f9 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 --nspath /mnt/ost_ns --node localhost --lov lov1 \ ---fstype $FSTYPE --backfstype $OST_BACKFSTYPE --dev $OSTDEV \ +${LMC} --add ost --ost ost1 --nspath /mnt/ost_ns --node localhost --lov lov1 \ +--fstype $OST_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 new file mode 100644 index 0000000..d357cfa --- /dev/null +++ b/lustre/tests/sanity-cmobd.sh @@ -0,0 +1,310 @@ +#!/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 b6d051c..54ac543 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -7,10 +7,8 @@ set -e ONLY=${ONLY:-"$*"} -# 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"} - +# bug number for skipped test: 2739 +ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"65a 65b 65c 65d 65e 65f"} # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT" @@ -795,7 +793,7 @@ test_27c() { mkdir $DIR/d27 fi $LSTRIPE $DIR/d27/f01 65536 0 2 || error "lstripe failed" - [ `$LFIND $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] || + [ `$LFIND $DIR/d27/f01 --quiet | grep [^[:blank:]*] | wc -l` -eq 2 ] || error "two-stripe file doesn't have two stripes" pass log "== test_27d: write to two stripe file file f01 ================" @@ -1662,18 +1660,17 @@ 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)" @@ -1871,25 +1868,25 @@ test_56() { done # test lfs find with --recursive - FILENUM=`$LFIND --recursive $DIR/d56 | grep -c obdidx` + FILENUM=`$LFIND --recursive $DIR/d56 | grep -v OBDS | grep -c obdidx` [ $FILENUM -eq $NUMFILESx2 ] || error \ "lfs find --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2" - FILENUM=`$LFIND $DIR/d56 | grep -c obdidx` + FILENUM=`$LFIND $DIR/d56 | grep -v OBDS | 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 -c obdidx` + FILENUM=`$LFIND $DIR/d56/file1 | grep -v OBDS | 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 -c lmm_magic` -eq $NUMFILES ] ||\ + [ `$LFIND --verbose $DIR/d56 | grep -v OBDS | grep -c lmm_magic` -eq $NUMFILES ] ||\ error "lfs find --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info" - [ `$LFIND $DIR/d56 | grep -c lmm_magic` -eq 0 ] || error \ + [ `$LFIND $DIR/d56 | grep -v OBDS | 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." @@ -1899,14 +1896,17 @@ test_56() { [ "$OSTCOUNT" -lt 2 ] && \ echo "skipping other lfs find --obd test" && return - 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` + 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` + [ $FOUND -eq $FILENUM ] || \ error "lfs find --obd wrong: found $FOUND, expected $FILENUM" - [ `$LFIND -r -v --obd $OBDUUID $DIR/d56 | sed '/^[ ]*1[ ]/d' | \ - sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] || \ + + [ `$LFIND -r -v --obd $OBDUUID $DIR/d56 | grep "^[[:blank:]]*$OBDIDX" | wc -l` ] || \ 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 7e6ee93..966ac1e 100644 --- a/lustre/tests/uml_cobd.sh +++ b/lustre/tests/uml_cobd.sh @@ -12,21 +12,20 @@ COBD_OST=${COBD_OST:-"cobd2"} CMOBD_MDS=${CMOBD_MDS:-"cmobd1"} CMOBD_OST=${CMOBD_OST:-"cmobd2"} - CACHE_MDS=${CACHE_MDS:-"mds1"} -REAL_MDS=${REAL_MDS:-"mds2"} +MASTER_MDS=${MASTER_MDS:-"mds2"} MDS_CACHE_DEV=$TMP/mds1-`hostname` -MDS_REAL_DEV=$TMP/mds2-`hostname` +MDS_MASTER_DEV=$TMP/mds2-`hostname` MDS_DEV=$TMP/mds MDSSIZE=${MDSSIZE:-100000} CACHE_LOV=${CACHE_LOV:-"lov1"} -REAL_LOV=${REAL_LOV:-"lov2"} +MASTER_LOV=${MASTER_LOV:-"lov2"} CACHE_OST=${CACHE_OST:-"ost1"} -REAL_OST=${REAL_OST:-"ost2"} +MASTER_OST=${MASTER_OST:-"ost2"} OST_CACHE_DEV=$TMP/ost1-`hostname` -OST_REAL_DEV=$TMP/ost2-`hostname` +OST_MASTER_DEV=$TMP/ost2-`hostname` OST_DEV=$TMP/ost OSTSIZE=${OSTSIZE:-100000} @@ -41,10 +40,10 @@ BACKUP_FSTYPE=${BACKUP_FSTYPE:-ext3} NETTYPE=${NETTYPE:-tcp} NIDTYPE=${NIDTYPE:-$NETTYPE} -MDSNODE=${MDSNODE:-uml} -OSTNODE=${OSTNODE:-uml} -CLIENT=${CLIENT:-"uml"} -NODE=${NODE:-"uml"} +MDSNODE=${MDSNODE:-`hostname`} +OSTNODE=${OSTNODE:-`hostname`} +CLIENT=${CLIENT:-`hostname`} +NODE=${NODE:-`hostname`} MDS_MOUNT_OPTS=${MDS_MOUNT_OPTS:-"kml"} OST_MOUNT_OPTS=${OST_MOUNT_OPTS:-"kml"} @@ -65,19 +64,20 @@ ${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 --add mds --format --node $MDSNODE --mds $CACHE_MDS --fstype $FSTYPE \ +${LMC} -m $config --format --add mds --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 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 "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 "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 real lov on: $MDSNODE" -${LMC} -m $config --add lov --lov $REAL_LOV --mds $REAL_MDS \ + +echo "add master lov on: $MDSNODE" +${LMC} -m $config --add lov --lov $MASTER_LOV --mds $MASTER_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 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 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 mds lov: $COBD_MDS $COBD_OST" -${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 +${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 # create client config(s) echo "add cmobd: $CMOBD_MDS $CMOBD_OST" -${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 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 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 828db61..53c032d 100755 --- a/lustre/utils/lconf +++ b/lustre/utils/lconf @@ -737,17 +737,6 @@ 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 = () @@ -895,8 +884,6 @@ 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 @@ -905,8 +892,9 @@ def init_loop(file, size, fstype, journal_size, inode_size, if fstype == 'smfs': realfile = backfile realfstype = backfstype - if is_block(backfile): - if reformat or (need_format(realfstype, backfile) and autoformat == 'yes'): + + if is_block(realfile): + if reformat or (need_format(realfstype, realfile) and autoformat == 'yes'): mkfs(realfile, size, realfstype, journal_size, inode_size, mkfsoptions, isblock=0) return realfile else: @@ -915,20 +903,21 @@ 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) @@ -936,6 +925,7 @@ 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" @@ -944,19 +934,31 @@ def init_loop(file, size, fstype, journal_size, inode_size, return '' # undo loop assignment -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) +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) # 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): @@ -1066,19 +1068,6 @@ 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""" @@ -1097,7 +1086,7 @@ def is_prepared(name): e.dump() return 0 -def is_network_prepared(): +def network_is_prepared(): """If the any device exists, then assume that all networking has been configured""" out = lctl.device_list() @@ -1117,55 +1106,153 @@ 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.""" - self.kmodule_list.append((self.portals_dir, dev_dir, modname)) + + mod = self.find_module(modname) + if not mod: + mod = kmod(self.portals_dir, dev_dir, modname) + self.kmodule_list.append(mod) 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)) - def load_module(self): + 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): """Load all the modules in the list in the order they appear.""" - for src_dir, dev_dir, mod in self.kmodule_list: - if mod_loaded(mod) and not config.noexec: + for mod in self.kmodule_list: + if mod.loaded() and not config.noexec: continue - 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) + mod.load() - def cleanup_module(self): + def cleanup_modules(self): """Unload the modules in the list in reverse order.""" rev = self.kmodule_list rev.reverse() - for src_dir, dev_dir, mod in rev: - if not mod_loaded(mod) and not config.noexec: + for mod in rev: + if (not mod.loaded() or mod.busy()) and not config.noexec: continue # debug hack - if mod == 'portals' and config.dump: + if mod.name == 'portals' and config.dump: lctl.dump(config.dump) - log('unloading module:', mod) - (rc, out) = run('/sbin/rmmod', mod) - if rc: - log('! unable to unload module:', mod) - logall(out) + mod.cleanup() # ============================================================ # Classes to prepare and cleanup the various objects @@ -1181,7 +1268,7 @@ class Module: self.uuid = self.db.getUUID() self._server = None self._connected = 0 - self.kmod = kmod(config.lustre, config.portals) + self.kmod_manager = mod_manager def info(self, *args): msg = string.join(map(str,args)) @@ -1197,22 +1284,9 @@ class Module: e.dump() cleanup_error(e.rc) - 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 add_module(self, manager): + """Adds all needed modules in the order they appear.""" + return def safe_to_clean(self): return 1 @@ -1246,14 +1320,15 @@ class Network(Module): panic("unable to set hostaddr for", self.net_type, self.hostaddr, self.cluster_id) debug("hostaddr:", self.hostaddr) - self.add_portals_module("libcfs", 'libcfs') - self.add_portals_module("portals", 'portals') + def add_module(self, manager): + manager.add_portals_module("libcfs", 'libcfs') + manager.add_portals_module("portals", 'portals') if node_needs_router(): - self.add_portals_module("router", 'kptlrouter') + manager.add_portals_module("router", 'kptlrouter') if self.net_type == 'tcp': - self.add_portals_module("knals/socknal", 'ksocknal') + manager.add_portals_module("knals/socknal", 'ksocknal') if self.net_type == 'elan': - self.add_portals_module("knals/qswnal", 'kqswnal') + manager.add_portals_module("knals/qswnal", 'kqswnal') if self.net_type == 'gm': self.add_portals_module("knals/gmnal", 'kgmnal') if self.net_type == 'openib': @@ -1263,7 +1338,7 @@ class Network(Module): return "NID_%s_UUID" %(nid,) def prepare(self): - if not config.record and is_network_prepared(): + if not config.record and network_is_prepared(): return self.info(self.net_type, self.nid, self.port) if not (config.record and self.generic_nid): @@ -1304,7 +1379,7 @@ class Network(Module): cleanup_error(e.rc) def safe_to_clean(self): - return not is_network_prepared() + return not network_is_prepared() def cleanup(self): self.info(self.net_type, self.nid, self.port) @@ -1347,7 +1422,7 @@ class RouteTable(Module): return Network(srvdb) def prepare(self): - if not config.record and is_network_prepared(): + if not config.record and network_is_prepared(): return self.info() for net_type, gw, gw_cluster_id, tgt_cluster_id, lo, hi in self.db.get_route_tbl(): @@ -1357,10 +1432,10 @@ class RouteTable(Module): lctl.connect(srv) def safe_to_clean(self): - return not is_network_prepared() + return not network_is_prepared() def cleanup(self): - if is_network_prepared(): + if network_is_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(): @@ -1380,14 +1455,42 @@ 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) - self.add_lustre_module('lvfs', 'lvfs') - self.add_lustre_module('obdclass', 'obdclass') - self.add_lustre_module('ptlrpc', 'ptlrpc') + + def add_module(self, manager): + manager.add_lustre_module('lvfs', 'lvfs') + manager.add_lustre_module('obdclass', 'obdclass') + manager.add_lustre_module('ptlrpc', 'ptlrpc') def prepare(self): return @@ -1398,13 +1501,11 @@ 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) @@ -1466,22 +1567,13 @@ class LOV(Module): if self.config_only: panic("Can't clean up config_only LOV ", self.name) - def load_module(self): + def add_module(self, manager): if self.config_only: panic("Can't load modules for config_only LOV ", self.name) for (osc, index, gen, active) in self.osclist: - 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() + osc.add_module(manager) break + manager.add_lustre_module('lov', 'lov') def correct_level(self, level, op=None): return level @@ -1491,12 +1583,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: @@ -1510,6 +1602,8 @@ 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 @@ -1527,17 +1621,11 @@ class LMV(Module): if is_prepared(self.name): Module.cleanup(self) - 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) + def add_module(self, manager): for mdc in self.mdclist: - mdc.cleanup_module() + mdc.add_module(manager) break + manager.add_lustre_module('lmv', 'lmv') def correct_level(self, level, op=None): return level @@ -1554,128 +1642,135 @@ 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') - mds = self.db.lookup(target_uuid) - self.name = mds.getName() - self.filesystem_uuids = mds.get_refs('filesystem') - self.lmv_uuid = '' + 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 = "" self.lmv = '' - 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 + + 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 + # FIXME: if fstype not set, then determine based on kernel version self.format = self.db.get_val('autoformat', "no") - if mds.get_val('failover', 0): + if self.mds.get_val('failover', 0): self.failover_mds = 'f' else: self.failover_mds = 'n' - active_uuid = get_active_target(mds) + active_uuid = get_active_target(self.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 != mds.get_val('group'): + if self.active and config.group and config.group != self.mds.get_val('group'): self.active = 0 - self.inode_size = self.db.get_val_int('inodesize', 0) - if self.inode_size == 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: # find the LOV for this MDS - 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): + 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 stripe_count = lov.stripe_cnt - 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 + 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_mds: - client_uuid = generate_client_uuid(self.name) + if self.master_uuid: client_uuid = self.name + "_lmv_" + "UUID" - self.master = LMV(self.db.lookup(self.lmv_uuid), client_uuid, self.name, self.name) - self.master_mds = self.master.name + self.master = LMV(self.db.lookup(self.lmv_uuid), client_uuid, + self.name, self.name) + self.master_uuid = self.master.name - # 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') + 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') - if self.fstype == 'smfs': - self.add_lustre_module('smfs', 'smfs') + if self.fstype == 'smfs': + manager.add_lustre_module('smfs', 'smfs') - if self.fstype == 'ldiskfs': - self.add_lustre_module('ldiskfs', 'ldiskfs') + if self.fstype == 'ldiskfs': + manager.add_lustre_module('ldiskfs', 'ldiskfs') - if self.fstype: - self.add_lustre_module('lvfs', 'fsfilt_%s' % (self.fstype)) + if self.fstype: + manager.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': - 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) + # 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) def prepare(self): if not config.record and is_prepared(self.name): @@ -1688,9 +1783,11 @@ class MDSDEV(Module): self.write_conf() self.info(self.devpath, self.fstype, self.size, self.format) run_acceptors() + # prepare LMV - if self.master_mds: + if self.master_uuid: self.master.prepare() + # never reformat here blkdev = block_dev(self.devpath, self.size, self.fstype, 0, self.format, self.journal_size, self.inode_size, @@ -1730,14 +1827,22 @@ class MDSDEV(Module): print 'MDS mount options: ' + mountfsoptions - if not self.master_mds: - self.master_mds = 'dumb' - if not self.cachetype: - self.cachetype = 'dumb' - lctl.newdev("mds", self.name, self.uuid, + 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, setup ="%s %s %s %s %s %s" %(realdev, self.fstype, self.name, mountfsoptions, - self.master_mds, self.cachetype)) + self.master_uuid, self.obdtype)) if development_mode(): procentry = "/proc/fs/lustre/mds/grp_hash_upcall" @@ -1766,6 +1871,9 @@ 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) @@ -1806,9 +1914,12 @@ 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, @@ -1817,29 +1928,18 @@ 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" %(realdev, self.fstype, - 'dumb', mountfsoptions)) + setup ="%s %s %s %s %s %s" %(realdev, self.fstype, + 'dumb', mountfsoptions, + 'dumb', self.obdtype)) do_cleanup = 1 - # record logs for the MDS lov - for uuid in self.filesystem_uuids: - log("recording clients for filesystem:", uuid) - fs = self.db.lookup(uuid) + # record logs for all MDS clients + for obd_uuid in self.client_uuids: + log("recording client:", obd_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) @@ -1904,11 +2004,9 @@ class MDSDEV(Module): e.dump() cleanup_error(e.rc) Module.cleanup(self) - - if self.fstype == 'smfs': - clean_loop(self.backdevpath) - else: - clean_loop(self.devpath) + + clean_dev(self.devpath, self.fstype, self.backfstype, + self.backdevpath) def msd_remaining(self): out = lctl.device_list() @@ -1921,7 +2019,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") @@ -1937,7 +2035,7 @@ class MDSDEV(Module): cleanup_error(e.rc) Module.cleanup(self) # cleanup LMV - if self.master_mds: + if self.master_uuid: self.master.cleanup() if not self.msd_remaining() and is_prepared('MDT'): try: @@ -1948,13 +2046,11 @@ class MDSDEV(Module): e.dump() cleanup_error(e.rc) - if self.fstype == 'smfs': - clean_loop(self.backdevpath) - else: - clean_loop(self.devpath) + clean_dev(self.devpath, self.fstype, self.backfstype, + self.backdevpath) def correct_level(self, level, op=None): - #if self.master_mds: + #if self.master_uuid: # level = level + 2 return level @@ -1993,30 +2089,29 @@ class OSD(Module): self.target_dev_uuid = self.uuid self.uuid = target_uuid - # 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)) + + 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)) - self.add_lustre_module(self.osdtype, self.osdtype) + 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)) - def load_module(self): - if self.active: - Module.load_module(self) + manager.add_lustre_module(self.osdtype, self.osdtype) # need to check /proc/mounts and /etc/mtab before # formatting anything. @@ -2110,10 +2205,8 @@ class OSD(Module): e.dump() cleanup_error(e.rc) if not self.osdtype == 'obdecho': - if self.fstype == 'smfs': - clean_loop(self.backdevpath) - else: - clean_loop(self.devpath) + clean_dev(self.devpath, self.fstype, self.backfstype, + self.backdevpath) def correct_level(self, level, op=None): return level @@ -2124,6 +2217,8 @@ 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 = [] @@ -2132,7 +2227,7 @@ class Client(Module): if not self.tgt_dev_uuid: panic("No target device found for target(1):", self.target_name) - self.kmod = kmod(config.lustre, config.portals) + self.kmod_manager = kmod_manager(config.lustre, config.portals) self._server = None self._connected = 0 @@ -2148,17 +2243,21 @@ class Client(Module): self.lookup_backup_targets() self.fs_name = fs_name - if not module_dir: - module_dir = module - self.add_lustre_module(module_dir, module) + if not self.module_dir: + self.module_dir = module + + def add_module(self, manager): + manager.add_lustre_module(self.module_dir, self.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): @@ -2268,89 +2367,51 @@ class OSC(Client): def permits_inactive(self): return 1 -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() +def mgmtcli_name_for_uuid(uuid): + return 'MGMTCLI_%s' % uuid - def correct_level(self, level, op=None): - return level +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') 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) - - 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: + + 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': 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. @@ -2363,78 +2424,97 @@ 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 load_module(self): - self.master.load_module() - Module.load_module(self) + def add_module(self, manager): + manager.add_lustre_module('cmobd', 'cmobd') + self.master.add_module(manager) - 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, type, name_override = None): + def __init__(self, db, uuid, name): Module.__init__(self, 'COBD', db) self.name = self.db.getName(); self.uuid = generate_client_uuid(self.name) - self.real_uuid = self.db.get_first_ref('realobd') + self.master_uuid = self.db.get_first_ref('masterobd') self.cache_uuid = self.db.get_first_ref('cacheobd') - 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) + + 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) - if type == 'obd': - self.real = LOV(real_obd, self.real_uuid, name, - "%s_real" % (self.name)); + + 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)); self.cache = LOV(cache_obd, self.cache_uuid, name, - "%s_cache" % (self.name)); - else: - self.real = get_mdc(db, name, self.real_uuid) - self.cache = get_mdc(db, name, self.cache_uuid) + "%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)); + # 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_real_name(self): - return self.real.name + + def get_master_name(self): + return self.master.name + def get_cache_name(self): return self.cache.name + def prepare(self): - self.real.prepare() + self.master.prepare() self.cache.prepare() if not config.record and is_prepared(self.name): return - self.info(self.real_uuid, self.cache_uuid) + self.info(self.master_uuid, self.cache_uuid) lctl.newdev("cobd", self.name, self.uuid, - setup ="%s %s" %(self.real.name, + setup ="%s %s" %(self.master.name, self.cache.name)) def cleanup(self): if is_prepared(self.name): Module.cleanup(self) - self.real.cleanup() + self.master.cleanup() self.cache.cleanup() - def load_module(self): - self.real.load_module() - Module.load_module(self) - - def cleanup_module(self): - Module.cleanup_module(self) - self.real.cleanup_module() + def add_module(self, manager): + manager.add_lustre_module('cobd', 'cobd') + self.master.add_module(manager) # virtual interface for OSC and LOV class VOSC(Module): @@ -2444,23 +2524,27 @@ 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, 'obd') + self.osc = COBD(db, client_uuid, name) 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 load_module(self): - self.osc.load_module() - def cleanup_module(self): - self.osc.cleanup_module() + + def add_module(self, manager): + self.osc.add_module(manager) + def correct_level(self, level, op=None): return self.osc.correct_level(level, op) @@ -2471,28 +2555,31 @@ 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, 'mds') + self.mdc = COBD(db, client_uuid, name) 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 load_module(self): - self.mdc.load_module() - def cleanup_module(self): - self.mdc.cleanup_module() + + def add_module(self, manager): + self.mdc.add_module(manager) + 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) @@ -2513,13 +2600,9 @@ class ECHO_CLIENT(Module): Module.cleanup(self) self.osc.cleanup() - 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 add_module(self, manager): + self.osc.add_module(manager) + manager.add_lustre_module('obdecho', 'obdecho') def correct_level(self, level, op=None): return level @@ -2560,6 +2643,7 @@ 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) @@ -2570,18 +2654,22 @@ 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() @@ -2633,14 +2721,19 @@ class Mountpoint(Module): self.vmdc.cleanup() self.vosc.cleanup() + if self.mgmtcli: + self.mgmtcli.cleanup() - def load_module(self): - self.vosc.load_module() - Module.load_module(self) + 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 cleanup_module(self): - Module.cleanup_module(self) - self.vosc.cleanup_module() + manager.add_lustre_module('llite', 'llite') def correct_level(self, level, op=None): return level @@ -3042,17 +3135,36 @@ def doSetup(services): for n in nlist: n[1].prepare() -def doModules(services): +def doLoadModules(services): if config.nomod: return + + # adding all needed modules from all services for s in services: n = newService(s[1]) - n.load_module() + 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() def doCleanup(services): if config.nosetup: return slist = [] + for s in services: n = newService(s[1]) n.level = s[0] @@ -3063,19 +3175,11 @@ 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): @@ -3105,7 +3209,7 @@ def doHost(lustreDB, hosts): prof_list = node_db.get_refs('profile') if config.write_conf: - for_each_profile(node_db, prof_list, doModules) + for_each_profile(node_db, prof_list, doLoadModules) sys_make_devices() for_each_profile(node_db, prof_list, doWriteconf) for_each_profile(node_db, prof_list, doUnloadModules) @@ -3148,7 +3252,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, doModules) + for_each_profile(node_db, prof_list, doLoadModules) sys_set_debug_path() sys_set_ptldebug(ptldebug) @@ -3452,7 +3556,7 @@ lconf_options = [ ] def main(): - global lctl, config, toplustreDB, CONFIG_FILE + global lctl, config, toplustreDB, CONFIG_FILE, mod_manager # in the upcall this is set to SIG_IGN signal.signal(signal.SIGCHLD, signal.SIG_DFL) @@ -3559,6 +3663,9 @@ 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 3fea4e2..d2d02a6b 100755 --- a/lustre/utils/lmc +++ b/lustre/utils/lmc @@ -164,13 +164,13 @@ Object creation command summary: --add cobd --node node_name - --real_obd obd_name + --master_obd obd_name --cache_obd obd_name --add cmobd --node node_name - --master_dev obd_name - --cache_dev obd_name + --master_obd obd_name + --cache_obd obd_name --commit - Close a configuration version, and start a new one """ @@ -252,22 +252,19 @@ 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 - - ('real_obd', "Specify the real device for the cache obd system.", PARAM), + # cobd and cmobd + ('master_obd', "Specify the master 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 - ('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), + ('cmobd', "Specify CMOBD name", PARAM, ""), ('mgmt', "Specify management/monitoring service name.", PARAM, ""), # lmv - ('lmv', "Specify LMV name.", PARAM,""), + ('lmv', "Specify LMV name.", PARAM, ""), ] def error(*args): @@ -439,7 +436,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) @@ -464,15 +461,15 @@ class GenConfig: self.addElement(osd, "nspath", nspath) return osd - def cobd(self, name, uuid, real_uuid, cache_uuid): + def cobd(self, name, uuid, master_uuid, cache_uuid): cobd = self.newService("cobd", name, uuid) - cobd.appendChild(self.ref("realobd",real_uuid)) + cobd.appendChild(self.ref("masterobd",master_uuid)) cobd.appendChild(self.ref("cacheobd",cache_uuid)) return cobd - def cmobd(self, name, uuid, real_uuid, cache_uuid): + def cmobd(self, name, uuid, master_uuid, cache_uuid): cmobd = self.newService("cmobd", name, uuid) - cmobd.appendChild(self.ref("masterobd",real_uuid)) + cmobd.appendChild(self.ref("masterobd",master_uuid)) cmobd.appendChild(self.ref("cacheobd",cache_uuid)) return cmobd @@ -514,7 +511,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 @@ -526,13 +523,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: @@ -549,7 +546,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)) @@ -817,40 +814,6 @@ 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: @@ -899,7 +862,6 @@ def do_add_node(gen, lustre, options, node_name): return node - def add_node(gen, lustre, options): """ create a node with a network config """ @@ -910,7 +872,6 @@ 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 """ @@ -941,7 +902,6 @@ 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 """ @@ -971,7 +931,6 @@ 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') @@ -1035,7 +994,6 @@ 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') @@ -1054,6 +1012,9 @@ 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') @@ -1113,7 +1074,6 @@ 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, @@ -1173,18 +1133,64 @@ def add_cmobd(gen, lustre, options): name = get_option(options, 'cmobd') uuid = new_uuid(name) - real_name = get_option(options, 'master_dev') - cache_name = get_option(options, 'cache_dev') + 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 + "'") node = findByName(lustre, node_name, "node") node_add_profile(gen, node, "cmobd", 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) + + 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) lustre.appendChild(cmobd) def add_cobd(gen, lustre, options): @@ -1192,23 +1198,24 @@ def add_cobd(gen, lustre, options): name = get_option(options, 'cobd') uuid = new_uuid(name) - real_name = get_option(options, 'real_obd') + master_name = get_option(options, 'master_obd') cache_name = get_option(options, 'cache_obd') - real_uuid = name2uuid(lustre, real_name, tag='lov', fatal=0) + master_uuid = name2uuid(lustre, master_name, tag='lov', fatal=0) cache_uuid = name2uuid(lustre, cache_name, tag='lov', fatal=0) - if real_uuid: - node = lookup(lustre, real_uuid) + if master_uuid: + node = lookup(lustre, master_uuid) rets = node.getElementsByTagName('lov_tgt') for ret in rets: ost_uuid = ret.getAttribute('uuidref') ost_node = lookup(lustre, ost_uuid) - ret = ost_node.getElementsByTagName('active_ref') - if ret: - osd_uuid = ret[0].getAttribute('uuidref') + active = ost_node.getElementsByTagName('active_ref') + if active: + osd_uuid = active[0].getAttribute('uuidref') osd_node = lookup(lustre, osd_uuid) - gen.addElement(osd_node, 'cachetype', 'master') + if not osd_node.getElementsByTagName('obdtype'): + gen.addElement(osd_node, 'obdtype', 'master') if cache_uuid: node = lookup(lustre, cache_uuid) @@ -1216,32 +1223,35 @@ def add_cobd(gen, lustre, options): for ret in rets: ost_uuid = ret.getAttribute('uuidref') ost_node = lookup(lustre, ost_uuid) - ret = ost_node.getElementsByTagName('active_ref') - if ret: - osd_uuid = ret[0].getAttribute('uuidref') + active = ost_node.getElementsByTagName('active_ref') + if active: + osd_uuid = active[0].getAttribute('uuidref') osd_node = lookup(lustre, osd_uuid) - gen.addElement(osd_node, 'cachetype', 'cache') + if not osd_node.getElementsByTagName('obdtype'): + gen.addElement(osd_node, 'obdtype', 'cache') - if not real_uuid or not cache_uuid: - real_uuid = name2uuid(lustre,real_name, tag='mds') + if not master_uuid or not cache_uuid: + master_uuid = name2uuid(lustre,master_name, tag='mds') cache_uuid = name2uuid(lustre,cache_name, tag='mds') - if real_uuid: - mds_node = lookup(lustre, real_uuid) + if master_uuid: + mds_node = lookup(lustre, master_uuid) ret = mds_node.getElementsByTagName('active_ref') if ret: mdsdev_uuid = ret[0].getAttribute('uuidref') mdsdev_node = lookup(lustre, mdsdev_uuid) - gen.addElement(mdsdev_node, 'cachetype', 'master') + if not mdsdev_node.getElementsByTagName('obdtype'): + gen.addElement(mdsdev_node, 'obdtype', '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) - gen.addElement(mdsdev_node, 'cachetype', 'cache') + if not mdsdev_node.getElementsByTagName('obdtype'): + gen.addElement(mdsdev_node, 'obdtype', 'cache') node = findByName(lustre, node_name, "node") - cobd = gen.cobd(name, uuid, real_uuid, cache_uuid) + cobd = gen.cobd(name, uuid, master_uuid, cache_uuid) lustre.appendChild(cobd) @@ -1274,9 +1284,8 @@ def add_lov(gen, lustre, options): warning("name:", lov_orig, "already used. using:", name) mds_name = get_option(options, 'mds') - if not mds_name: - if not lmv_name: - error("LOV: MDS or LMV must be specified."); + if not mds_name and 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') @@ -1287,7 +1296,7 @@ def add_lov(gen, lustre, options): if ret: error("LOV: ", name, " already exists.") - if not mds_name: + if lmv_name: mds_uuid = name2uuid(lustre, lmv_name, 'lmv') else: mds_uuid = name2uuid(lustre, mds_name, 'mds') @@ -1301,9 +1310,13 @@ 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) @@ -1350,20 +1363,10 @@ 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) - 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)) + + obd = lookup(lustre, mds_uuid) + obd.appendChild(gen.ref("client", obd_uuid)) + fs = gen.filesystem(fs_name, fs_uuid, mds_uuid, obd_uuid, mgmt_uuid) lustre.appendChild(fs) return fs_uuid @@ -1373,17 +1376,22 @@ 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='lov', fatal=0) - if obd_uuid == '': - obd_uuid = name2uuid(lustre, obd_name, tag='cobd') + 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) 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): @@ -1455,7 +1463,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 it is set, otherwise exception.""" + set, then if return default if 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 ca17073..9565aaa 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 2cf74f9a..3313169 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -2386,9 +2386,10 @@ 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: rc=%d\n", - rc); + if (rc) { + fprintf(stderr, "OBD_IOC_CMOBD_SYNC failed: %s\n", + strerror(errno)); + } return rc; } @@ -2404,9 +2405,10 @@ 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_CMOBD_SYNC failed: rc=%d\n", - rc); + if (rc) { + fprintf(stderr, "OBD_IOC_COBD_CON failed: %s\n", + strerror(errno)); + } return rc; } @@ -2420,9 +2422,10 @@ 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_CMOBD_SYNC failed: rc=%d\n", - rc); + if (rc) { + fprintf(stderr, "OBD_IOC_COBD_COFF failed: %s\n", + strerror(errno)); + } return rc; } int jt_obd_snap_add(int argc, char **argv) @@ -2448,9 +2451,11 @@ 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) @@ -2459,7 +2464,8 @@ 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 3101832..89f2ec0 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -117,6 +117,7 @@ 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); @@ -231,13 +232,13 @@ check_ost_body(void) } void -check_ll_fid(void) +check_lustre_stc(void) { BLANK_LINE(); - CHECK_STRUCT(ll_fid); - CHECK_MEMBER(ll_fid, id); - CHECK_MEMBER(ll_fid, generation); - CHECK_MEMBER(ll_fid, f_type); + 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); } void @@ -254,13 +255,12 @@ check_mds_body(void) { BLANK_LINE(); CHECK_STRUCT(mds_body); - CHECK_MEMBER(mds_body, fid1); - CHECK_MEMBER(mds_body, fid2); + CHECK_MEMBER(mds_body, id1); + CHECK_MEMBER(mds_body, id2); 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,9 +271,7 @@ 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); @@ -295,7 +293,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_fid); + CHECK_MEMBER(mds_rec_setattr, sa_id); CHECK_MEMBER(mds_rec_setattr, sa_mode); CHECK_MEMBER(mds_rec_setattr, sa_uid); CHECK_MEMBER(mds_rec_setattr, sa_gid); @@ -315,8 +313,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_fid); - CHECK_MEMBER(mds_rec_create, cr_replayfid); + CHECK_MEMBER(mds_rec_create, cr_id); + CHECK_MEMBER(mds_rec_create, cr_replayid); CHECK_MEMBER(mds_rec_create, cr_time); CHECK_MEMBER(mds_rec_create, cr_rdev); } @@ -328,8 +326,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_fid1); - CHECK_MEMBER(mds_rec_link, lk_fid2); + CHECK_MEMBER(mds_rec_link, lk_id1); + CHECK_MEMBER(mds_rec_link, lk_id2); CHECK_MEMBER(mds_rec_link, lk_time); } @@ -340,8 +338,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_fid1); - CHECK_MEMBER(mds_rec_unlink, ul_fid2); + CHECK_MEMBER(mds_rec_unlink, ul_id1); + CHECK_MEMBER(mds_rec_unlink, ul_id2); CHECK_MEMBER(mds_rec_unlink, ul_time); } @@ -352,8 +350,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_fid1); - CHECK_MEMBER(mds_rec_rename, rn_fid2); + CHECK_MEMBER(mds_rec_rename, rn_id1); + CHECK_MEMBER(mds_rec_rename, rn_id2); CHECK_MEMBER(mds_rec_rename, rn_time); } @@ -558,7 +556,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_fid); + CHECK_MEMBER(llog_create_rec, lcr_id); CHECK_MEMBER(llog_create_rec, lcr_oid); CHECK_MEMBER(llog_create_rec, lcr_ogen); } @@ -591,7 +589,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_fid); + CHECK_MEMBER(llog_size_change_rec, lsc_id); CHECK_MEMBER(llog_size_change_rec, lsc_io_epoch); CHECK_MEMBER(llog_size_change_rec, lsc_tail); } @@ -857,7 +855,7 @@ main(int argc, char **argv) check_obd_ioobj(); check_niobuf_remote(); check_ost_body(); - check_ll_fid(); + check_lustre_stc(); check_mds_status_req(); check_mds_body(); check_mds_rec_setattr(); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index c8994ec..3563b8a 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -24,1393 +24,4 @@ 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