Whamcloud - gitweb
Merge of b_md to HEAD:
authoradilger <adilger>
Mon, 2 Dec 2002 08:39:50 +0000 (08:39 +0000)
committeradilger <adilger>
Mon, 2 Dec 2002 08:39:50 +0000 (08:39 +0000)
- fixes of many metadata bugs:
  - multiple client file opens
  - missing/extra intent releases
  - symlink fixes
- OST/MDS server threads clobbering each other
  - dbench 2 works mostly
- many others too numerous to mention here (ChangeLog is a good record)

75 files changed:
lustre/.cvsignore
lustre/ChangeLog
lustre/Makefile.am
lustre/doc/VERSIONING
lustre/include/linux/.cvsignore
lustre/include/linux/lustre_dlm.h
lustre/include/linux/lustre_lib.h
lustre/include/linux/lustre_mds.h
lustre/include/linux/lustre_net.h
lustre/include/linux/obd.h
lustre/include/linux/obd_class.h
lustre/include/linux/obd_support.h
lustre/ldlm/l_lock.c
lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_request.c
lustre/ldlm/ldlm_resource.c
lustre/lib/client.c
lustre/lib/mds_updates.c
lustre/lib/simple.c
lustre/llite/dcache.c
lustre/llite/dir.c
lustre/llite/namei.c
lustre/llite/symlink.c
lustre/lov/lov_obd.c
lustre/mdc/mdc_request.c
lustre/mds/handler.c
lustre/mds/mds_ext3.c
lustre/mds/mds_fs.c
lustre/mds/mds_lov.c
lustre/mds/mds_reint.c
lustre/obdclass/Makefile.am
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/obdecho/echo_client.c
lustre/obdfilter/filter.c
lustre/osc/osc_request.c
lustre/ost/ost_handler.c
lustre/patches/patch-2.4.18-14
lustre/patches/patch-2.4.18-chaos25
lustre/ptlrpc/client.c
lustre/ptlrpc/events.c
lustre/ptlrpc/niobuf.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/recover.c
lustre/ptlrpc/service.c
lustre/scripts/Makefile.am
lustre/scripts/version_tag.pl [new file with mode: 0644]
lustre/tests/Makefile.am
lustre/tests/acceptance-small.sh
lustre/tests/ba-echo.sh
lustre/tests/ba-mount.sh
lustre/tests/create.pl
lustre/tests/leak_finder.pl
lustre/tests/llecho.sh
lustre/tests/llmount.sh
lustre/tests/llmount2-hack.sh [new file with mode: 0644]
lustre/tests/llmountcleanup.sh
lustre/tests/llmountcleanup2-hack.sh [new file with mode: 0644]
lustre/tests/lov.sh
lustre/tests/mcr-routed-config.sh
lustre/tests/rundbench
lustre/tests/runiozone
lustre/tests/runregression-brw.sh
lustre/tests/runregression-net.sh
lustre/tests/runtests
lustre/tests/sanity.sh
lustre/tests/setuid.c [new file with mode: 0644]
lustre/utils/lconf
lustre/utils/lctl.c
lustre/utils/llanalyze
lustre/utils/lmc
lustre/utils/obd.c
lustre/utils/obdctl.c
lustre/utils/obdctl.h

index 953c699..111b232 100644 (file)
@@ -10,3 +10,5 @@ Makefile.in
 tags
 TAGS
 lustre*.tar.gz
+cscope.files
+cscope.out
index 2099fd2..924b3a5 100644 (file)
@@ -5,6 +5,12 @@ TBA
          - credentials weren't being shipped for readdir/getattr operations
          - remove invalid assertions triggered during some concurrent MD
            updates
+         - proper Lustre versions added (336, 389)
+         - fix memory leak for create error case (398)
+         - fix LOV locking bug that would get cli/srv out of sync
+         - fix echo client over LOV (409)
+         - fix dbench 2, extN refcount problem (170, 258, 356, 418)
+         - fix double-O_EXCL intent crash (424)
 
 2002-11-18  Phil Schwan  <phil@clusterfs.com>
        * version v0_5_17
index 11194b3..6fcadf3 100644 (file)
@@ -11,9 +11,9 @@ else
 DIRS24 = extN mds
 endif
 
-# NOTE: keep extN before mds
-SUBDIRS = lov utils obdclass ldlm ptlrpc lib obdecho mdc osc ost llite 
-SUBDIRS+=   $(DIRS24) obdfilter tests doc scripts 
+# NOTE: keep extN before mds and obdfilter
+SUBDIRS = $(DIRS24) obdclass utils ptlrpc ldlm lib obdfilter mdc osc ost llite 
+SUBDIRS+= obdecho lov tests doc scripts 
 
 DIST_SUBDIRS = $(SUBDIRS)
 EXTRA_DIST = BUGS FDL Rules include patches archdep.m4
@@ -29,5 +29,3 @@ include $(top_srcdir)/Rules
 
 rpms: dist Makefile
        rpm -ta $(distdir).tar.gz
-
index a1a8b62..839c746 100644 (file)
@@ -14,20 +14,20 @@ RPM's that you build should get 3 figure versions, CVS versions will
 be 4 digits, and can correspond to test RPM's, and lead up to the
 package version.  So let's plan on releasing
 
-So you'd build 2 sets of test rpms this week: 
+So you'd build 2 sets of test rpms this week:
 
 0.0.9.1
 0.0.9.2
 
-we decide it's fine then and we release 
+we decide it's fine then and we release
 
 0.1.0
 
-We go on developing with 
+We go on developing with
 
-0.1.0.{1,2,3,4,...} 
+0.1.0.{1,2,3,4,...}
 
-as test releases and then we release: 
+as test releases and then we release:
 
 0.1.1
 
@@ -41,36 +41,36 @@ CVS
 Versions will have 4 digits:
                      major.minor.patch.test
 
-Such versions will be tagged in CVS as:  
+Such versions will be tagged in CVS as:
                      v1_2_11_7
 and referred to as:
                      1.2.11.7
 encoded as:
                      0x01021107
 
-Usage: 
+Usage:
 ------
 
-New numbers are used as follows: 
+New numbers are used as follows:
 
-1. major: 
+1. major:
  - increased when major new functionality becomes available
-2. minor: 
+2. minor:
  - even: for each new release with new functionality
  - odd : when a new development cycle starts after a release
 3. patch:
  - when a development snapshot or release update becomes available
  - all these are announced on lustre-devel@lists.sf.net
-4. test: 
+4. test:
  - when developers feel it is time to exchange a named version
 
-What will run, what won't ? 
+What will run, what won't ?
 ---------------------------
 
 1. If the test level is non-zero, i.e. there are 4 digits in the
    version, no guarantees of any kind are made.
 
-2. For three digit releases/tags the code should perform 
+2. For three digit releases/tags the code should perform
    according to the announcement.
 
 Moving tags
@@ -82,16 +82,10 @@ The last operational development snapshot will be  CVS tag "dstable"
 Branches
 --------
 
-For even minor releases a branch tag will be created.  The branch tag
-will be of the form: 
+Any and all development must be done on branches, and can only merge to the
+HEAD if _at_least_ tests/acceptance-small.sh and IOR with 5 SMP nodes and
+2 clients/node with 1GB file/client pass without any errors or cleanup
+problems.  Additional tests may be added in the future, so the tests in the
+current CVS head must pass before a branch can be merged back to the trunk.
 
-bmajor_minor
-
-Note that the CVS head is where development is going.  If developers
-use a branch they must eventually merge that back into the head.
-Typically this is done by importing changes into the branch and
-removing the sticky tags:
-
-cvs update -A
-
-fixing any conflicts and then committing. 
+See http://lustre.org/docs/branches.html for details on CVS branch usage.
index ce9b313..b731c89 100644 (file)
@@ -12,3 +12,4 @@ extN_fs_sb.h
 extN_jbd.h
 extN_xattr.h
 xattr.h
+lustre_build_version.h
index b52dfca..29a800e 100644 (file)
@@ -31,23 +31,33 @@ typedef enum {
 #define LDLM_NAMESPACE_SERVER 0
 #define LDLM_NAMESPACE_CLIENT 1
 
-#define LDLM_FL_LOCK_CHANGED   (1 << 0)
+#define LDLM_FL_LOCK_CHANGED   (1 << 0) /* extent, mode, or resource changed */
+
+/* If the server returns one of these flags, then the lock was put on that list.
+ * If the client sends one of these flags (during recovery ONLY!), it wants the
+ * lock added to the specified list, no questions asked. -p */
 #define LDLM_FL_BLOCK_GRANTED  (1 << 1)
 #define LDLM_FL_BLOCK_CONV     (1 << 2)
 #define LDLM_FL_BLOCK_WAIT     (1 << 3)
-#define LDLM_FL_CBPENDING      (1 << 4)
-#define LDLM_FL_AST_SENT       (1 << 5)
-#define LDLM_FL_DESTROYED      (1 << 6)
-#define LDLM_FL_WAIT_NOREPROC  (1 << 7)
-#define LDLM_FL_CANCEL         (1 << 8)
+
+#define LDLM_FL_CBPENDING      (1 << 4) // this lock is being destroyed
+#define LDLM_FL_AST_SENT       (1 << 5) // blocking or cancel packet was sent
+#define LDLM_FL_DESTROYED      (1 << 6) // this lock is destroyed
+#define LDLM_FL_WAIT_NOREPROC  (1 << 7)// not a real lock flag,not saved in lock
+#define LDLM_FL_CANCEL         (1 << 8) // cancellation callback already run
+
+/* Lock is being replayed.  This could probably be implied by the fact that one
+ * of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. */
 #define LDLM_FL_REPLAY         (1 << 9)
+
 #define LDLM_FL_INTENT_ONLY    (1 << 10) /* don't grant lock, just do intent */
 #define LDLM_FL_LOCAL_ONLY     (1 << 11) /* see ldlm_cli_cancel_unused */
 #define LDLM_FL_NO_CALLBACK    (1 << 12) /* see ldlm_cli_cancel_unused */
 #define LDLM_FL_HAS_INTENT     (1 << 13) /* lock request has intent */
-#define LDLM_FL_REDUCE         (1 << 14) /* throw away unused locks */
-#define LDLM_FL_CANCELING      (1 << 15) /* lock is being canceled */
+#define LDLM_FL_CANCELING      (1 << 14) /* lock cancel has already been sent */
 
+/* The blocking callback is overloaded to perform two functions.  These flags
+ * indicate which operation should be performed. */
 #define LDLM_CB_BLOCKING    1
 #define LDLM_CB_CANCELING   2
 
@@ -312,8 +322,8 @@ void ldlm_register_intent(int (*arg)(struct ldlm_lock *lock, void *req_cookie,
                                      ldlm_mode_t mode, int flags, void *data));
 void ldlm_unregister_intent(void);
 void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh);
-struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *, int strict, int flags);
-void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh);
+struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *, int strict,
+                                     int flags);
 void ldlm_cancel_callback(struct ldlm_lock *);
 int ldlm_lock_set_data(struct lustre_handle *, void *data, int datalen);
 
index 1c6e0fd..b5c7e30 100644 (file)
@@ -75,6 +75,7 @@ struct lustre_lock {
 void l_lock_init(struct lustre_lock *);
 void l_lock(struct lustre_lock *);
 void l_unlock(struct lustre_lock *);
+int l_has_lock(struct lustre_lock *);
 
 #define CB_PHASE_START   12
 #define CB_PHASE_FINISH  13
@@ -93,9 +94,10 @@ struct obd_brw_set {
 /* simple.c */
 struct obd_run_ctxt;
 struct obd_ucred;
-void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new
+void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new_ctx,
                struct obd_ucred *cred);
-void pop_ctxt(struct obd_run_ctxt *saved);
+void pop_ctxt(struct obd_run_ctxt *saved, struct obd_run_ctxt *new_ctx,
+              struct obd_ucred *cred);
 struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode);
 struct dentry *simple_mknod(struct dentry *dir, char *name, int mode);
 int lustre_fread(struct file *file, char *str, int len, loff_t *off);
@@ -458,6 +460,8 @@ static inline int obd_ioctl_getdata(char **buf, int *len, void *arg)
 
 #define OBD_IOC_DEC_FS_USE_COUNT       _IO  ('f', 139      )
 
+#define OBD_GET_VERSION                _IOWR ('f', 144, long)
+
 /*
  * l_wait_event is a flexible sleeping function, permitting simple caller
  * configuration of interrupt and timeout sensitivity along with actions to
index 936ce99..0260ac8 100644 (file)
@@ -117,7 +117,7 @@ void mds_pack_rep_body(struct ptlrpc_request *);
 int mds_update_unpack(struct ptlrpc_request *, int offset,
                       struct mds_update_record *);
 
-void mds_readdir_pack(struct ptlrpc_request *req, int offset,
+void mds_readdir_pack(struct ptlrpc_request *req, __u64 offset,
                       obd_id ino, int type);
 void mds_getattr_pack(struct ptlrpc_request *req, int offset,
                       struct inode *inode, const char *name, int namelen);
index ab8ee9a..5c2ba75 100644 (file)
@@ -89,7 +89,7 @@ struct ptlrpc_connection {
         struct list_head        c_imports;
         struct list_head        c_exports;
         struct list_head        c_sb_chain;
-        __u32                   c_flags; /* can we indicate INVALID elsewhere? */
+        __u32                   c_flags; // can we indicate INVALID elsewhere?
 };
 
 struct ptlrpc_client {
@@ -99,8 +99,6 @@ struct ptlrpc_client {
         __u32                     cli_target_devno;
 
         void                     *cli_data;
-        // struct semaphore          cli_rpc_sem; /* limits outstanding requests */
-
         char                     *cli_name;
 };
 
@@ -127,8 +125,8 @@ struct ptlrpc_request {
         int rq_flags;
         atomic_t rq_refcount;
 
-        int rq_request_portal; /* XXX FIXME bug 625069 */
-        int rq_reply_portal; /* XXX FIXME bug 625069 */
+        int rq_request_portal; /* XXX FIXME bug 249 */
+        int rq_reply_portal; /* XXX FIXME bug 249 */
 
         int rq_reqlen;
         struct lustre_msg *rq_reqmsg;
index 2235a1e..c028a0e 100644 (file)
@@ -9,30 +9,6 @@
 
 #ifndef __OBD_H
 #define __OBD_H
-#include <linux/fs.h>
-#include <linux/list.h>
-#include <linux/smp_lock.h>
-#include <linux/proc_fs.h>
-
-#include <linux/lustre_lib.h>
-#include <linux/lustre_idl.h>
-#include <linux/lustre_mds.h>
-#include <linux/lustre_export.h>
-
-struct obd_type {
-        struct list_head typ_chain;
-        struct obd_ops *typ_ops;
-        struct proc_dir_entry *typ_procroot;
-        char *typ_name;
-        int  typ_refcnt;
-};
-
-struct brw_page {
-        struct page *pg;
-        obd_size count;
-        obd_off  off;
-        obd_flag flag;
-};
 
 struct lov_oinfo { /* per-child structure */
         __u64 loi_id;              /* object ID on the target OST */
@@ -50,6 +26,32 @@ struct lov_stripe_md {
         struct lov_oinfo lsm_oinfo[0];
 };
 
+#ifdef __KERNEL__
+# include <linux/fs.h>
+# include <linux/list.h>
+# include <linux/smp_lock.h>
+# include <linux/proc_fs.h>
+
+# include <linux/lustre_lib.h>
+# include <linux/lustre_idl.h>
+# include <linux/lustre_mds.h>
+# include <linux/lustre_export.h>
+
+struct obd_type {
+        struct list_head typ_chain;
+        struct obd_ops *typ_ops;
+        struct proc_dir_entry *typ_procroot;
+        char *typ_name;
+        int  typ_refcnt;
+};
+
+struct brw_page {
+        struct page *pg;
+        obd_size count;
+        obd_off  off;
+        obd_flag flag;
+};
+
 /* Individual type definitions */
 
 struct ext2_obd {
@@ -414,5 +416,5 @@ static inline int mds_fs_statfs(struct mds_obd *mds, struct statfs *sfs)
 
         return vfs_statfs(mds->mds_sb, sfs);
 }
-
-#endif
+#endif /* __KERNEL */
+#endif /* __OBD_H */
index f6ed766..7efd82d 100644 (file)
@@ -143,6 +143,7 @@ static inline int obd_get_info(struct lustre_handle *conn, obd_count keylen,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, get_info);
@@ -156,6 +157,7 @@ static inline int obd_set_info(struct lustre_handle *conn, obd_count keylen,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, set_info);
@@ -167,6 +169,7 @@ static inline int obd_set_info(struct lustre_handle *conn, obd_count keylen,
 static inline int obd_setup(struct obd_device *obd, int datalen, void *data)
 {
         int rc;
+        ENTRY;
 
         OBD_CHECK_OP(obd, setup);
 
@@ -177,6 +180,7 @@ static inline int obd_setup(struct obd_device *obd, int datalen, void *data)
 static inline int obd_cleanup(struct obd_device *obd)
 {
         int rc;
+        ENTRY;
 
         OBD_CHECK_DEVSETUP(obd);
         OBD_CHECK_OP(obd, cleanup);
@@ -197,6 +201,7 @@ static inline int obd_packmd(struct lustre_handle *conn,
                              struct lov_stripe_md *mem_src)
 {
         struct obd_export *exp;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, packmd);
@@ -239,6 +244,7 @@ static inline int obd_unpackmd(struct lustre_handle *conn,
                                struct lov_mds_md *wire_src)
 {
         struct obd_export *exp;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, unpackmd);
@@ -274,6 +280,7 @@ static inline int obd_create(struct lustre_handle *conn, struct obdo *obdo,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, create);
@@ -287,6 +294,7 @@ static inline int obd_destroy(struct lustre_handle *conn, struct obdo *obdo,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, destroy);
@@ -300,6 +308,7 @@ static inline int obd_getattr(struct lustre_handle *conn, struct obdo *obdo,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, getattr);
@@ -313,6 +322,7 @@ static inline int obd_close(struct lustre_handle *conn, struct obdo *obdo,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, close);
@@ -326,6 +336,7 @@ static inline int obd_open(struct lustre_handle *conn, struct obdo *obdo,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, open);
@@ -339,6 +350,7 @@ static inline int obd_setattr(struct lustre_handle *conn, struct obdo *obdo,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, setattr);
@@ -353,6 +365,7 @@ static inline int obd_connect(struct lustre_handle *conn,
                               ptlrpc_recovery_cb_t recover)
 {
         int rc;
+        ENTRY;
 
         OBD_CHECK_DEVSETUP(obd);
         OBD_CHECK_OP(obd, connect);
@@ -365,6 +378,7 @@ static inline int obd_disconnect(struct lustre_handle *conn)
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, disconnect);
@@ -377,6 +391,7 @@ static inline int obd_statfs(struct lustre_handle *conn,struct obd_statfs *osfs)
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, statfs);
@@ -391,6 +406,7 @@ static inline int obd_punch(struct lustre_handle *conn, struct obdo *oa,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, punch);
@@ -405,6 +421,7 @@ static inline int obd_brw(int cmd, struct lustre_handle *conn,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, brw);
@@ -425,6 +442,7 @@ static inline int obd_preprw(int cmd, struct lustre_handle *conn,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, preprw);
@@ -441,6 +459,7 @@ static inline int obd_commitrw(int cmd, struct lustre_handle *conn,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, commitrw);
@@ -455,6 +474,7 @@ static inline int obd_iocontrol(int cmd, struct lustre_handle *conn,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, iocontrol);
@@ -472,6 +492,7 @@ static inline int obd_enqueue(struct lustre_handle *conn,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, enqueue);
@@ -488,6 +509,7 @@ static inline int obd_cancel(struct lustre_handle *conn,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, cancel);
@@ -501,6 +523,7 @@ static inline int obd_cancel_unused(struct lustre_handle *conn,
 {
         struct obd_export *exp;
         int rc;
+        ENTRY;
 
         OBD_CHECK_SETUP(conn, exp);
         OBD_CHECK_OP(exp->exp_obd, cancel_unused);
index a6eb4c2..b95b266 100644 (file)
@@ -152,27 +152,36 @@ static inline void OBD_FAIL_WRITE(int id, kdev_t dev)
 
 #define OBD_ALLOC(ptr, size)                                            \
 do {                                                                    \
+        void *lptr;                                                     \
         long s = (size);                                                \
-        (ptr) = kmalloc(s, GFP_KERNEL);                                 \
-        if ((ptr) == NULL) {                                            \
+        (ptr) = lptr = kmalloc(s, GFP_KERNEL);                          \
+        if (lptr == NULL) {                                             \
                 CERROR("kmalloc of '" #ptr "' (%ld bytes) failed "      \
                        "at %s:%d\n", s, __FILE__, __LINE__);            \
         } else {                                                        \
-                memset((ptr), 0, s);                                    \
+                memset(lptr, 0, s);                                     \
                 obd_memory += s;                                        \
                 CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %ld at "        \
-                       "%p (tot %ld).\n", s, (ptr), obd_memory);        \
+                       "%p (tot %ld).\n", s, lptr, obd_memory);         \
         }                                                               \
 } while (0)
 
+#ifdef CONFIG_DEBUG_SLAB
+#define POISON(lptr, s) do {} while (0)
+#else
+#define POISON(lptr, s) memset(lptr, 0xb6, s)
+#endif
+
 #define OBD_FREE(ptr, size)                                             \
 do {                                                                    \
+        void *lptr = (ptr);                                             \
         int s = (size);                                                 \
-        LASSERT(ptr);                                                   \
-        kfree((ptr));                                                   \
+        LASSERT(lptr);                                                  \
+        POISON(lptr, s);                                                \
+        kfree(lptr);                                                    \
         obd_memory -= s;                                                \
         CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %ld).\n",    \
-               s, (ptr), obd_memory);                                   \
+               s, lptr, obd_memory);                                    \
         (ptr) = (void *)0xdeadbeef;                                     \
 } while (0)
 
index 2566280..680d4f0 100644 (file)
@@ -20,8 +20,6 @@
  *
  */
 
-
-
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
@@ -61,14 +59,15 @@ void l_lock_init(struct lustre_lock *lock)
 void l_lock(struct lustre_lock *lock)
 {
         int owner = 0;
+
         spin_lock(&lock->l_spin);
-        if (lock->l_owner == current) { 
+        if (lock->l_owner == current)
                 owner = 1;
-        }
         spin_unlock(&lock->l_spin);
-        if (owner)
-                 ++lock->l_depth;
-        else { 
+
+        if (owner) {
+                ++lock->l_depth;
+        } else {
                 down(&lock->l_sem);
                 spin_lock(&lock->l_spin);
                 lock->l_owner = current;
@@ -79,17 +78,31 @@ void l_lock(struct lustre_lock *lock)
 
 void l_unlock(struct lustre_lock *lock)
 {
-        if (lock->l_owner != current)
-                LBUG();
-        if (lock->l_depth < 0)
-                LBUG();
+        LASSERT(lock->l_owner == current);
+        LASSERT(lock->l_depth >= 0);
 
-        spin_lock(&lock->l_spin); 
-        if (--lock->l_depth < 0) { 
+        spin_lock(&lock->l_spin);
+        if (--lock->l_depth < 0) {
                 lock->l_owner = NULL;
                 spin_unlock(&lock->l_spin);
                 up(&lock->l_sem);
-                return ;
+                return;
         }
         spin_unlock(&lock->l_spin);
 }
+
+int l_has_lock(struct lustre_lock *lock)
+{
+        int depth = -1, owner = 0;
+
+        spin_lock(&lock->l_spin);
+        if (lock->l_owner == current) {
+                depth = lock->l_depth;
+                owner = 1;
+        }
+        spin_unlock(&lock->l_spin);
+
+        if (depth >= 0)
+                CDEBUG(D_INFO, "lock_depth: %d\n", depth);
+        return owner;
+}
index 978d0ed..59818f8 100644 (file)
@@ -178,6 +178,7 @@ void ldlm_lock_put(struct ldlm_lock *lock)
                 lock->l_random = DEAD_HANDLE_MAGIC;
                 if (lock->l_export && lock->l_export->exp_connection)
                         ptlrpc_put_connection(lock->l_export->exp_connection);
+                memset(lock, 0x5a, sizeof(*lock));
                 kmem_cache_free(ldlm_lock_slab, lock);
                 //spin_unlock(&ldlm_handle_lock);
                 CDEBUG(D_MALLOC, "kfreed 'lock': %d at %p (tot 0).\n",
@@ -346,7 +347,9 @@ struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *handle,
         struct ldlm_lock *lock = NULL, *retval = NULL;
         ENTRY;
 
-        if (!handle || !handle->addr)
+        LASSERT(handle);
+
+        if (!handle->addr)
                 RETURN(NULL);
 
         //spin_lock(&ldlm_handle_lock);
@@ -379,7 +382,7 @@ struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *handle,
                 GOTO(out, NULL);
         }
 
-        if (flags && (lock->l_flags & flags)) 
+        if (flags && (lock->l_flags & flags))
                 GOTO(out, NULL);
 
         if (flags)
@@ -699,11 +702,13 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
                                    ldlm_mode_t mode, void *data, __u32 data_len)
 {
         struct ldlm_resource *res, *parent_res = NULL;
-        struct ldlm_lock *lock, *parent_lock;
+        struct ldlm_lock *lock, *parent_lock = NULL;
 
-        parent_lock = ldlm_handle2lock(parent_lock_handle);
-        if (parent_lock)
-                parent_res = parent_lock->l_resource;
+        if (parent_lock_handle) {
+                parent_lock = ldlm_handle2lock(parent_lock_handle);
+                if (parent_lock)
+                        parent_res = parent_lock->l_resource;
+        }
 
         res = ldlm_resource_get(ns, parent_res, res_id, type, 1);
         if (res == NULL)
index da675c9..892bf94 100644 (file)
@@ -633,7 +633,7 @@ static int ldlm_setup(struct obd_device *obddev, obd_count len, void *buf)
 
         for (i = 0; i < LDLM_NUM_THREADS; i++) {
                 char name[32];
-                sprintf(name, "ldlm_%02d", i);
+                sprintf(name, "ldlm_cn_%02d", i);
                 rc = ptlrpc_start_thread(obddev, ldlm->ldlm_cancel_service,
                                          name);
                 if (rc) {
@@ -645,7 +645,7 @@ static int ldlm_setup(struct obd_device *obddev, obd_count len, void *buf)
 
         for (i = 0; i < LDLM_NUM_THREADS; i++) {
                 char name[32];
-                sprintf(name, "ldlm_%02d", i);
+                sprintf(name, "ldlm_cb_%02d", i);
                 rc = ptlrpc_start_thread(obddev, ldlm->ldlm_cb_service, name);
                 if (rc) {
                         CERROR("cannot start LDLM thread #%d: rc %d\n", i, rc);
index 130f092..ccb7611 100644 (file)
@@ -434,9 +434,8 @@ int ldlm_cli_cancel(struct lustre_handle *lockh)
 
         /* concurrent cancels on the same handle can happen */
         lock = __ldlm_handle2lock(lockh, 0, LDLM_FL_CANCELING);
-        if (!lock) {
+        if (lock == NULL)
                 RETURN(0);
-        }
 
         if (lock->l_connh) {
                 LDLM_DEBUG(lock, "client-side cancel");
@@ -478,6 +477,8 @@ int ldlm_cli_cancel(struct lustre_handle *lockh)
                 LDLM_DEBUG(lock, "client-side local cancel handler END");
         }
 
+        lock->l_flags |= LDLM_FL_CANCELING;
+
         EXIT;
  out:
         LDLM_LOCK_PUT(lock);
@@ -550,10 +551,6 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns,
         struct ldlm_ast_work *w;
         ENTRY;
 
-        if ((flags & LDLM_FL_REDUCE) && 
-            ns->ns_max_unused > ns->ns_nr_unused)
-                RETURN(0);
-
         res = ldlm_resource_get(ns, NULL, res_id, 0, 0);
         if (res == NULL) {
                 /* This is not a problem. */
@@ -577,9 +574,6 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns,
 
                 w->w_lock = LDLM_LOCK_GET(lock);
                 list_add(&w->w_list, &list);
-                if ((flags & LDLM_FL_REDUCE) && 
-                    ns->ns_max_unused > ns->ns_nr_unused)
-                        break;
         }
         l_unlock(&ns->ns_lock);
 
index bdb3449..60a351f 100644 (file)
@@ -65,8 +65,7 @@ struct ldlm_namespace *ldlm_namespace_new(char *name, __u32 client)
 {
         struct ldlm_namespace *ns = NULL;
         struct list_head *bucket;
-
-       
+        ENTRY;
 
         OBD_ALLOC(ns, sizeof(*ns));
         if (!ns) {
@@ -112,6 +111,7 @@ struct ldlm_namespace *ldlm_namespace_new(char *name, __u32 client)
 
  out:
         if (ns && ns->ns_hash) {
+                memset(ns->ns_hash, 0x5a, sizeof(*ns->ns_hash) * RES_HASH_SIZE);
                 vfree(ns->ns_hash);
                 obd_memory -= sizeof(*ns->ns_hash) * RES_HASH_SIZE;
         }
@@ -178,11 +178,10 @@ int ldlm_namespace_cleanup(struct ldlm_namespace *ns, int local_only)
                         cleanup_resource(res, &res->lr_converting, local_only);
                         cleanup_resource(res, &res->lr_waiting, local_only);
 
-                        /* XXX this is a bit counter-intuitive and should
-                         * probably be cleaner: don't force cleanup if we're
-                         * local_only (which is only used by recovery).  We
-                         * probably still have outstanding lock refs which
-                         * reference these resources. -phil */
+                        /* XXX what a mess: don't force cleanup if we're
+                         * local_only (which is only used by recovery).  In that
+                         * case, we probably still have outstanding lock refs
+                         * which reference these resources. -phil */
                         if (!ldlm_resource_put(res) && !local_only) {
                                 CERROR("Resource refcount nonzero (%d) after "
                                        "lock cleanup; forcing cleanup.\n",
@@ -211,6 +210,7 @@ int ldlm_namespace_free(struct ldlm_namespace *ns)
 
         ldlm_namespace_cleanup(ns, 0);
 
+        memset(ns->ns_hash, 0x5a, sizeof(*ns->ns_hash) * RES_HASH_SIZE);
         vfree(ns->ns_hash /* , sizeof(*ns->ns_hash) * RES_HASH_SIZE */);
         obd_memory -= sizeof(*ns->ns_hash) * RES_HASH_SIZE;
         OBD_FREE(ns->ns_name, strlen(ns->ns_name) + 1);
@@ -333,12 +333,12 @@ struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
                 if (memcmp(chk->lr_name, name, sizeof(chk->lr_name)) == 0) {
                         res = chk;
                         atomic_inc(&res->lr_refcount);
-                        EXIT;
-                        break;
+                        l_unlock(&ns->ns_lock);
+                        RETURN(res);
                 }
         }
 
-        if (res == NULL && create)
+        if (create)
                 res = ldlm_resource_add(ns, parent, name, type);
         l_unlock(&ns->ns_lock);
 
@@ -384,6 +384,7 @@ int ldlm_resource_put(struct ldlm_resource *res)
                 list_del(&res->lr_hash);
                 list_del(&res->lr_childof);
 
+                memset(res, 0x5a, sizeof(*res));
                 kmem_cache_free(ldlm_resource_slab, res);
                 l_unlock(&ns->ns_lock);
 
index 00b0d48..c75b399 100644 (file)
@@ -142,6 +142,8 @@ int client_obd_connect(struct lustre_handle *conn, struct obd_device *obd,
         if (cli->cl_conn_count > 1)
                 GOTO(out_sem, rc);
 
+        if (obd->obd_namespace != NULL)
+                CERROR("already have namespace!\n");
         obd->obd_namespace = ldlm_namespace_new(obd->obd_name,
                                                 LDLM_NAMESPACE_CLIENT);
         if (obd->obd_namespace == NULL)
index 8da9f39..6a53cb6 100644 (file)
@@ -121,12 +121,12 @@ void mds_getattr_pack(struct ptlrpc_request *req, int offset,
         }
 }
 
-void mds_readdir_pack(struct ptlrpc_request *req, int offset,
+void mds_readdir_pack(struct ptlrpc_request *req, __u64 offset,
                       obd_id ino, int type)
 {
         struct mds_body *b;
 
-        b = lustre_msg_buf(req->rq_reqmsg, offset);
+        b = lustre_msg_buf(req->rq_reqmsg, 0);
         b->fsuid = HTON__u32(current->fsuid);
         b->fsgid = HTON__u32(current->fsgid);
         b->capability = HTON__u32(current->cap_effective);
index 0a3d058..4b423d4 100644 (file)
 #endif
 
 /* push / pop to root of obd store */
-void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new
+void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new_ctx,
                struct obd_ucred *uc)
 {
         //ASSERT_NOT_KERNEL_CTXT("already in kernel context!\n");
-        ASSERT_CTXT_MAGIC(new->magic);
+        ASSERT_CTXT_MAGIC(new_ctx->magic);
         OBD_SET_CTXT_MAGIC(save);
+
+        /*
+        CDEBUG(D_INFO, "== push %p->%p == cur fs %p pwd %p (%*s), pwdmnt %p\n",
+               save, current, current->fs, current->fs->pwd,
+               current->fs->pwd->d_name.len, current->fs->pwd->d_name.name,
+               current->fs->pwdmnt);
+        */
+
         save->fs = get_fs();
         save->pwd = dget(current->fs->pwd);
         save->pwdmnt = mntget(current->fs->pwdmnt);
 
         LASSERT(save->pwd);
         LASSERT(save->pwdmnt);
-        LASSERT(new->pwd);
-        LASSERT(new->pwdmnt);
+        LASSERT(new_ctx->pwd);
+        LASSERT(new_ctx->pwdmnt);
+
+        if (uc) {
+                save->fsuid = current->fsuid;
+                save->fsgid = current->fsgid;
+                save->cap = current->cap_effective;
 
-        save->fsuid = current->fsuid;
-        save->fsgid = current->fsgid;
-        save->cap = current->cap_effective;
-        if (uc) { 
                 current->fsuid = uc->ouc_fsuid;
                 current->fsgid = uc->ouc_fsgid;
                 current->cap_effective = uc->ouc_cap;
         }
-        set_fs(new->fs);
-        set_fs_pwd(current->fs, new->pwdmnt, new->pwd);
-        //if (save->override)
-        //        cap_lower(current->cap_effective, CAP_DAC_OVERRIDE);
+        set_fs(new_ctx->fs);
+        set_fs_pwd(current->fs, new_ctx->pwdmnt, new_ctx->pwd);
+
+        /*
+        CDEBUG(D_INFO, "== push %p==%p == cur fs %p pwd %p (%*s), pwdmnt %p\n",
+               new_ctx, current, current->fs, current->fs->pwd,
+               current->fs->pwd->d_name.len, current->fs->pwd->d_name.name,
+               current->fs->pwdmnt);
+        */
 }
 
-void pop_ctxt(struct obd_run_ctxt *saved)
+void pop_ctxt(struct obd_run_ctxt *saved, struct obd_run_ctxt *new_ctx,
+              struct obd_ucred *uc)
 {
         //printk("pc0");
         ASSERT_CTXT_MAGIC(saved->magic);
         //printk("pc1");
         ASSERT_KERNEL_CTXT("popping non-kernel context!\n");
+
+        /*
+        CDEBUG(D_INFO, " == pop  %p==%p == cur %p pwd %p (%*s), pwdmnt %p\n",
+               new_ctx, current, current->fs, current->fs->pwd,
+               current->fs->pwd->d_name.len, current->fs->pwd->d_name.name,
+               current->fs->pwdmnt);
+        */
+
+        LASSERT(current->fs->pwd == new_ctx->pwd);
+        LASSERT(current->fs->pwdmnt == new_ctx->pwdmnt);
+
         //printk("pc2");
         set_fs(saved->fs);
         //printk("pc3\n");
@@ -86,12 +112,18 @@ void pop_ctxt(struct obd_run_ctxt *saved)
         //printk("pc5");
         mntput(saved->pwdmnt);
         //printk("pc6\n");
-        current->fsuid = saved->fsuid;
-        current->fsgid = saved->fsgid;
-        current->cap_effective = saved->cap;
+        if (uc) {
+                current->fsuid = saved->fsuid;
+                current->fsgid = saved->fsgid;
+                current->cap_effective = saved->cap;
+        }
 
-        //        if (saved->override)
-        //       cap_raise(current->cap_effective, CAP_DAC_OVERRIDE);
+        /*
+        CDEBUG(D_INFO, "== pop  %p->%p == cur fs %p pwd %p (%*s), pwdmnt %p\n",
+               saved, current, current->fs, current->fs->pwd,
+               current->fs->pwd->d_name.len, current->fs->pwd->d_name.name,
+               current->fs->pwdmnt);
+        */
 }
 
 /* utility to make a file */
index d654544..9a12fd5 100644 (file)
@@ -67,6 +67,10 @@ void ll_intent_release(struct dentry *de, struct lookup_intent *it)
                                 CERROR("ldlm_cli_cancel: %d\n", rc);
                 } else
                         ldlm_lock_decref(handle, it->it_lock_mode);
+
+                /* intent_release may be called multiple times, and we don't
+                 * want to double-decref this lock (see bug 494) */
+                it->it_lock_mode = 0;
         }
 
         if (!de->d_it || it->it_op == IT_RELEASED_MAGIC) {
@@ -137,8 +141,8 @@ int ll_revalidate2(struct dentry *de, int flags, struct lookup_intent *it)
                 RETURN(0);
         }
 
-        if (it == NULL && ll_have_lock(de))
-                RETURN(1);
+//        if (it == NULL && ll_have_lock(de))
+//                RETURN(1);
 
         rc = ll_intent_lock(de->d_parent->d_inode, &de, it, revalidate2_finish);
         if (rc < 0) {
index 1d51460..6f67f4b 100644 (file)
@@ -281,7 +281,7 @@ fail:
         LBUG();
 }
 
-static struct page * ext2_get_page(struct inode *dir, unsigned long n)
+static struct page * ll_get_page(struct inode *dir, unsigned long n)
 {
         struct address_space *mapping = dir->i_mapping;
         struct page *page = read_cache_page(mapping, n,
@@ -396,7 +396,9 @@ int ll_readdir(struct file * filp, void * dirent, filldir_t filldir)
         for ( ; n < npages; n++, offset = 0) {
                 char *kaddr, *limit;
                 ext2_dirent *de;
-                struct page *page = ext2_get_page(inode, n);
+                struct page *page;
+                
+                page = ll_get_page(inode, n);
 
                 /* size might have been updated by mdc_readpage */
                 npages = dir_pages(inode);
@@ -466,7 +468,7 @@ struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir,
         n = start;
         do {
                 char *kaddr;
-                page = ext2_get_page(dir, n);
+                page = ll_get_page(dir, n);
                 if (!IS_ERR(page)) {
                         kaddr = page_address(page);
                         de = (ext2_dirent *) kaddr;
@@ -491,7 +493,7 @@ found:
 
 struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p)
 {
-        struct page *page = ext2_get_page(dir, 0);
+        struct page *page = ll_get_page(dir, 0);
         ext2_dirent *de = NULL;
 
         if (!IS_ERR(page)) {
@@ -557,7 +559,7 @@ int ll_add_link (struct dentry *dentry, struct inode *inode)
 
         /* We take care of directory expansion in the same loop */
         for (n = 0; n <= npages; n++) {
-                page = ext2_get_page(dir, n);
+                page = ll_get_page(dir, n);
                 err = PTR_ERR(page);
                 if (IS_ERR(page))
                         goto out;
@@ -709,7 +711,7 @@ int ext2_empty_dir (struct inode * inode)
         for (i = 0; i < npages; i++) {
                 char *kaddr;
                 ext2_dirent * de;
-                page = ext2_get_page(inode, i);
+                page = ll_get_page(inode, i);
 
                 if (IS_ERR(page))
                         continue;
index b349bc8..7498c94 100644 (file)
@@ -221,10 +221,11 @@ int ll_intent_lock(struct inode *parent, struct dentry **de,
                  *
                  * For everything else, we want to lookup to succeed. */
 
-                /* One additional note: we add an extra reference to
-                 * the request because we need to keep it around until
-                 * ll_create gets called.  For anything else which
-                 * results in LL_LOOKUP_POSITIVE, we can do the iget()
+                /* One additional note: if CREATE/MKDIR/etc succeeded,
+                 * we add an extra reference to the request because we
+                 * need to keep it around until ll_create gets called.
+                 * For anything else which results in
+                 * LL_LOOKUP_POSITIVE, we can do the iget()
                  * immediately with the contents of the reply (in the
                  * intent_finish callback).  In the create case,
                  * however, we need to wait until ll_create_node to do
@@ -241,10 +242,10 @@ int ll_intent_lock(struct inode *parent, struct dentry **de,
                         /* For create ops, we want the lookup to be negative,
                          * unless the create failed in a way that indicates
                          * that the file is already there */
-                        if (it->it_status != -EEXIST) {
+                        if (it->it_status == 0)
                                 atomic_inc(&request->rq_refcount);
+                        if (it->it_status != -EEXIST)
                                 GOTO(out, flag = LL_LOOKUP_NEGATIVE);
-                        }
                         /*
                          * Fall through to update attibutes: it may already
                          * have appeared in the namespace of another client
index 742e430..93a4bdb 100644 (file)
@@ -89,20 +89,20 @@ static int ll_follow_link(struct dentry *dentry, struct nameidata *nd,
         struct inode *inode = dentry->d_inode;
         struct ll_inode_info *lli = ll_i2info(inode);
         struct ptlrpc_request *request;
+        int op, mode;
         char *symname;
         int rc;
         ENTRY;
 
-        /* we got here from a lookup up to the symlink that we hit */
-        if (it->it_lock_mode) {
-                struct lustre_handle *handle =
-                        (struct lustre_handle *)it->it_lock_handle;
-                ldlm_lock_decref(handle, it->it_lock_mode);
-                it->it_lock_mode = 0;
-                memset(handle, 0, sizeof(*handle));
-        }
+        op = it->it_op;
+        mode = it->it_mode;
 
+        ll_intent_release(dentry, it);
         down(&lli->lli_open_sem);
+
+        it->it_op = op;
+        it->it_mode = mode;
+
         rc = ll_readlink_internal(inode, &request, &symname);
         if (rc)
                 GOTO(out, rc);
index 15fe873..5ab02b1 100644 (file)
@@ -1195,6 +1195,7 @@ static int lov_enqueue(struct lustre_handle *conn, struct lov_stripe_md *lsm,
                  */
                 submd.lsm_stripe_count = 0;
                 /* XXX submd is not fully initialized here */
+                *flags = 0;
                 rc = obd_enqueue(&(lov->tgts[loi->loi_ost_idx].conn), &submd,
                                  parent_lock, type, &sub_ext, sizeof(sub_ext),
                                  mode, flags, cb, data, datalen, &(lockhs[i]));
index 5058ef0..16f6ca8 100644 (file)
@@ -114,6 +114,9 @@ int mdc_getattr(struct lustre_handle *conn,
         int rc, size[2] = {sizeof(*body), 0}, bufcount = 1;
         ENTRY;
 
+        /* XXX do we need to make another request here?  We just did a getattr
+         *     to do the lookup in the first place.
+         */
         req = ptlrpc_prep_req(class_conn2cliimp(conn), MDS_GETATTR, 1, size,
                               NULL);
         if (!req)
@@ -245,8 +248,8 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
         struct ldlm_request *lockreq;
         ENTRY;
 
-        LDLM_DEBUG_NOLOCK("mdsintent %s dir %ld", ldlm_it2str(it->it_op),
-                          dir->i_ino);
+        LDLM_DEBUG_NOLOCK("mdsintent %s parent dir %ld",
+                          ldlm_it2str(it->it_op), dir->i_ino);
 
         if (it->it_op & (IT_MKDIR | IT_CREAT | IT_SYMLINK | IT_MKNOD)) {
                 switch (it->it_op) {
@@ -485,7 +488,7 @@ int mdc_open(struct lustre_handle *conn, obd_id ino, int type, int flags,
         memcpy(&body->handle, fh, sizeof(body->handle));
 
         if (lmm && lmm_size) {
-                CDEBUG(D_INODE, "sending %u bytes MD for ino LPU64\n",
+                CDEBUG(D_INODE, "sending %u bytes MD for ino "LPU64"\n",
                        lmm_size, ino);
                 lustre_msg_set_op_flags(req->rq_reqmsg, MDS_OPEN_HAS_EA);
                 memcpy(lustre_msg_buf(req->rq_reqmsg, 1), lmm, lmm_size);
@@ -573,7 +576,7 @@ int mdc_readpage(struct lustre_handle *conn, obd_id ino, int type, __u64 offset,
                 GOTO(out2, rc);
         }
 
-        mds_readdir_pack(req, 0, ino, type);
+        mds_readdir_pack(req, offset, ino, type);
 
         req->rq_replen = lustre_msg_size(1, &size);
         rc = ptlrpc_queue_wait(req);
index 4f5f6e3..bfdb3de 100644 (file)
@@ -138,8 +138,8 @@ static int mds_sendpage(struct ptlrpc_request *req, struct file *file,
  *
  * If we do not need an exclusive or write lock on this entry (e.g.
  * a read lock for attribute lookup only) then we do not hold the
- * directory on return.  It is up to the caller to know what type
- * of lock it is getting, and clean up appropriately.
+ * directory semaphore on return.  It is up to the caller to know what
+ * type of lock it is getting, and clean up appropriately.
  */
 struct dentry *mds_name2locked_dentry(struct obd_device *obd,
                                       struct dentry *dir, struct vfsmount **mnt,
@@ -513,7 +513,6 @@ static int mds_getlovinfo(struct ptlrpc_request *req)
         desc = lustre_msg_buf(req->rq_repmsg, 0);
         rc = mds_get_lovdesc(mds, desc);
         if (rc) {
-                CERROR("mds_get_lovdesc error %d", rc);
                 req->rq_status = rc;
                 RETURN(0);
         }
@@ -720,7 +719,7 @@ out_create_de:
         l_dput(de);
 out_pre_de:
         req->rq_status = rc;
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &mds->mds_ctxt, &uc);
         return 0;
 }
 
@@ -789,7 +788,7 @@ static int mds_getattr(int offset, struct ptlrpc_request *req)
 out:
         l_dput(de);
 out_pop:
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &mds->mds_ctxt, &uc);
         RETURN(rc);
 }
 
@@ -880,7 +879,7 @@ static int mds_store_md(struct mds_obd *mds, struct ptlrpc_request *req,
         if (rc2 && !rc)
                 rc = rc2;
 out_ea:
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &mds->mds_ctxt, &uc);
 
         RETURN(rc);
 }
@@ -1068,7 +1067,7 @@ static int mds_readpage(struct ptlrpc_request *req)
 
         filp_close(file, 0);
 out_pop:
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &mds->mds_ctxt, &uc);
 out:
         req->rq_status = rc;
         RETURN(0);
@@ -1467,7 +1466,7 @@ static int mds_recovery_complete(struct obd_device *obddev)
         ++mds->mds_mount_count;
         push_ctxt(&saved, &mds->mds_ctxt, NULL);
         rc = mds_update_server_data(mds);
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &mds->mds_ctxt, NULL);
 
         return rc;
 }
@@ -1562,7 +1561,7 @@ static int mds_cleanup(struct obd_device *obddev)
                 if (rc)
                         CERROR("last_rcvd file won't close, rc=%d\n", rc);
         }
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &mds->mds_ctxt, NULL);
 
         unlock_kernel();
         mntput(mds->mds_vfsmnt);
@@ -1685,8 +1684,7 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
 
                 /* If the client is about to open a file that doesn't have an MD
                  * stripe record, it's going to need a write lock. */
-                if (it->opc & IT_OPEN &&
-                    !(lustre_msg_get_op_flags(req->rq_reqmsg)&MDS_OPEN_HAS_EA)){
+                if (it->opc & IT_OPEN && !(mds_rep->valid & OBD_MD_FLEASIZE)) {
                         LDLM_DEBUG(lock, "open with no EA; returning PW lock");
                         lock->l_req_mode = LCK_PW;
                 }
@@ -1749,7 +1747,7 @@ static int mdt_setup(struct obd_device *obddev, obd_count len, void *buf)
                                            "self", mds_handle, "mds");
         if (!mds->mds_service) {
                 CERROR("failed to start service\n");
-                GOTO(err_dec, rc = -EINVAL);
+                GOTO(err_dec, rc = -ENOMEM);
         }
 
         for (i = 0; i < MDT_NUM_THREADS; i++) {
index 6487d82..4fb5756 100644 (file)
@@ -50,8 +50,6 @@ struct mds_cb_data {
 #define EXT3_XATTR_INDEX_LUSTRE         5
 #define XATTR_LUSTRE_MDS_OBJID          "system.lustre_mds_objid"
 
-#define XATTR_MDS_MO_MAGIC              0xEA0BD047
-
 /*
  * We don't currently need any additional blocks for rmdir and
  * unlink transactions because we are storing the OST oa_id inside
@@ -160,13 +158,13 @@ static int mds_ext3_get_md(struct inode *inode, struct lov_mds_md *lmm,int size)
 
         /* This gives us the MD size */
         if (lmm == NULL)
-                return rc;
+                return (rc == -ENODATA) ? 0 : rc;
 
         if (rc < 0) {
                 CDEBUG(D_INFO, "error getting EA %s from MDS inode %ld: "
                        "rc = %d\n", XATTR_LUSTRE_MDS_OBJID, inode->i_ino, rc);
                 memset(lmm, 0, size);
-                return rc;
+                return (rc == -ENODATA) ? 0 : rc;
         }
 
         /* This field is byteswapped because it appears in the
@@ -213,7 +211,7 @@ static void mds_ext3_delete_inode(struct inode *inode)
                         EXIT;
                         return;
                 }
-                if (mds_ext3_set_md(inode, handle, NULL))
+                if (mds_ext3_set_md(inode, handle, NULL, 0))
                         CERROR("error clearing objid on %ld\n", inode->i_ino);
 
                 if (mds_ext3_fs_ops.cl_delete_inode)
index 9bba857..811c801 100644 (file)
@@ -82,12 +82,12 @@ int mds_client_add(struct mds_obd *mds, struct mds_export_data *med, int cl_off)
                 struct obd_run_ctxt saved;
                 loff_t off = MDS_LR_CLIENT + (cl_off * MDS_LR_SIZE);
                 ssize_t written;
-                
+
                 push_ctxt(&saved, &mds->mds_ctxt, NULL);
                 written = lustre_fwrite(mds->mds_rcvd_filp,
                                                 (char *)med->med_mcd,
                                                 sizeof(*med->med_mcd), &off);
-                pop_ctxt(&saved);
+                pop_ctxt(&saved, &mds->mds_ctxt, NULL);
 
                 if (written != sizeof(*med->med_mcd)) {
                         if (written < 0)
@@ -125,7 +125,7 @@ int mds_client_free(struct obd_export *exp)
         push_ctxt(&saved, &mds->mds_ctxt, NULL);
         written = lustre_fwrite(mds->mds_rcvd_filp, (const char *)&zero_mcd,
                                 sizeof zero_mcd, &off);
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &mds->mds_ctxt, NULL);
 
         if (written != sizeof zero_mcd) {
                 CERROR("error zeroing out client %s off %d in %s: %d\n",
@@ -136,7 +136,7 @@ int mds_client_free(struct obd_export *exp)
                 CDEBUG(D_INFO, "zeroed out disconnecting client %s at off %d\n",
                        med->med_mcd->mcd_uuid, med->med_off);
         }
-        
+
         OBD_FREE(med->med_mcd, sizeof(*med->med_mcd));
 
         return 0;
@@ -334,7 +334,7 @@ static int mds_fs_prep(struct obd_device *obddev)
         }
         mds->mds_rcvd_filp = f;
 err_pop:
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &mds->mds_ctxt, NULL);
 
         return rc;
 
index 945cc39..a7304de 100644 (file)
@@ -43,6 +43,7 @@ int mds_set_lovdesc(struct obd_device *obd, struct lov_desc *desc,
         int tgt_count;
         int rc;
         int i;
+        ENTRY;
 
         tgt_count = desc->ld_tgt_count;
         lov_packdesc(desc);
@@ -85,7 +86,7 @@ int mds_set_lovdesc(struct obd_device *obd, struct lov_desc *desc,
                 CERROR("Error closing LOVTGTS file\n");
 
 out:
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &mds->mds_ctxt, NULL);
         RETURN(rc);
 }
 
@@ -94,13 +95,13 @@ int mds_get_lovdesc(struct mds_obd *mds, struct lov_desc *desc)
         struct obd_run_ctxt saved;
         struct file *f;
         int rc;
+        ENTRY;
 
         push_ctxt(&saved, &mds->mds_ctxt, NULL);
         f = filp_open("LOVDESC", O_RDONLY, 0644);
-        if (!f || IS_ERR(f)) {
+        if (IS_ERR(f)) {
                 CERROR("Cannot open LOVDESC file\n");
-                pop_ctxt(&saved);
-                RETURN(-EIO);
+                GOTO(out, rc = PTR_ERR(f));
         }
 
         rc = lustre_fread(f, (char *)desc, sizeof(*desc), &f->f_pos);
@@ -108,13 +109,15 @@ int mds_get_lovdesc(struct mds_obd *mds, struct lov_desc *desc)
                 CERROR("Error closing LOVDESC file\n");
 
         if (rc != sizeof(*desc)) {
-                CERROR("Cannot read LOVDESC file\n");
-                pop_ctxt(&saved);
-                RETURN(-EIO);
-        }
-        pop_ctxt(&saved);
+                CERROR("Cannot read LOVDESC file: rc = %d\n", rc);
+                GOTO(out, rc = -EIO);
+        } else
+                rc = 0;
+        EXIT;
+out:
+        pop_ctxt(&saved, &mds->mds_ctxt, NULL);
 
-        RETURN(0);
+        return rc;
 }
 
 int mds_get_lovtgts(struct mds_obd *mds, int tgt_count,obd_uuid_t *uuidarray)
@@ -142,11 +145,11 @@ int mds_get_lovtgts(struct mds_obd *mds, int tgt_count,obd_uuid_t *uuidarray)
                 if (rc >= 0)
                         rc = -EIO;
                 GOTO(out, rc);
-        } else 
+        } else
                 rc = 0;
         EXIT;
 out:
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &mds->mds_ctxt, NULL);
 
         RETURN(rc);
 }
index f158bc2..5ac6e6e 100644 (file)
@@ -234,7 +234,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                 mds_pack_inode2fid(&body->fid1, inode);
                 mds_pack_inode2body(body, inode);
                 if (S_ISREG(inode->i_mode))
-                        rc = mds_pack_md(mds, req, offset + 1, body, inode);
+                        mds_pack_md(mds, req, offset + 1, body, inode);
 
                 /* This isn't an error for RECREATE. */
                 if (rec->ur_opcode & REINT_REPLAYING) {
@@ -474,7 +474,7 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
         case S_IFREG:
                 /* get OBD EA data first so client can also destroy object */
                 if ((inode->i_mode & S_IFMT) == S_IFREG && offset)
-                        rc = mds_pack_md(mds, req, offset + 1, body, inode);
+                        mds_pack_md(mds, req, offset + 1, body, inode);
                 /* no break */
         case S_IFLNK:
         case S_IFCHR:
@@ -606,7 +606,7 @@ static int mds_reint_link(struct mds_update_record *rec, int offset,
                         mds_pack_inode2fid(&body->fid1, inode);
                         mds_pack_inode2body(body, inode);
                         if (S_ISREG(inode->i_mode))
-                                rc = mds_pack_md(mds, req, 2, body, inode);
+                                mds_pack_md(mds, req, 2, body, inode);
                 }
                 if (rec->ur_opcode & REINT_REPLAYING) {
                         /* XXX verify that the link is to the the right file? */
@@ -752,7 +752,7 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
                         mds_pack_inode2fid(&body->fid1, inode);
                         mds_pack_inode2body(body, inode);
                         if (S_ISREG(inode->i_mode))
-                                rc = mds_pack_md(mds, req, 2, body, inode);
+                                mds_pack_md(mds, req, 2, body, inode);
                 }
         }
 
@@ -861,7 +861,7 @@ int mds_reint_rec(struct mds_update_record *rec, int offset,
 
         push_ctxt(&saved, &mds->mds_ctxt, &uc);
         rc = reinters[realop] (rec, offset, req);
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &mds->mds_ctxt, &uc);
 
         return rc;
 }
index 3ad8a59..44c7ec7 100644 (file)
@@ -1,6 +1,13 @@
+# FIXME: we need to make it clear that obdclass.o depends on
+# lustre_build_version, or 'make -j2' breaks!
 DEFS=
 MODULE = obdclass
-modulefs_DATA = obdclass.o
+modulefs_DATA = lustre_build_version obdclass.o
 EXTRA_PROGRAMS = obdclass
 obdclass_SOURCES = debug.c genops.c class_obd.c sysctl.c uuid.c lprocfs_status.c
 include $(top_srcdir)/Rules
+lustre_build_version:
+       perl $(top_srcdir)/scripts/version_tag.pl $(top_srcdir) > tmpver
+       diff -u tmpver $(top_builddir)/include/linux/lustre_build_version.h &&\
+               $(RM) tmpver || \
+               mv tmpver $(top_builddir)/include/linux/lustre_build_version.h
index 60816e7..a780f10 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/smp_lock.h>
 #include <linux/lprocfs_status.h>
 #include <portals/lib-types.h> /* for PTL_MD_MAX_IOV */
+#include <linux/lustre_build_version.h>
 
 struct semaphore obd_conf_sem;   /* serialize configuration commands */
 struct obd_device obd_dev[MAX_OBD_DEVICES];
@@ -137,7 +138,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
         down(&obd_conf_sem);
 
         if (!obd && cmd != OBD_IOC_DEVICE && cmd != TCGETS &&
-            cmd != OBD_IOC_LIST &&
+            cmd != OBD_IOC_LIST && cmd != OBD_GET_VERSION &&
             cmd != OBD_IOC_NAME2DEV && cmd != OBD_IOC_NEWDEV) {
                 CERROR("OBD ioctl: No device\n");
                 GOTO(out, err = -EINVAL);
@@ -203,6 +204,24 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                 GOTO(out, err);
         }
 
+        case OBD_GET_VERSION:
+                if (!data->ioc_inlbuf1) {
+                        CERROR("No buffer passed in ioctl\n");
+                        GOTO(out, err = -EINVAL);
+                }
+
+                if (strlen(BUILD_VERSION) + 1 > data->ioc_inllen1) {
+                        CERROR("ioctl buffer too small to hold version\n");
+                        GOTO(out, err = -EINVAL);
+                }
+
+                memcpy(data->ioc_bulk, BUILD_VERSION,
+                       strlen(BUILD_VERSION) + 1);
+
+                err = copy_to_user((void *)arg, data, len);
+                if (err)
+                        err = -EFAULT;
+                GOTO(out, err);
 
         case OBD_IOC_NAME2DEV: {
                 /* Resolve a device name.  This does not change the
@@ -450,7 +469,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                         obd->obd_flags &= ~OBD_SET_UP;
                         obd->obd_type->typ_refcnt--;
                 }
-                GOTO(out, err);
+                      GOTO(out, err);
         }
 
         case OBD_IOC_CONNECT: {
@@ -621,7 +640,8 @@ static int __init init_obdclass(void)
         int err;
         int i;
 
-        printk(KERN_INFO "OBD class driver  v0.9, info@clusterfs.com\n");
+        printk(KERN_INFO "OBD class driver Build Version: " BUILD_VERSION
+                      ", info@clusterfs.com\n");
 
         sema_init(&obd_conf_sem, 1);
         INIT_LIST_HEAD(&obd_types);
@@ -673,12 +693,12 @@ static void __exit cleanup_obdclass(void)
 /* Check that we're building against the appropriate version of the Lustre
  * kernel patch */
 #include <linux/lustre_version.h>
-#if (LUSTRE_KERNEL_VERSION != 2)
+#if (LUSTRE_KERNEL_VERSION != 3)
 # error Cannot continue: Your Lustre kernel patch is out of date
 #endif
 
 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
-MODULE_DESCRIPTION("Lustre Class Driver v1.0");
+MODULE_DESCRIPTION("Lustre Class Driver Build Version: " BUILD_VERSION);
 MODULE_LICENSE("GPL");
 
 module_init(init_obdclass);
index f31a97a..926991a 100644 (file)
@@ -246,6 +246,7 @@ int obd_init_caches(void)
 struct obd_export *class_conn2export(struct lustre_handle *conn)
 {
         struct obd_export *export;
+        ENTRY;
 
         if (!conn) {
                 CDEBUG(D_CACHE, "looking for null handle\n");
index 524e779..763ddb8 100644 (file)
@@ -38,6 +38,7 @@ static int echo_iocontrol(long cmd, struct lustre_handle *obdconn, int len,
         struct echo_client_obd *ec = &obd->u.echo_client;
         struct obd_ioctl_data *data = karg;
         int rw = OBD_BRW_READ, rc = 0;
+        struct lov_stripe_md *lsm = NULL;
         ENTRY;
 
         if (obd == NULL) {
@@ -45,55 +46,71 @@ static int echo_iocontrol(long cmd, struct lustre_handle *obdconn, int len,
                 GOTO(out, rc = -EINVAL);
         }
 
+        if (data->ioc_inllen1 == sizeof(*lsm)) {
+                lsm = (struct lov_stripe_md *)data->ioc_inlbuf1;
+        } else if (data->ioc_inllen1 != 0) {
+                CERROR("nonzero ioc_inllen1 != sizeof(struct lov_stripe_md)\n");
+                GOTO(out, rc = -EINVAL);
+        }
+
         switch (cmd) {
         case OBD_IOC_CREATE: {
-                struct lov_stripe_md *lsm = NULL;
-#warning FIXME: save lsm into file handle for other ops, release on close
-                rc = obd_create(&ec->conn, &data->ioc_obdo1, &lsm);
+                struct lov_stripe_md *tmp_lsm = NULL;
+                rc = obd_create(&ec->conn, &data->ioc_obdo1, &tmp_lsm);
+                if (lsm)
+                        memcpy(lsm, tmp_lsm, sizeof(*tmp_lsm));
+
                 GOTO(out, rc);
         }
 
         case OBD_IOC_GETATTR:
-                rc = obd_getattr(&ec->conn, &data->ioc_obdo1, NULL);
+                rc = obd_getattr(&ec->conn, &data->ioc_obdo1, lsm);
                 GOTO(out, rc);
 
         case OBD_IOC_SETATTR:
-                rc = obd_setattr(&ec->conn, &data->ioc_obdo1, NULL);
+                rc = obd_setattr(&ec->conn, &data->ioc_obdo1, lsm);
                 GOTO(out, rc);
 
-        case OBD_IOC_DESTROY: {
-                //void *ea;
-                rc = obd_destroy(&ec->conn, &data->ioc_obdo1, NULL);
+        case OBD_IOC_DESTROY:
+                rc = obd_destroy(&ec->conn, &data->ioc_obdo1, lsm);
                 GOTO(out, rc);
-        }
-
-        case OBD_IOC_OPEN: {
-                struct lov_stripe_md *lsm = NULL; // XXX fill in from create
 
+        case OBD_IOC_OPEN:
                 rc = obd_open(&ec->conn, &data->ioc_obdo1, lsm);
                 GOTO(out, rc);
-        }
-
-        case OBD_IOC_CLOSE: {
-                struct lov_stripe_md *lsm = NULL; // XXX fill in from create
 
+        case OBD_IOC_CLOSE:
                 rc = obd_close(&ec->conn, &data->ioc_obdo1, lsm);
                 GOTO(out, rc);
-        }
 
         case OBD_IOC_BRW_WRITE:
                 rw = OBD_BRW_WRITE;
         case OBD_IOC_BRW_READ: {
-                struct lov_stripe_md tmp_lsm; // XXX fill in from create
-                struct lov_stripe_md *lsm = &tmp_lsm; // XXX fill in from create
+                struct lov_stripe_md tmp_lsm;
                 struct obd_brw_set *set;
                 obd_count pages = 0;
                 struct brw_page *pga, *pgp;
-                __u64 id = data->ioc_obdo1.o_id;
+                __u64 off, id = data->ioc_obdo1.o_id;
                 int gfp_mask = (id & 1) ? GFP_HIGHUSER : GFP_KERNEL;
-                int verify = (id != 0);
-                __u64 off;
-                int j;
+                int j, verify = (id != 0);
+
+                if (lsm && lsm->lsm_object_id != id) {
+                        CERROR("LSM object ID ("LPU64") != id ("LPU64")\n",
+                               lsm->lsm_object_id, id);
+                        GOTO(out, rc = -EINVAL);
+                }
+
+                if (!lsm) {
+                        memset(&tmp_lsm, 0, sizeof(tmp_lsm));
+                        lsm = &tmp_lsm;
+                        lsm->lsm_object_id = id;
+                }
+
+                if (data->ioc_count < 0) {
+                        CERROR("invalid buffer size: "LPD64"\n",
+                               data->ioc_count);
+                        GOTO(out, rc = -EINVAL);
+                }
 
                 set = obd_brw_set_new();
                 if (set == NULL)
@@ -110,9 +127,6 @@ static int echo_iocontrol(long cmd, struct lustre_handle *obdconn, int len,
                         GOTO(brw_free, rc = -ENOMEM);
                 }
 
-                memset(lsm, 0, sizeof(*lsm)); // XXX don't do this later
-                lsm->lsm_object_id = id; // ensure id == lsm->lsm_object_id
-
                 for (j = 0, pgp = pga; j < pages; j++, off += PAGE_SIZE, pgp++){
                         pgp->pg = alloc_pages(gfp_mask, 0);
                         if (!pgp->pg) {
index 081174e..76d21cc 100644 (file)
@@ -206,7 +206,7 @@ static int filter_prep(struct obd_device *obd)
 
         rc = 0;
  out:
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &filter->fo_ctxt, NULL);
 
         return(rc);
 
@@ -261,7 +261,7 @@ static void filter_post(struct obd_device *obd)
         }
         f_dput(filter->fo_dentry_O);
 out:
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &filter->fo_ctxt, NULL);
 }
 
 
@@ -281,7 +281,7 @@ static __u64 filter_next_id(struct obd_device *obd)
 /* parent i_sem is already held if needed for exclusivity */
 static struct dentry *filter_fid2dentry(struct obd_device *obd,
                                         struct dentry *dparent,
-                                        __u64 id, __u32 type)
+                                        __u64 id, __u32 type, int locked)
 {
         struct super_block *sb = obd->u.filter.fo_sb;
         struct dentry *dchild;
@@ -309,7 +309,11 @@ static struct dentry *filter_fid2dentry(struct obd_device *obd,
         len = sprintf(name, LPU64, id);
         CDEBUG(D_INODE, "opening object O/%s/%s\n", obd_mode_to_type(type),
                name);
+        if (!locked)
+                down(&dparent->d_inode->i_sem);
         dchild = lookup_one_len(name, dparent, len);
+        if (!locked)
+                up(&dparent->d_inode->i_sem);
         if (IS_ERR(dchild)) {
                 CERROR("child lookup error %ld\n", PTR_ERR(dchild));
                 RETURN(dchild);
@@ -377,11 +381,13 @@ static struct file *filter_obj_open(struct obd_export *export,
 
         filter_id(name, id, type);
         push_ctxt(&saved, &filter->fo_ctxt, NULL);
-        file = filp_open(name, O_RDONLY | O_LARGEFILE, 0 /* type? */);
-        pop_ctxt(&saved);
+        file = filp_open(name, O_RDWR | O_LARGEFILE, 0 /* type? */);
+        pop_ctxt(&saved, &filter->fo_ctxt, NULL);
 
-        if (IS_ERR(file))
+        if (IS_ERR(file)) {
+                CERROR("error opening %s: rc %d\n", name, PTR_ERR(file));
                 GOTO(out_fdd, file);
+        }
 
         dentry = file->f_dentry;
         spin_lock(&filter->fo_fddlock);
@@ -415,7 +421,7 @@ static struct file *filter_obj_open(struct obd_export *export,
         list_add(&ffd->ffd_export_list, &fed->fed_open_head);
         spin_unlock(&fed->fed_lock);
 
-        CDEBUG(D_INODE, "opening objid "LPX64": rc = %p\n", id, file);
+        CDEBUG(D_INODE, "opened objid "LPX64": rc = %p\n", id, file);
 
 out:
         RETURN(file);
@@ -448,7 +454,7 @@ static int filter_destroy_internal(struct obd_device *obd,
         push_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
         rc = vfs_unlink(dir_dentry->d_inode, object_dentry);
         /* XXX unlink from PENDING directory now too */
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
 
         if (rc)
                 CERROR("error unlinking objid %*s: rc %d\n",
@@ -689,7 +695,7 @@ static struct filter_file_data *filter_handle2ffd(struct lustre_handle *handle)
 }
 
 static struct dentry *__filter_oa2dentry(struct lustre_handle *conn,
-                                         struct obdo *oa, char *what)
+                                         struct obdo *oa, int locked,char *what)
 {
         struct dentry *dentry = NULL;
 
@@ -708,7 +714,7 @@ static struct dentry *__filter_oa2dentry(struct lustre_handle *conn,
                         RETURN(ERR_PTR(-EINVAL));
                 }
                 dentry = filter_fid2dentry(obd, filter_parent(obd, oa->o_mode),
-                                           oa->o_id, oa->o_mode);
+                                           oa->o_id, oa->o_mode, locked);
         }
 
         if (IS_ERR(dentry)) {
@@ -725,7 +731,8 @@ static struct dentry *__filter_oa2dentry(struct lustre_handle *conn,
         return dentry;
 }
 
-#define filter_oa2dentry(conn, oa) __filter_oa2dentry(conn, oa, __FUNCTION__)
+#define filter_oa2dentry(conn, oa, locked) __filter_oa2dentry(conn, oa, locked,\
+                                                              __FUNCTION__)
 
 static int filter_getattr(struct lustre_handle *conn, struct obdo *oa,
                           struct lov_stripe_md *md)
@@ -734,7 +741,7 @@ static int filter_getattr(struct lustre_handle *conn, struct obdo *oa,
         int rc = 0;
         ENTRY;
 
-        dentry = filter_oa2dentry(conn, oa);
+        dentry = filter_oa2dentry(conn, oa, 0);
         if (IS_ERR(dentry))
                 RETURN(PTR_ERR(dentry));
 
@@ -755,7 +762,7 @@ static int filter_setattr(struct lustre_handle *conn, struct obdo *oa,
         int rc;
         ENTRY;
 
-        dentry = filter_oa2dentry(conn, oa);
+        dentry = filter_oa2dentry(conn, oa, 0);
 
         if (IS_ERR(dentry))
                 RETURN(PTR_ERR(dentry));
@@ -772,7 +779,7 @@ static int filter_setattr(struct lustre_handle *conn, struct obdo *oa,
                 rc = inode->i_op->setattr(dentry, &iattr);
         else
                 rc = inode_setattr(inode, &iattr);
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
         if (iattr.ia_valid & ATTR_SIZE) {
                 up(&inode->i_sem);
                 oa->o_valid = OBD_MD_FLBLOCKS | OBD_MD_FLCTIME | OBD_MD_FLMTIME;
@@ -811,8 +818,9 @@ static int filter_open(struct lustre_handle *conn, struct obdo *oa,
         handle->addr = (__u64)(unsigned long)ffd;
         handle->cookie = ffd->ffd_servercookie;
         oa->o_valid |= OBD_MD_FLHANDLE;
+        EXIT;
 out:
-        RETURN(rc);
+        return rc;
 } /* filter_open */
 
 static int filter_close(struct lustre_handle *conn, struct obdo *oa,
@@ -880,7 +888,7 @@ static int filter_create(struct lustre_handle *conn, struct obdo *oa,
         sprintf(name, LPU64, oa->o_id);
         push_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
         new = simple_mknod(filter_parent(obd, oa->o_mode), name, oa->o_mode);
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
         if (IS_ERR(new)) {
                 CERROR("Error mknod obj %s, err %ld\n", name, PTR_ERR(new));
                 return -ENOENT;
@@ -914,7 +922,7 @@ static int filter_destroy(struct lustre_handle *conn, struct obdo *oa,
         dir_dentry = filter_parent(obd, oa->o_mode);
         down(&dir_dentry->d_inode->i_sem);
 
-        object_dentry = filter_oa2dentry(conn, oa);
+        object_dentry = filter_oa2dentry(conn, oa, 1);
         if (IS_ERR(object_dentry))
                 GOTO(out, rc = -ENOENT);
 
@@ -1034,7 +1042,7 @@ static int filter_pgcache_brw(int cmd, struct lustre_handle *conn,
 
         EXIT;
 out:
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &export->exp_obd->u.filter.fo_ctxt, NULL);
         error = (retval >= 0) ? 0 : retval;
         return error;
 }
@@ -1467,7 +1475,7 @@ static int filter_preprw(int cmd, struct lustre_handle *conn,
                 int j;
 
                 dentry = filter_fid2dentry(obd, filter_parent(obd, S_IFREG),
-                                           o->ioo_id, S_IFREG);
+                                           o->ioo_id, S_IFREG, 0);
                 if (IS_ERR(dentry))
                         GOTO(out_clean, rc = PTR_ERR(dentry));
                 inode = dentry->d_inode;
@@ -1512,7 +1520,7 @@ out_stop:
                         rc = err;
         }
 out_ctxt:
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
         RETURN(rc);
 out_clean:
         while (lnb-- > res) {
@@ -1637,7 +1645,7 @@ static int filter_commitrw(int cmd, struct lustre_handle *conn,
         }
 
 out_ctxt:
-        pop_ctxt(&saved);
+        pop_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
         RETURN(rc);
 }
 
index 532ec14..52703c8 100644 (file)
@@ -83,8 +83,10 @@ static int osc_packmd(struct lustre_handle *conn, struct lov_mds_md **lmmp,
                 if (!*lmmp)
                         RETURN(-ENOMEM);
         }
-        if (lsm)
+        if (lsm) {
+                LASSERT(lsm->lsm_object_id);
                 (*lmmp)->lmm_object_id = (lsm->lsm_object_id);
+        }
 
         return lmm_size;
 }
@@ -111,8 +113,10 @@ static int osc_unpackmd(struct lustre_handle *conn, struct lov_stripe_md **lsmp,
         }
 
         /* XXX endianness */
-        if (lmm)
+        if (lmm) {
                 (*lsmp)->lsm_object_id = (lmm->lmm_object_id);
+                LASSERT((*lsmp)->lsm_object_id);
+        }
 
         return lsm_size;
 }
index ced4655..2d47fcd 100644 (file)
@@ -303,13 +303,9 @@ out_bulk:
 out_local:
         OBD_FREE(local_nb, sizeof(*local_nb) * niocount);
 out:
-        if (rc) {
-                /* It's a lot of work to delay allocating the reply, and a lot
-                 * less work to just free it here. */
-                OBD_FREE(req->rq_repmsg, req->rq_replen);
-                req->rq_repmsg = NULL;
+        if (rc)
                 ptlrpc_error(req->rq_svc, req);
-        else
+        else
                 ptlrpc_reply(req->rq_svc, req);
         RETURN(rc);
 }
index 22029f1..e563f7b 100644 (file)
@@ -1,7 +1,7 @@
 --- linux-2.4.18-17.8.0-uml-pristine/include/linux/lustre_version.h    Wed Dec 31 19:00:00 1969
-+++ linux-2.4.18-17.8.0-uml/include/linux/lustre_version.h     Wed Nov  6 02:34:14 2002
++++ linux-2.4.18-17.8.0-uml/include/linux/lustre_version.h     Tue Nov 26 07:02:14 2002
 @@ -0,0 +1 @@
-+#define LUSTRE_KERNEL_VERSION 2
++#define LUSTRE_KERNEL_VERSION 3
 --- linux-2.4.18-17.8.0-uml-pristine/arch/ia64/mm/init.c       2002-10-19 11:44:08.000000000 -0600
 +++ linux-2.4.18-17.8.0-uml/arch/ia64/mm/init.c        2002-10-19 11:44:51.000000000 -0600
 @@ -37,6 +37,12 @@
 +{
 +      if (de->d_op && de->d_op->d_intent_release)
 +              de->d_op->d_intent_release(de, it);
-+      de->d_it = NULL;
++
 +}
 +
 +
        dir = nd->dentry;
        down(&dir->d_inode->i_sem);
 -      dentry = lookup_hash(&nd->last, nd->dentry);
-+      dentry = lookup_hash_it(&nd->last, nd->dentry, NULL);
++      dentry = lookup_hash_it(&nd->last, nd->dentry, it);
        putname(nd->last.name);
        goto do_last;
  }
index 6dac001..2d534f5 100644 (file)
@@ -1,3 +1,7 @@
+--- linux-2.4.18-17.8.0-uml-pristine/include/linux/lustre_version.h    Wed Dec 31 19:00:00 1969
++++ linux-2.4.18-17.8.0-uml/include/linux/lustre_version.h     Tue Nov 26 07:02:14 2002
+@@ -0,0 +1 @@
++#define LUSTRE_KERNEL_VERSION 3
 --- kernel-2.4.18-pristine/arch/ia64/mm/init.c 2002-10-14 13:47:20.000000000 -0600
 +++ kernel-2.4.18/arch/ia64/mm/init.c  2002-10-14 14:08:23.000000000 -0600
 @@ -37,6 +37,12 @@
 +{
 +      if (de->d_op && de->d_op->d_intent_release)
 +              de->d_op->d_intent_release(de, it);
-+      de->d_it = NULL;
++
 +}
 +
 +
        dir = nd->dentry;
        down(&dir->d_inode->i_sem);
 -      dentry = lookup_hash(&nd->last, nd->dentry);
-+      dentry = lookup_hash_it(&nd->last, nd->dentry, NULL);
++      dentry = lookup_hash_it(&nd->last, nd->dentry, it);
        putname(nd->last.name);
        goto do_last;
  }
index b60ec1f..04a76f2 100644 (file)
@@ -376,11 +376,13 @@ static int ptlrpc_check_reply(struct ptlrpc_request *req)
         }
 
         if (req->rq_flags & PTL_RPC_FL_RESEND) {
+                ENTRY;
                 DEBUG_REQ(D_ERROR, req, "RESEND:");
                 GOTO(out, rc = 1);
         }
 
         if (req->rq_flags & PTL_RPC_FL_ERR) {
+                ENTRY;
                 DEBUG_REQ(D_ERROR, req, "ABORTED:");
                 GOTO(out, rc = 1);
         }
@@ -401,15 +403,15 @@ static int ptlrpc_check_status(struct ptlrpc_request *req)
 
         err = req->rq_repmsg->status;
         if (req->rq_repmsg->type == NTOH__u32(PTL_RPC_MSG_ERR)) {
-                CERROR("req->rq_repmsg->type == PTL_RPC_MSG_ERR\n");
+                DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR");
                 RETURN(err ? err : -EINVAL);
         }
 
-        if (err != 0) {
-                if (err < 0)
-                        CDEBUG(D_INFO, "req->rq_repmsg->status is %d\n", err);
-                else
-                        CDEBUG(D_INFO, "req->rq_repmsg->status is %d\n", err);
+        if (err < 0) {
+                DEBUG_REQ(D_ERROR, req, "status is %d", err);
+        } else if (err > 0) {
+                /* XXX: translate this error from net to host */
+                DEBUG_REQ(D_INFO, req, "status is %d", err);
         }
 
         RETURN(err);
@@ -439,6 +441,10 @@ void ptlrpc_free_committed(struct obd_import *imp)
 {
         struct list_head *tmp, *saved;
         struct ptlrpc_request *req;
+        ENTRY;
+
+        CDEBUG(D_HA, "committing for xid "LPU64", last_committed "LPU64"\n",
+               imp->imp_peer_last_xid, imp->imp_peer_committed_transno);
 
         list_for_each_safe(tmp, saved, &imp->imp_replay_list) {
                 req = list_entry(tmp, struct ptlrpc_request, rq_list);
@@ -721,8 +727,8 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req)
                 imp->imp_peer_last_xid = req->rq_repmsg->last_xid;
                 imp->imp_peer_committed_transno =
                         req->rq_repmsg->last_committed;
-                spin_unlock(&imp->imp_lock);
                 ptlrpc_free_committed(imp);
+                spin_unlock(&imp->imp_lock);
         }
 
         rc = ptlrpc_check_status(req);
index 448b2a8..0bdf0d8 100644 (file)
@@ -39,7 +39,8 @@ static int request_out_callback(ptl_event_t *ev)
         struct ptlrpc_request *req = ev->mem_desc.user_ptr;
         ENTRY;
 
-        LASSERT ((ev->mem_desc.options & PTL_MD_IOV) == 0); /* requests always contiguous */
+        /* requests always contiguous */
+        LASSERT((ev->mem_desc.options & PTL_MD_IOV) == 0);
 
         if (ev->type != PTL_EVENT_SENT) {
                 // XXX make sure we understand all events, including ACK's
@@ -60,7 +61,8 @@ static int reply_out_callback(ptl_event_t *ev)
 {
         ENTRY;
 
-        LASSERT ((ev->mem_desc.options & PTL_MD_IOV) == 0); /* replies always contiguous */
+        /* replies always contiguous */
+        LASSERT((ev->mem_desc.options & PTL_MD_IOV) == 0);
 
         if (ev->type == PTL_EVENT_SENT) {
                 OBD_FREE(ev->mem_desc.start, ev->mem_desc.length);
@@ -81,7 +83,8 @@ static int reply_in_callback(ptl_event_t *ev)
         struct ptlrpc_request *req = ev->mem_desc.user_ptr;
         ENTRY;
 
-        LASSERT ((ev->mem_desc.options & PTL_MD_IOV) == 0); /* replies always contiguous */
+        /* replies always contiguous */
+        LASSERT((ev->mem_desc.options & PTL_MD_IOV) == 0);
 
         if (req->rq_xid == 0x5a5a5a5a5a5a5a5a) {
                 CERROR("Reply received for freed request!  Probably a missing "
@@ -113,30 +116,29 @@ int request_in_callback(ptl_event_t *ev)
         struct ptlrpc_service *service = rqbd->rqbd_service;
 
         /* requests always contiguous */
-        LASSERT ((ev->mem_desc.options & PTL_MD_IOV) == 0);
+        LASSERT((ev->mem_desc.options & PTL_MD_IOV) == 0);
         /* we only enable puts */
-        LASSERT (ev->type == PTL_EVENT_PUT);
-        LASSERT (atomic_read (&service->srv_nrqbds_receiving) > 0);
-        LASSERT (atomic_read (&rqbd->rqbd_refcount) > 0);
+        LASSERT(ev->type == PTL_EVENT_PUT);
+        LASSERT(atomic_read(&service->srv_nrqbds_receiving) > 0);
+        LASSERT(atomic_read(&rqbd->rqbd_refcount) > 0);
 
         if (ev->rlength != ev->mlength)
                 CERROR("Warning: Possibly truncated rpc (%d/%d)\n",
                        ev->mlength, ev->rlength);
 
-        if (ptl_is_valid_handle (&ev->unlinked_me)) {
+        if (ptl_is_valid_handle(&ev->unlinked_me)) {
                 /* This is the last request to be received into this
                  * request buffer.  We don't bump the refcount, since the
                  * thread servicing this event is effectively taking over
                  * portals' reference.
                  */
 #warning ev->unlinked_me.nal_idx is not set properly in a callback
-                LASSERT (ev->unlinked_me.handle_idx == rqbd->rqbd_me_h.handle_idx);
+                LASSERT(ev->unlinked_me.handle_idx==rqbd->rqbd_me_h.handle_idx);
 
                 /* we're off the air */
-                if (atomic_dec_and_test (&service->srv_nrqbds_receiving)) {
-                        CERROR ("All request buffers busy\n");
-                        /* we'll probably start dropping packets in portals soon */
-                }
+                /* we'll probably start dropping packets in portals soon */
+                if (atomic_dec_and_test(&service->srv_nrqbds_receiving))
+                        CERROR("All request buffers busy\n");
         } else {
                 /* +1 ref for service thread */
                 atomic_inc(&rqbd->rqbd_refcount);
@@ -159,15 +161,15 @@ static int bulk_source_callback(ptl_event_t *ev)
                (ev->type == PTL_EVENT_SENT) ? "SENT" :
                (ev->type == PTL_EVENT_ACK)  ? "ACK"  : "UNEXPECTED", ev->type);
 
-        LASSERT (ev->type == PTL_EVENT_SENT || ev->type == PTL_EVENT_ACK);
+        LASSERT(ev->type == PTL_EVENT_SENT || ev->type == PTL_EVENT_ACK);
 
-        LASSERT (atomic_read (&desc->bd_source_callback_count) > 0 &&
-                 atomic_read (&desc->bd_source_callback_count) <= 2);
+        LASSERT(atomic_read(&desc->bd_source_callback_count) > 0 &&
+                atomic_read(&desc->bd_source_callback_count) <= 2);
 
         /* 1 fragment for each page always */
-        LASSERT (ev->mem_desc.niov == desc->bd_page_count);
+        LASSERT(ev->mem_desc.niov == desc->bd_page_count);
 
-        if (atomic_dec_and_test (&desc->bd_source_callback_count)) {
+        if (atomic_dec_and_test(&desc->bd_source_callback_count)) {
                 list_for_each_safe(tmp, next, &desc->bd_page_list) {
                         bulk = list_entry(tmp, struct ptlrpc_bulk_page,
                                           bp_link);
@@ -195,11 +197,11 @@ static int bulk_sink_callback(ptl_event_t *ev)
 
         if (ev->type == PTL_EVENT_PUT) {
                 /* put with zero offset */
-                LASSERT (ev->offset == 0);
+                LASSERT(ev->offset == 0);
                 /* used iovs */
-                LASSERT ((ev->mem_desc.options & PTL_MD_IOV) != 0);
+                LASSERT((ev->mem_desc.options & PTL_MD_IOV) != 0);
                 /* 1 fragment for each page always */
-                LASSERT (ev->mem_desc.niov == desc->bd_page_count);
+                LASSERT(ev->mem_desc.niov == desc->bd_page_count);
 
                 list_for_each_safe (tmp, next, &desc->bd_page_list) {
                         bulk = list_entry(tmp, struct ptlrpc_bulk_page,
@@ -211,7 +213,7 @@ static int bulk_sink_callback(ptl_event_t *ev)
                                 bulk->bp_cb(bulk);
                 }
 
-                LASSERT (ev->mem_desc.length == total);
+                LASSERT(ev->mem_desc.length == total);
 
                 desc->bd_flags |= PTL_BULK_FL_RCVD;
                 wake_up(&desc->bd_waitq);
index 81ae6b2..c2c2b32 100644 (file)
@@ -134,17 +134,17 @@ int ptlrpc_send_bulk(struct ptlrpc_bulk_desc *desc)
         desc->bd_md.options = PTL_MD_OP_PUT | PTL_MD_IOV;
         desc->bd_md.user_ptr = desc;
 
-        atomic_set (&desc->bd_source_callback_count, 2);
+        atomic_set(&desc->bd_source_callback_count, 2);
 
         list_for_each_safe(tmp, next, &desc->bd_page_list) {
                 struct ptlrpc_bulk_page *bulk;
                 bulk = list_entry(tmp, struct ptlrpc_bulk_page, bp_link);
 
-                LASSERT (desc->bd_md.niov < desc->bd_page_count);
+                LASSERT(desc->bd_md.niov < desc->bd_page_count);
 
                 if (desc->bd_md.niov == 0)
                         xid = bulk->bp_xid;
-                LASSERT (xid == bulk->bp_xid);   /* should all be the same */
+                LASSERT(xid == bulk->bp_xid);   /* should all be the same */
 
                 iov[desc->bd_md.niov].iov_base = bulk->bp_buf;
                 iov[desc->bd_md.niov].iov_len = bulk->bp_buflen;
@@ -152,8 +152,8 @@ int ptlrpc_send_bulk(struct ptlrpc_bulk_desc *desc)
                 desc->bd_md.length += bulk->bp_buflen;
         }
 
-        LASSERT (desc->bd_md.niov == desc->bd_page_count);
-        LASSERT (desc->bd_md.niov != 0);
+        LASSERT(desc->bd_md.niov == desc->bd_page_count);
+        LASSERT(desc->bd_md.niov != 0);
 
         rc = PtlMDBind(desc->bd_connection->c_peer.peer_ni, desc->bd_md,
                        &desc->bd_md_h);
@@ -217,11 +217,11 @@ int ptlrpc_register_bulk(struct ptlrpc_bulk_desc *desc)
                 struct ptlrpc_bulk_page *bulk;
                 bulk = list_entry(tmp, struct ptlrpc_bulk_page, bp_link);
 
-                LASSERT (desc->bd_md.niov < desc->bd_page_count);
+                LASSERT(desc->bd_md.niov < desc->bd_page_count);
 
                 if (desc->bd_md.niov == 0)
                         xid = bulk->bp_xid;
-                LASSERT (xid == bulk->bp_xid);   /* should all be the same */
+                LASSERT(xid == bulk->bp_xid);   /* should all be the same */
 
                 iov[desc->bd_md.niov].iov_base = bulk->bp_buf;
                 iov[desc->bd_md.niov].iov_len = bulk->bp_buflen;
@@ -229,8 +229,8 @@ int ptlrpc_register_bulk(struct ptlrpc_bulk_desc *desc)
                 desc->bd_md.length += bulk->bp_buflen;
         }
 
-        LASSERT (desc->bd_md.niov == desc->bd_page_count);
-        LASSERT (desc->bd_md.niov != 0);
+        LASSERT(desc->bd_md.niov == desc->bd_page_count);
+        LASSERT(desc->bd_md.niov != 0);
 
         source_id.nid = desc->bd_connection->c_peer.peer_nid;
         source_id.pid = PTL_PID_ANY;
@@ -454,7 +454,7 @@ void ptlrpc_link_svc_me(struct ptlrpc_request_buffer_desc *rqbd)
         ptl_md_t dummy;
         ptl_handle_md_t md_h;
 
-        LASSERT (atomic_read (&rqbd->rqbd_refcount) == 0);
+        LASSERT(atomic_read(&rqbd->rqbd_refcount) == 0);
 
         /* Attach the leading ME on which we build the ring */
         rc = PtlMEAttach(service->srv_self.peer_ni, service->srv_req_portal,
@@ -473,8 +473,8 @@ void ptlrpc_link_svc_me(struct ptlrpc_request_buffer_desc *rqbd)
         dummy.user_ptr   = rqbd;
         dummy.eventq     = service->srv_eq_h;
 
-        atomic_inc (&service->srv_nrqbds_receiving);
-        atomic_set (&rqbd->rqbd_refcount, 1);   /* 1 ref for portals */
+        atomic_inc(&service->srv_nrqbds_receiving);
+        atomic_set(&rqbd->rqbd_refcount, 1);   /* 1 ref for portals */
 
         rc = PtlMDAttach(rqbd->rqbd_me_h, dummy, PTL_UNLINK, &md_h);
         if (rc != PTL_OK) {
@@ -482,7 +482,7 @@ void ptlrpc_link_svc_me(struct ptlrpc_request_buffer_desc *rqbd)
                 LBUG();
 #warning proper cleanup required
                 PtlMEUnlink (rqbd->rqbd_me_h);
-                atomic_set (&rqbd->rqbd_refcount, 0);
-                atomic_dec (&service->srv_nrqbds_receiving);
+                atomic_set(&rqbd->rqbd_refcount, 0);
+                atomic_dec(&service->srv_nrqbds_receiving);
         }
 }
index f62920a..49d79dc 100644 (file)
@@ -76,6 +76,7 @@ int lustre_msg_size(int count, int *lengths)
 int lustre_unpack_msg(struct lustre_msg *m, int len)
 {
         int required_len, i;
+        ENTRY;
 
         required_len = size_round(sizeof(*m));
         if (len < required_len)
index fbfebe7..acdecf8 100644 (file)
@@ -32,7 +32,7 @@ int ptlrpc_reconnect_import(struct obd_import *imp, int rq_opc)
         char *tmp[] = {cli->cl_target_uuid, obd->obd_uuid };
         struct ptlrpc_connection *conn = imp->imp_connection;
         struct lustre_handle old_hdl;
-        struct ptlrpc_request *request; 
+        struct ptlrpc_request *request;
         struct obd_export *ldlmexp;
         int rc;
 
@@ -79,7 +79,7 @@ int ptlrpc_reconnect_import(struct obd_import *imp, int rq_opc)
                         imp->imp_handle.cookie = request->rq_repmsg->cookie;
                         GOTO(out_disc, rc = EALREADY);
                 }
-                
+
                 CERROR("reconnected to %s@%s after partition\n",
                        cli->cl_target_uuid, conn->c_remote_uuid);
                 GOTO(out_disc, rc = EALREADY);
@@ -147,10 +147,10 @@ int ptlrpc_replay(struct obd_import *imp, int send_last_flag)
         /* It might have committed some after we last spoke, so make sure we
          * get rid of them now.
          */
-        ptlrpc_free_committed(imp);
-
         spin_lock(&imp->imp_lock);
 
+        ptlrpc_free_committed(imp);
+
         CDEBUG(D_HA, "import %p from %s has committed "LPD64"\n",
                imp, imp->imp_obd->u.cli.cl_target_uuid, committed);
 
@@ -159,7 +159,7 @@ int ptlrpc_replay(struct obd_import *imp, int send_last_flag)
                 DEBUG_REQ(D_HA, req, "RETAINED: ");
         }
 
-        list_for_each_safe(tmp, pos, &imp->imp_replay_list) { 
+        list_for_each_safe(tmp, pos, &imp->imp_replay_list) {
                 req = list_entry(tmp, struct ptlrpc_request, rq_list);
 
                 if (req->rq_transno == imp->imp_max_transno &&
@@ -258,6 +258,7 @@ int ptlrpc_resend(struct obd_import *imp)
                         LBUG();
                 }
         }
+
         RETURN(rc);
 }
 
index f9c4212..1688ff9 100644 (file)
@@ -48,10 +48,10 @@ static int ptlrpc_check_event(struct ptlrpc_service *svc,
         case PTL_OK:
                 thread->t_flags |= SVC_EVENT;
                 GOTO(out, rc = 1);
-                
+
         case PTL_EQ_EMPTY:
                 GOTO(out, rc = 0);
-                
+
         default:
                 CERROR("BUG: PtlEQGet returned %d\n", rc);
                 LBUG();
@@ -172,8 +172,8 @@ static int handle_incoming_request(struct obd_device *obddev,
         }
 
         CDEBUG(D_RPCTRACE, "Handling RPC pid:xid:nid:opc %d:"
-               LPX64":%x:%d\n", 
-               NTOH__u32(request->rq_reqmsg->status), 
+               LPX64":%x:%d\n",
+               NTOH__u32(request->rq_reqmsg->status),
                request->rq_xid,
                event->initiator.nid,
                NTOH__u32(request->rq_reqmsg->opc));
@@ -232,6 +232,18 @@ static int handle_incoming_request(struct obd_device *obddev,
         return rc;
 }
 
+/* Don't use daemonize, it removes fs struct from new thread  (bug 418) */
+static void ptlrpc_daemonize(void)
+{
+        exit_mm(current);
+
+        current->session = 1;
+        current->pgrp = 1;
+        current->tty = NULL;
+
+        exit_files(current);
+}
+
 static int ptlrpc_main(void *arg)
 {
         struct ptlrpc_svc_data *data = (struct ptlrpc_svc_data *)arg;
@@ -245,7 +257,8 @@ static int ptlrpc_main(void *arg)
         ENTRY;
 
         lock_kernel();
-        daemonize();
+        ptlrpc_daemonize();
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
         sigfillset(&current->blocked);
         recalc_sigpending();
@@ -257,8 +270,7 @@ static int ptlrpc_main(void *arg)
 #endif
 
 #ifdef __arch_um__
-        sprintf(current->comm, "%s|%d", 
-                data->name, current->thread.extern_pid);
+        sprintf(current->comm, "%s|%d", data->name,current->thread.extern_pid);
 #else
         strcpy(current->comm, data->name);
 #endif
@@ -370,9 +382,7 @@ int ptlrpc_start_thread(struct obd_device *dev, struct ptlrpc_service *svc,
         list_add(&thread->t_link, &svc->srv_threads);
         spin_unlock(&svc->srv_lock);
 
-        /* XXX should we really be cloning open file handles here? */
-        rc = kernel_thread(ptlrpc_main, (void *) &d,
-                           CLONE_VM | CLONE_FS | CLONE_FILES);
+        rc = kernel_thread(ptlrpc_main, (void *) &d, CLONE_VM | CLONE_FILES);
         if (rc < 0) {
                 CERROR("cannot start thread\n");
                 OBD_FREE(thread, sizeof(*thread));
index a33c1e5..199f5be 100644 (file)
@@ -3,7 +3,7 @@
 # This code is issued under the GNU General Public License.
 # See the file COPYING in this distribution
 
-EXTRA_DIST = license-status maketags.sh lustre.spec $(initd_SCRIPTS)
+EXTRA_DIST = license-status maketags.sh lustre.spec version_tag.pl $(initd_SCRIPTS)
 initddir = $(sysconfdir)/init.d
 initd_SCRIPTS = lustre
 include $(top_srcdir)/Rules
diff --git a/lustre/scripts/version_tag.pl b/lustre/scripts/version_tag.pl
new file mode 100644 (file)
index 0000000..e810f3f
--- /dev/null
@@ -0,0 +1,156 @@
+#!/usr/bin/perl
+# -*- Mode: perl; indent-tabs-mode: nil; cperl-indent-level: 4 -*-
+
+use strict;
+use diagnostics;
+use IO::File;
+use Time::Local;
+
+my $pristine = 1;
+my $kernver;
+
+sub get_tag()
+{
+    my $tag;
+
+    my $tagfile = new IO::File;
+    if (!$tagfile->open("CVS/Tag")) {
+        return "HEAD";
+    } else {
+        my $tmp = <$tagfile>;
+        $tagfile->close();
+
+        $tmp =~ m/T(.*)/;
+        return $1;
+    }
+}
+
+sub get_latest_mtime()
+{
+    my %months=("Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4,
+                "Jun" => 5, "Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9,
+                "Nov" => 10, "Dec" => 11);
+
+    my $last_mtime = 0;
+    my @entries = `find . -name Entries`;
+    my $entry_file;
+    foreach $entry_file (@entries) {
+        chomp($entry_file);
+        my $entry = new IO::File;
+        if (!$entry->open($entry_file)) {
+            die "unable to open $entry_file: $!\n";
+        }
+        my $line;
+        while (defined($line = <$entry>)) {
+            chomp($line);
+            #print "line: $line\n";
+            my ($junk, $file, $version, $date) = split(/\//, $line);
+
+            #print "junk: $junk\nfile: $file\nver: $version\ndate: $date\n";
+            #print "last_mtime: " . localtime($last_mtime) . "\n";
+
+            if ($junk eq "D" ||
+                $file eq "lustre.spec.in" ||
+                $file !~ m/\.(c|h|am|in)$/) {
+                next;
+            }
+
+            my $cur_dir = $entry_file;
+            $cur_dir =~ s/\/CVS\/Entries$//;
+            my @statbuf = stat("$cur_dir/$file");
+            my $mtime = $statbuf[9];
+            my $local_date = gmtime($mtime);
+            if ($local_date ne $date &&
+                $file ne "lustre.spec.in") {
+                #print "$file : " . localtime($mtime) . "\n";
+                $pristine = 0;
+            }
+
+            if ($mtime > $last_mtime) {
+                $last_mtime = $mtime;
+            }
+
+            if ($date) {
+                my @t = split(/ +/, $date);
+                if (int(@t) != 5) {
+                    #print "skipping: $date\n";
+                    next;
+                }
+                my ($hours, $min, $sec) = split(/:/, $t[3]);
+                my ($mon, $mday, $year) = ($t[1], $t[2], $t[4]);
+                my $secs = 0;
+                $mon = $months{$mon};
+                $secs = timelocal($sec, $min, $hours, $mday, $mon, $year);
+                if ($secs > $last_mtime) {
+                    $last_mtime = $secs;
+                }
+            }
+        }
+        $entry->close();
+    }
+    return $last_mtime;
+}
+
+sub get_linuxdir()
+{
+    my $config = new IO::File;
+    my ($line, $dir);
+    if (!$config->open("Makefile")) {
+        die "Run ./configure first\n";
+    }
+    while (defined($line = <$config>)) {
+        chomp($line);
+        if ($line =~ /LINUX = (.*)/) {
+            $dir = $1;
+            last;
+        }
+    }
+    $config->close();
+    my $ver = new IO::File;
+    if (!$ver->open("$dir/include/linux/version.h")) {
+        die "Run make dep on $dir\n";
+    }
+    while(defined($line = <$ver>)) {
+        $line =~ /\#define UTS_RELEASE "(.*)"/;
+        if ($1) {
+            $kernver = $1;
+            last;
+        }
+    }
+    $ver->close();
+    chomp($kernver);
+    $dir =~ s/\//\./g;
+    return $dir;
+}
+
+sub generate_ver($$$)
+{
+    my $tag = shift;
+    my $mtime = shift;
+    my $linuxdir = shift;
+
+    #print "localtime: " . localtime($mtime) . "\n";
+
+    my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
+      localtime($mtime);
+    $year += 1900;
+    $mon++;
+    my $show_last = $year . $mon . $mday . $hour . $min . $sec;
+
+    print "#define BUILD_VERSION \"";
+    if ($pristine) {
+        print "$tag-$show_last-PRISTINE-$linuxdir-$kernver\"\n";
+    } else {
+        print "$tag-$show_last-CHANGED-$linuxdir-$kernver\"\n";
+    }
+}
+
+if ($ARGV[0]) {
+    chdir($ARGV[0]);
+}
+my $linuxdir = get_linuxdir();
+my $tag = get_tag();
+my $mtime = get_latest_mtime();
+generate_ver($tag, $mtime, $linuxdir);
+
+exit(0);
index 6038ab9..f09b85c 100644 (file)
@@ -8,7 +8,7 @@ EXTRA_DIST = $(pkgexample_SCRIPTS) $(noinst_SCRIPTS) $(noinst_DATA) \
        common.sh lustre.cfg \
        client-echo.cfg    elan-server.cfg  net-client.cfg  obdecho.cfg \
        client-mount.cfg   ldlm.cfg         net-local.cfg   obdfilter.cfg \
-       client-mount2.cfg  lustre.cfg       net-server.cfg  sanity.sh   \
+       client-mount2.cfg  lustre.cfg       net-server.cfg  sanity.sh \
        rundbench \
        elan-client.cfg    mds.cfg      trivial.sh
 pkgexampledir = '${exec_prefix}/usr/lib/$(PACKAGE)/examples'
@@ -24,7 +24,7 @@ noinst_SCRIPTS += fs.sh intent-test.sh intent-test2.sh leak_finder.pl \
        runtests runvmstat snaprun.sh tbox.sh  common.sh
 noinst_PROGRAMS = openunlink testreq truncate directio openme writeme mcreate
 noinst_PROGRAMS += munlink tchmod toexcl fsx test_brw openclose createdestroy
-noinst_PROGRAMS += lovstripe stat createmany mkdirmany # ldaptest 
+noinst_PROGRAMS += lovstripe stat createmany mkdirmany setuid # ldaptest 
 
 # ldaptest_SOURCES = ldaptest.c
 tchmod_SOURCES = tchmod.c
@@ -45,5 +45,6 @@ lovstripe_SOURCES = lovstripe.c
 stat_SOURCES = stat.c
 createmany_SOURCES = createmany.c
 mkdirmany_SOURCES = mkdirmany.c
+setuid_SOURCES = setuid.c
 
 include $(top_srcdir)/Rules
index acdb3aa..55fc290 100755 (executable)
@@ -3,27 +3,81 @@
 # the CVS HEAD are allowed.
 set -vxe
 
-if [ "$LOCAL" != no ]; then
-       export NAME=${LOCAL:-local}
-       sh ${NAME}.sh
-       [ "$RUNTESTS" != "no" ] && sh runtests --reformat ${NAME}.xml
+[ "$CONFIGS" ] || CONFIGS="local lov"
+[ "$THREADS" ] || THREADS=1
+[ "$SIZE" ] || SIZE=20480
+[ "$RSIZE" ] || RSIZE=64
+[ "$UID" ] || UID=1000
+[ "$MNT" ] || MNT=/mnt/lustre
+[ "$COUNT" ] || COUNT=1000
+[ "$DEBUG_OFF" ] || DEBUG_OFF="eval echo 0 > /proc/sys/portals/debug"
 
-       mount | grep lustre_lite || sh llmount.sh
-       [ "$SANITY" != "no" ] && sh sanity.sh
-       [ "$DBENCH" != "no" ]  && sh rundbench 1
-       [ "$BONNIE" != "no" ] && bonnie++ -s 0 -n 10 -u 0 -d /mnt/lustre
-       sync; sync
-       sh llmountcleanup.sh
-fi
+for NAME in $CONFIGS; do
+       export NAME
+       [ -e $NAME.sh ] && sh $NAME.sh
+       [ ! -e $NAME.xml ] && echo "no config '$NAME.xml'" 1>&2 && exit 1
+
+       if [ "$RUNTESTS" != "no" ]; then
+               sh runtests
+       fi
 
-if [ "$LOV" != no ]; then
-       export NAME=${LOV:-lov}
-       sh ${NAME}.sh
-       [ "$RUNTESTS" != "no" ] && sh runtests --reformat ${NAME}.xml
-       mount | grep lustre_lite || sh llmount.sh
+       mount | grep $MNT || sh llmount.sh
        [ "$SANITY" != "no" ] && sh sanity.sh
-       [ "$DBENCH" != "no" ] && sh rundbench 1
-       [ "$BONNIE" != "no" ] && bonnie++ -s 0 -n 10 -u 0 -d /mnt/lustre
-       sync; sync
-       sh llmountcleanup.sh
-fi
+       if [ "$DBENCH" != "no" ]; then
+               $DEBUG_OFF
+               sh rundbench 1
+               sh llmountcleanup.sh
+               sh llrmount.sh
+               if [ $THREADS -gt 1 ]; then
+                       sh rundbench $THREADS
+                       sh llmountcleanup.sh
+                       sh llrmount.sh
+               fi
+               rm -f /mnt/lustre/client.txt
+       fi
+       chown $UID $MNT && chmod 700 $MNT
+       if [ "$BONNIE" != "no" ]; then
+               $DEBUG_OFF
+               bonnie++ -s 0 -n 10 -u $UID -d $MNT
+               sh llmountcleanup.sh
+               sh llrmount.sh
+       fi
+       IOZONE_OPTS="-i 0 -i 1 -i 2 -+d -r $RSIZE -s $SIZE"
+       IOZONE_FILE="-f $MNT/iozone"
+       if [ "$IOZONE" != "no" ]; then
+               $DEBUG_OFF
+               iozone $IOZONE_OPTS $IOZONE_FILE
+               sh llmountcleanup.sh
+               sh llrmount.sh
+       fi
+       if [ "$IOZONE_DIR" != "no" ]; then
+               $DEBUG_OFF
+               iozone -I $IOZONE_OPTS $IOZONE_FILE.odir
+               IOZVER=`iozone -v | awk '/Revision:/ { print $3 }' | tr -d '.'`
+               sh llmountcleanup.sh
+               sh llrmount.sh
+               if [ "$THREADS" -gt 1 -a "$IOZVER" -ge 3145 ]; then
+                       $DEBUG_OFF
+                       THREAD=1
+                       IOZONE_FILE="-F "
+                       SIZE=`expr $SIZE / $THREADS`
+                       while [ $THREAD -le $THREADS ]; do
+                               IOZONE_FILE="$IOZONE_FILE $MNT/iozone.$THREAD"
+                               THREAD=`expr $THREAD + 1`
+                       done
+                       iozone -I $IOZONE_OPTS -t $THREADS $IOZONE_FILE
+                       sh llmountcleanup.sh
+                       sh llrmount.sh
+               elif [ $IOZONEVER -lt 3145 ]; then
+                       VER=`iozone -v | awk '/Revision:/ { print $3 }'`
+                       echo "iozone $VER too old for multi-threaded tests"
+               fi
+       fi
+       if [ "$FSX" != "no" ]; then
+               $DEBUG_OFF
+               ./fsx -c 50 -p 1000 -l 1024000 -N $(($COUNT * 100)) $MNT/fsxfile
+               sh llmountcleanup.sh
+               #sh llrmount.sh
+       fi      
+       mount | grep $MNT && sh llmountcleanup.sh
+done
index d971016..a3b97cd 100644 (file)
@@ -5,7 +5,6 @@ config=${1:-ba-echo.xml}
 LMC="save_cmd"
 LMC_REAL="../../lustre/utils/lmc -m $config"
 
-PORT=988
 TCPBUF=1048576
 OST=ba-ost-1
 CLIENT=client
@@ -23,13 +22,13 @@ save_cmd() {
 [ -f $config ] && rm $config
 
 # Client node
-${LMC} --node $CLIENT --tcpbuf $TCPBUF --net '*' tcp $PORT
+${LMC} --node $CLIENT --tcpbuf $TCPBUF --net '*' tcp
 
 OBD_UUID=`awk "/$OST / { print \\$3 }" $UUIDLIST`
 [ "$OBD_UUID" ] && OBD_UUID="--obduuid=$OBD_UUID" || echo "$OST: no UUID"
 
 # server node
-${LMC} --node $OST --tcpbuf $TCPBUF --net $OST tcp $PORT
+${LMC} --node $OST --tcpbuf $TCPBUF --net $OST tcp
 ${LMC} --node $OST --obdtype=obdecho $OBD_UUID --ost
 
 # osc on client
index 78ad45d..b81455f 100644 (file)
@@ -16,7 +16,7 @@ LMC_REAL="${LMC:-../utils/lmc} -m $config"
 LMC="save_cmd"
 
 TCPBUF=1048576
-OST=ba-ost-1
+OST=${OST:-ba-ost-1}
 MDS=`hostname`
  
 UUIDLIST=${UUIDLIST:-/usr/local/admin/ba-ost/UUID.txt}
index c8bf567..341d31b 100644 (file)
@@ -1,10 +1,13 @@
 #!/usr/bin/perl
+use Getopt::Long;
+
+GetOptions("silent!"=> \$silent);
 
 my $mtpt = shift || usage();
 my $mount_count = shift || usage();
 my $i = shift || usage();
 my $files = 5;
-my $mcreate = 1; # should we use mcreate or open?
+my $mcreate = 0; # should we use mcreate or open?
 
 sub usage () {
     print "Usage: $0 <mount point prefix> <mount count> <iterations>\n";
@@ -21,16 +24,16 @@ sub do_open($) {
     if ($mcreate) {
         my $tmp = `./mcreate $path`;
         if ($tmp) {
-            print  "Creating [" . $$."]...\n";
+            print  "Creating $path [" . $$."]...\n" if !$silent;
             $tmp =~ /.*error: (.*)\n/;
-            print  "Create done [$$] $path: $!\n";
+            print  "Create done [$$] $path: $!\n" if !$silent;
         } else {
-            print  "Create done [$$] $path: Success\n";
+            print  "Create done [$$] $path: Success\n"if !$silent;
         }
     } else {
-        print  "Opening [" . $$."]...\n";
+        print  "Opening $path [" . $$."]...\n"if !$silent;
         open(FH, ">$path") || die "open($PATH): $!";
-        print  "Open done [$$] $path: Success\n";
+        print  "Open done [$$] $path: Success\n"if !$silent;
         close(FH) || die;
     }
 }
@@ -48,11 +51,11 @@ while ($i--) {
     }
     $d = int(rand() * $files);
     $path = "$mtpt$which/$d";
-    print  "Unlink start [" . $$."]...\n";
+    print  "Unlink $path start [" . $$."]...\n"if !$silent;
     if (unlink($path)) {
-        print  "Unlink done [$$] $path: Success\n";
+        print  "Unlink done [$$] $path: Success\n"if !$silent;
     } else {
-        print  "Unlink done [$$] $path: $!\n";
+        print  "Unlink done [$$] $path: $!\n"if !$silent;
     }
 }
 print "Done.\n";
index 4290b62..1a92327 100644 (file)
@@ -6,10 +6,10 @@ my $debug_line = 0;
 while ($line = <>) {
     $debug_line++;
     my ($file, $func, $lno, $name, $size, $addr, $type);
-    if ($line =~ m/^.*\((.*):(.*)\,l\. (\d+) .* k(.*) '(.*)': (\d+) at (.*) \(tot .*$/) {
+    if ($line =~ m/^.*\((.*):(\d+):(.*)\(\) \d+\+\d+\): [vk](.*) '(.*)': (\d+) at (.*) \(tot .*$/) {
         $file = $1;
-        $func = $2;
-        $lno = $3;
+        $lno = $2;
+        $func = $3;
         $type = $4;
         $name = $5;
         $size = $6;
index 1054064..a47c088 100644 (file)
@@ -7,19 +7,43 @@ LMC=${LMC:-../utils/lmc}
 SERVER=localhost
 CLIENT=localhost
 
+# FIXME: make LMC not require MDS for obdecho LOV
+MDSDEV=$TMP/mds1
+MDSSIZE=10000
+
+STRIPE_BYTES=65536
+STRIPES_PER_OBJ=2      # 0 means stripe over all OSTs
+
+LOV=0
+while [ "$1" ]; do
+        case $1 in
+        --lov) LOV="1" ;;
+       *) OPTS="$OPTS $1" ;;
+        esac
+        shift
+done
+
 # create nodes
 $LMC -o $config --node $SERVER --net $SERVER tcp || exit 1
-$LMC -m $config --node $SERVER --obdtype=obdecho --ost || exit 2
 
-# force the osc to be configured (this is normally done when it is mounted)
-$LMC -m $config --node $CLIENT --osc OSC_$SERVER || exit 3
-$LMC -m $config --node $CLIENT --echo_client OSC_${SERVER} || exit 3
+if (($LOV)); then
+    $LMC -m $config --node $SERVER --mds mds1 $MDSDEV $MDSSIZE || exit 10
+    $LMC -m $config --lov lov1 mds1 $STRIPE_BYTES $STRIPES_PER_OBJ 0 || exit 11
+    $LMC -m $config --node $SERVER --lov lov1 --obdtype=obdecho --ost || exit 12
+    $LMC -m $config --node $SERVER --lov lov1 --obdtype=obdecho --ost || exit 13
+
+    $LMC -m $config --node $CLIENT --echo_client lov1 || exit 3
+else
+    $LMC -m $config --node $SERVER --obdtype=obdecho --ost || exit 2
+    # force the osc to be configured (this is normally done when it is mounted)
+    $LMC -m $config --node $CLIENT --osc OSC_$SERVER || exit 3
+    $LMC -m $config --node $CLIENT --echo_client OSC_${SERVER} || exit 3
+fi
 
-$LCONF --gdb $config || exit 4
+$LCONF --gdb $OPTS $config || exit 4
 
 cat <<EOF
 
 run getattr tests as:
-../utils/lctl --device \$ECHO_$SERVER test_getattr 1000000
+../utils/lctl --device '\$ECHO_$SERVER' test_getattr 1000000
 EOF
-
index f7c2430..eb4618b 100755 (executable)
@@ -12,4 +12,3 @@ if [ ! -f $config -o $mkconfig -nt $config ]; then
 fi
 
 ${LCONF} --reformat --gdb $config || exit 2
-
diff --git a/lustre/tests/llmount2-hack.sh b/lustre/tests/llmount2-hack.sh
new file mode 100644 (file)
index 0000000..d17805a
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+# suggested boilerplate for test script
+
+LCONF=${LCONF:-../utils/lconf}
+NAME=${NAME:-local2}
+
+config=$NAME.xml
+mkconfig=./$NAME.sh
+
+if [ ! -f $config -o $mkconfig -nt $config ]; then
+   sh $mkconfig $config || exit 1
+fi
+
+${LCONF} -v --reformat --gdb $config || exit 2
+
+../utils/lctl <<EOF
+newdev
+attach osc OSC2_localhost OSC2_localhost_UUID
+setup OBD_localhost_UUID NET_localhost_tcp_UUID
+newdev
+attach mdc MDC2_mds1 MDC2_uuid
+setup mds1_UUID NET_localhost_tcp_UUID
+quit
+EOF
+
+mount -t lustre_lite -o osc=OSC2_localhost_UUID,mdc=MDC2_uuid none /mnt/lustre2
index 98f3510..82f2a17 100755 (executable)
@@ -2,13 +2,25 @@
 
 LCONF=${LCONF:-../utils/lconf}
 NAME=${NAME:-local}
+TMP=${TMP:-/tmp}
 
 config=$NAME.xml
 mkconfig=./$NAME.sh
 
-if [ ! -f $config -o $mkconfig -nt $config ]; then
+if [ ! -f $config ]; then
    sh $mkconfig $config || exit 1
 fi
 
-${LCONF} --cleanup --dump /tmp/debug $config
-
+sync; sleep 2; sync
+${LCONF} --cleanup --dump $TMP/debug $config
+LEAK=`dmesg | grep -v " 0 bytes" | grep leaked`
+if [ "$LEAK" ]; then
+       echo "$LEAK" 1>&2
+       mv $TMP/debug $TMP/debug.`date +%s`
+       #exit -1
+fi
+BUSY=`dmesg | grep -i destruct`
+if [ "$BUSY" ]; then
+       echo "$BUSY" 1>&2
+       #exit -2
+fi
diff --git a/lustre/tests/llmountcleanup2-hack.sh b/lustre/tests/llmountcleanup2-hack.sh
new file mode 100644 (file)
index 0000000..b2996cf
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+umount /mnt/lustre2
+umount /mnt/lustre1
+../utils/lctl <<EOF
+name2dev OSC2_localhost
+cleanup
+detach
+name2dev MDC2_mds1
+cleanup
+detach
+quit
+EOF
+
+LCONF=${LCONF:-../utils/lconf}
+NAME=${NAME:-local}
+
+config=$NAME.xml
+mkconfig=./$NAME.sh
+
+if [ ! -f $config -o $mkconfig -nt $config ]; then
+   sh $mkconfig $config || exit 1
+fi
+
+${LCONF} --cleanup --dump /tmp/debug $config
index 6cdfe7c..76f8374 100755 (executable)
@@ -2,7 +2,7 @@
 
 config=${1:-lov.xml}
 
-LMC=../utils/lmc
+LMC=${LMC:-../utils/lmc}
 TMP=${TMP:-/tmp}
 
 MDSDEV=$TMP/mds1
index 7b2a02a..f66335e 100755 (executable)
@@ -1,25 +1,34 @@
 #!/bin/bash
 
-config=${1:-mcr2.xml}
+BASE=`hostname | sed "s/[i0-9]*$//"`
+[ $BASE = "mcr" ] && OSTBASE=${OSTBASE:-ba} || OSTBASE=${OSTBASE:-ba-ost-}
+
+config=${1:-$BASE.xml}
+
+BATCH=/tmp/lmc-batch.$$
+save_cmd() {
+    echo "$@" >> $BATCH
+}
 
 LMC="save_cmd"
 LMC_REAL="../../lustre/utils/lmc -m $config"
 
 # TCP/IP servers
-SERVER_START=1
-SERVER_CNT=62
-GW_START=1
-GW_CNT=31
-MDS=mcr23
-UUIDLIST=${UUIDLIST:-/home/bluearc/UUID.0920}
+SERVER_START=0
+SERVER_CNT=64
+GW_START=0
+GW_CNT=32
+MDS=${BASE}23
+UUIDLIST=${UUIDLIST:-/usr/local/admin/ba-ost/UUID.txt}
+
+echo "MDS: $MDS"
 
-# THis is needed for to create route for elan network
-CLIENT_LO=mcr40
-CLIENT_HI=mcr96
+# This is needed for to create route for elan network
+CLIENT_LO=36
+CLIENT_HI=155
 
 TCPBUF=1048576
  
-
 h2elan () {
     echo $1 | sed 's/[^0-9]*//g'
 }
@@ -27,22 +36,17 @@ h2elan () {
 h2ip () {
     echo "${1}"
 }
-# map gwNN to mcrNN
-# assumes /etc/hosts looks like this:
-# 192.168.40.11        emcr10  mcr10-eth0      emcr-r2-s1      gw10
-gw2mcr() {
-    awk '$5 = /'$1'$/ {print substr($2,2)}'  /etc/hosts
-}
-BATCH=/tmp/lmc-batch.$$
-save_cmd() {
-    echo "$@" >> $BATCH
+
+# map gateway NN to host NN (assumes mcr[22-25] are not gateways)
+gw2node() {
+       [ $1 -gt 21 ] && echo $(($1 + 4)) || echo $1
 }
 
 [ -f $config ] && rm $config
 
 ${LMC} --node $MDS --net `h2elan $MDS` elan || exit 1
 ${LMC} --node $MDS --mds mds1 /tmp/mds1 100000 || exit 1
-${LMC} --lov lov1 mds1 65536 0 0
+${LMC} --lov lov1 mds1 65536 1 0
 
 # Client node
 #${LMC} --node client --tcpbuf $TCPBUF --net '*' tcp || exit 1
@@ -52,15 +56,15 @@ ${LMC} --node client --mtpt /mnt/lustre mds1 lov1
 # this is crude, but effective
 let server_per_gw=($SERVER_CNT / $GW_CNT )
 let tot_server=$server_per_gw*$GW_CNT
-echo "Allocating $server_per_gw per gateway."
-echo "For a total of $tot_server Blue Arcs"
+echo "Allocating $server_per_gw OSTs per gateway."
+echo "For a total of $tot_server Blue Arc OSTs"
 
 let gw=$GW_START
 let server=$SERVER_START
 while (( $gw < $GW_CNT + GW_START ));
 do 
-   echo "gw$gw"
-   gwnode=`gw2mcr gw$gw`
+   gwnode=$BASE`gw2node $gw`
+   echo "Router: $gwnode"
    ${LMC} --router --node $gwnode --tcpbuf $TCPBUF --net `h2ip $gwnode`  tcp || exit 1
    ${LMC} --node $gwnode --net `h2elan $gwnode` elan|| exit 1
    ${LMC} --node $gwnode --route elan `h2elan $gwnode` `h2elan $CLIENT_LO` `h2elan $CLIENT_HI` || exit 2
@@ -68,8 +72,8 @@ do
    let  i=0
    while (( $i < $server_per_gw ));
    do
-      echo "server: $server"
-      OST=ba$server
+      OST=${OSTBASE}$server
+      echo "server: $OST"
       OBD_UUID=`awk "/$OST / { print \\$3 }" $UUIDLIST`
       [ "$OBD_UUID" ] && OBD_UUID="--obduuid=$OBD_UUID" || echo "$OST: no UUID"
       # server node
index 4b500e5..cbf6a65 100755 (executable)
@@ -1,12 +1,10 @@
 #!/bin/sh
 
-[ -e /proc/sys/portals/debug ] && echo 0 > /proc/sys/portals/debug 
-if [ ! -e client.txt ]; then
-       if [ -e /usr/lib/dbench/client.txt ]; then
-               cp /usr/lib/dbench/client.txt /mnt/lustre/client.txt
-       elif [ -e /usr/lib/dbench/client_plain.txt ]; then
-               cp /usr/lib/dbench/client_plain.txt /mnt/lustre/client.txt
-       fi
-fi
+#[ -e /proc/sys/portals/debug ] && echo 0 > /proc/sys/portals/debug 
+TGT=/mnt/lustre/client.txt
+SRC=/usr/lib/dbench/client.txt
+[ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
+SRC=/usr/lib/dbench/client_plain.txt
+[ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
 cd /mnt/lustre
 dbench -c client.txt $@
index aa2a2c2..cf198ad 100755 (executable)
@@ -1,16 +1,17 @@
 #!/bin/sh
-SIZE=5g
-COUNT=0
+[ -z "$SIZE" ] && SIZE=5g
+[ -z "$LOOPS" ] && LOOPS=9999
 [ -z "$VERIFY" ] && VERIFY="-+d"
 [ -z "$ODIR" ] && ODIR="-I"
 [ -z "$REC" ] && REC=64
-FILE=/mnt/lustre/test.$$
+[ -z "$FILE" ] && FILE=/mnt/lustre/test.$$
 [ $1 ] && SIZE=$1
+COUNT=0
 rm -f endiozone
 echo 0 > /proc/sys/portals/debug
 while date; do
        echo "Test #$COUNT"
        iozone $VERIFY $ODIR -r $REC -i 0 -i 1 -f $FILE -s $SIZE 2>&1 || exit $?
        COUNT=`expr $COUNT + 1`
-       [ -f endiozone ] && rm endiozone && exit 0
+       [ -f endiozone -o $COUNT -ge $LOOPS ] && rm -f endiozone && exit 0
 done | tee /tmp/iozone.log
index e863f95..702bd1f 100644 (file)
@@ -4,7 +4,7 @@ export PATH=/sbin:/usr/sbin:$PATH
 SRCDIR="`dirname $0`/"
 . $SRCDIR/common.sh
 
-COUNT=${COUNT:-10000000}
+COUNT=${COUNT:-1000000}
 COUNT_10=`expr $COUNT / 10`
 COUNT_100=`expr $COUNT / 100`
 
@@ -36,7 +36,6 @@ runthreads() {
                DO=test_brw
                RW=w
                ;;
-
        test_brw_read)
                DO=test_brw
                RW=r
index 337d807..288f847 100644 (file)
@@ -4,7 +4,7 @@ export PATH=/sbin:/usr/sbin:$PATH
 SRCDIR="`dirname $0`/"
 . $SRCDIR/common.sh
 
-COUNT=${COUNT:-10000000}
+COUNT=${COUNT:-1000000}
 COUNT_10=`expr $COUNT / 10`
 COUNT_100=`expr $COUNT / 100`
 COUNT_1000=`expr $COUNT / 1000`
@@ -28,6 +28,7 @@ runthreads() {
        case $DO in
        test_getattr)
                RW=
+               ;;
 
        test_brw_write)
                DO=test_brw
@@ -64,13 +65,9 @@ for CMD in test_getattr test_brw_write test_brw_read; do
                PG=1
                PGV=16
                ;;
-
        test_brw_read)
                PG=1
-               case $OSTNODE in
-               ba*) PGV= ;; # disabled until the BA OST code is updated
-               *) PGV=16 ;;
-               esac
+               PGV=16
                ;;
        esac
 
@@ -87,8 +84,6 @@ for CMD in test_getattr test_brw_write test_brw_read; do
        runthreads 1 $CMD $COUNT -30 $PG
        [ "$PGV" ] && runthreads 1 $CMD $COUNT_10 -30 $PGV
 
-       runthreads 1 $CMD 100 -10 $PG
-
        runthreads 2 $CMD $COUNT_100 -30 $PG
        [ "$PGV" ] && runthreads 2 $CMD $COUNT_1000 -30 $PGV
 
index b028f06..e068a01 100755 (executable)
@@ -13,13 +13,6 @@ fail() {
 
 export PATH=/sbin:/usr/sbin:$SRCDIR:$PATH
 
-cleanup() {
-       sync
-       $LCONF --cleanup --dump /tmp/debug $OPTS
-       sync
-       #trap 0
-}
-
 ERROR=
 SRC=/etc
 [ "$COUNT" ] || COUNT=1000
@@ -28,25 +21,21 @@ SRC=/etc
 
 [ "$MCREATE" ] || MCREATE=$SRCDIR/../tests/mcreate
 
+while [ "$1" ]; do
+       case $1 in
+       *.xml) export NAME=`echo $1 | sed "s/.xml//"` ;;
+       esac
+       shift
+done
+
 OSCMT="`mount | awk '/ lustre_lite / { print $3 }' | tail -1`"
 if [ -z "$OSCMT" ]; then
-       [ -z "$*" ] && fail "usage: $0 [--reformat] <conf>.xml" 1
-       $LCONF --gdb $@ || exit 1
-       #trap cleanup 0
+       sh llmount.sh
        OSCMT="`mount | awk '/ lustre_lite / { print $3 }' | tail -1`"
        [ -z "$OSCMT" ] && fail "no lustre filesystem mounted" 1
        I_MOUNTED="yes"
 fi
 
-while [ "$1" ]; do
-       case $1 in
-       -v|--verbose) V=-v;;
-       --reformat) : ;;
-       *) OPTS="$OPTS $1" ;;
-       esac
-       shift
-done
-
 OSCTMP=`echo $OSCMT | tr "/" "."`
 USED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -1`
 USED=`expr $USED + 16` # Some space for the status file
@@ -57,8 +46,8 @@ touch $OSCMT || fail "can't touch $OSCMT" 2
 HOSTS=$OSCMT/hosts.$$
 
 # this will cause the following cp to trigger bug #620096
-#echo "create an empty file $HOSTS"
-#$MCREATE $HOSTS
+echo "create an empty file $HOSTS"
+$MCREATE $HOSTS
 
 echo "copying /etc/hosts to $HOSTS"
 cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS" 3
@@ -78,8 +67,9 @@ DST=$OSCMT/runtest.$$
 echo "creating $DST"
 mkdir $DST || fail "can't mkdir $DST" 10
 
-# ok, that hopefully worked, so let's do a little more
-FILES=`find $SRC -type f | grep -v mtab | head -$COUNT`
+# ok, that hopefully worked, so let's do a little more, with files that
+# haven't changed in the last day (hopefully they don't change during test)
+FILES=`find $SRC -type f -mtime +1 -ctime +1 | head -$COUNT`
 echo "copying files from $SRC to $DST$SRC"
 tar cf - $FILES | tar xvf - -C $DST || fail "copying $SRC" 11
 
@@ -91,8 +81,8 @@ done
 
 [ "$ERROR" ] && fail "old and new files are different" $ERROR
 
-cleanup || exit 19
-$LCONF $OPTS || exit 20
+sh llmountcleanup.sh || exit 19
+sh llrmount.sh || exit 20
 
 echo "comparing previously copied files"
 for f in $FILES; do
@@ -102,8 +92,8 @@ done
 
 [ "$ERROR" ] && fail "old and new files are different on second diff" $ERROR
 
-cleanup || exit 29
-$LCONF $OPTS || exit 30
+sh llmountcleanup.sh || exit 19
+sh llrmount.sh || exit 20
 
 echo "renaming $HOSTS.ren to $HOSTS"
 mv $HOSTS.ren $HOSTS || fail "can't rename $HOSTS.ren to $HOSTS" 32
@@ -120,4 +110,6 @@ if [ $NOWUSED -gt $USED ]; then
        echo "This is normal on BA OSTs, because of subdirectories." 1>&2
 fi
 
-[ "$I_MOUNTED" = "yes" ] && cleanup $OPTS || exit 29
+if [ "$I_MOUNTED" = "yes" ]; then
+       sh llmountcleanup.sh || exit 29
+fi
index 531a009..da72bda 100644 (file)
@@ -4,68 +4,80 @@ export NAME=$NAME
 clean() {
         echo -n "cleanup..."
         sh llmountcleanup.sh > /dev/null
-        dmesg | grep leaked | grep -v " 0 bytes" 
-        dmesg | grep -i destruct
 }
 CLEAN=clean
 start() {
         echo -n "mounting..."
         sh llrmount.sh > /dev/null
         echo -n "mounted"
-        echo 0 > /proc/sys/portals/debug
 }
 START=start
 
-echo '== touch .../f ; rm .../f ========== test 0'
+echo '== touch .../f ; rm .../f ======================== test 0'
 touch /mnt/lustre/f
 rm /mnt/lustre/f
 $CLEAN
 $START
 
-echo '== mkdir .../d1; mkdir .../d1/d2 == test 1'
+echo '== mkdir .../d1; mkdir .../d1/d2 ================= test 1'
 mkdir /mnt/lustre/d1
 mkdir /mnt/lustre/d1/d2
 $CLEAN
 $START
 
-echo '== mkdir .../d1; touch .../d1/f === test 2'
+echo '== rmdir .../d1/d2; rmdir .../d1 ================= test 1b'
+rmdir /mnt/lustre/d1/d2
+rmdir /mnt/lustre/d1
+$CLEAN
+$START
+
+echo '== mkdir .../d2; touch .../d2/f ================== test 2'
 mkdir /mnt/lustre/d2
 touch /mnt/lustre/d2/f
 $CLEAN
 $START
 
-echo '== mkdir .../d3 =================== test 3'
+echo '== rm -r .../d2; touch .../d2/f ================== test 2b'
+rm -r /mnt/lustre/d2
+$CLEAN
+$START
+
+echo '== mkdir .../d3 ================================== test 3'
 mkdir /mnt/lustre/d3
 $CLEAN
 $START
-echo '== touch .../d3/f ================= test 3b'
+echo '== touch .../d3/f ================================ test 3b'
 touch /mnt/lustre/d3/f
 $CLEAN
 $START
+echo '== rm -r .../d3 ================================== test 3c'
+rm -r /mnt/lustre/d3
+$CLEAN
+$START
 
-echo '== mkdir .../d4 =================== test 4'
+echo '== mkdir .../d4 ================================== test 4'
 mkdir /mnt/lustre/d4
 $CLEAN
 $START
-echo '== mkdir .../d4/d2 ================ test 4b'
+echo '== mkdir .../d4/d2 =============================== test 4b'
 mkdir /mnt/lustre/d4/d2
 $CLEAN
 $START
 
-echo '== mkdir .../d5; mkdir .../d5/d2; chmod .../d5/d2 == test 5'
+echo '== mkdir .../d5; mkdir .../d5/d2; chmod .../d5/d2 = test 5'
 mkdir /mnt/lustre/d5
 mkdir /mnt/lustre/d5/d2
 chmod 0666 /mnt/lustre/d5/d2
 $CLEAN
 $START
 
-echo '== touch .../f6; chmod .../f6 ===== test 6'
+echo '== touch .../f6; chmod .../f6 ==================== test 6'
 touch /mnt/lustre/f6
 chmod 0666 /mnt/lustre/f6
 $CLEAN
 $START
 
-echo '== mkdir .../d7; mcreate .../d7/f; chmod .../d7/f == test 7'
+echo '== mkdir .../d7; mcreate .../d7/f; chmod .../d7/f = test 7'
 mkdir /mnt/lustre/d7
 ./mcreate /mnt/lustre/d7/f
 chmod 0666 /mnt/lustre/d7/f
@@ -88,14 +100,14 @@ $CLEAN
 $START
 
 
-echo '=============================== test 10'
+echo '== mkdir .../d10; mkdir .../d10/d2; touch .../d10/d2/f = test 10'
 mkdir /mnt/lustre/d10
 mkdir /mnt/lustre/d10/d2
 touch /mnt/lustre/d10/d2/f
 $CLEAN
 $START
 
-echo '=============================== test 11'
+echo '=================================================== test 11'
 mkdir /mnt/lustre/d11
 mkdir /mnt/lustre/d11/d2
 chmod 0666 /mnt/lustre/d11/d2
@@ -103,7 +115,7 @@ chmod 0555 /mnt/lustre/d11/d2
 $CLEAN
 $START
 
-echo '=============================== test 12'
+echo '=================================================== test 12'
 mkdir /mnt/lustre/d12
 touch /mnt/lustre/d12/f
 chmod 0666 /mnt/lustre/d12/f
@@ -111,7 +123,7 @@ chmod 0555 /mnt/lustre/d12/f
 $CLEAN
 $START
 
-echo '=============================== test 13'
+echo '=================================================== test 13'
 mkdir /mnt/lustre/d13
 cp /etc/passwd /mnt/lustre/d13/f
 >  /mnt/lustre/d13/f
@@ -119,7 +131,7 @@ $CLEAN
 $START
 
 
-echo '=============================== test 14'
+echo '=================================================== test 14'
 mkdir /mnt/lustre/d14
 touch /mnt/lustre/d14/f
 rm /mnt/lustre/d14/f
@@ -127,21 +139,21 @@ $CLEAN
 $START
 
 
-echo '=============================== test 15'
+echo '=================================================== test 15'
 mkdir /mnt/lustre/d15
 touch /mnt/lustre/d15/f
 mv /mnt/lustre/d15/f /mnt/lustre/d15/f2
 $CLEAN
 $START
 
-echo '=============================== test 16'
+echo '=================================================== test 16'
 mkdir /mnt/lustre/d16
 touch /mnt/lustre/d16/f
 rm -rf /mnt/lustre/d16/f
 $CLEAN
 $START
 
-echo '====== symlinks: create, remove symlinks (dangling and real) =====' test 17
+echo '== symlinks: create, remove (dangling and real) === test 17'
 mkdir /mnt/lustre/d17
 touch /mnt/lustre/d17/f
 ln -s /mnt/lustre/d17/f /mnt/lustre/d17/l-exist
@@ -152,20 +164,20 @@ rm -f /mnt/lustre/l-exist
 $CLEAN
 $START
 
-echo '==== touch /mnt/lustre/f ; ls /mnt/lustre ==== test 18'
+echo '== touch /mnt/lustre/f ; ls /mnt/lustre ========== test 18'
 touch /mnt/lustre/f
 ls /mnt/lustre
 $CLEAN
 $START
 
-echo '==== touch /mnt/lustre/f ; ls -l /mnt/lustre ==== test 19'
+echo '== touch /mnt/lustre/f ; ls -l /mnt/lustre ======= test 19'
 touch /mnt/lustre/f
 ls -l /mnt/lustre
 rm /mnt/lustre/f
 $CLEAN
 $START
 
-echo '==== touch /mnt/lustre/f ; ls -l /mnt/lustre ==== test 20'
+echo '== touch /mnt/lustre/f ; ls -l /mnt/lustre ======= test 20'
 touch /mnt/lustre/f
 rm /mnt/lustre/f
 echo "1 done"
@@ -178,5 +190,29 @@ echo "3 done"
 $CLEAN
 $START
 
-echo '=========== finished ==========='
+echo '== write to dangling link ======================= test 21'
+mkdir /mnt/lustre/d21
+ln -s dangle /mnt/lustre/d21/link
+echo foo >> /mnt/lustre/d21/link
+cat /mnt/lustre/d21/dangle
+$CLEAN
+$START
+
+# echo '== unpack tar archive as nonroot user =========== test 22'
+echo '== please fix test 22'
+# mkdir /mnt/lustre/d22
+# chown 4711 /mnt/lustre/d22
+# (./setuid 4711 ; tar cf - /etc/hosts /etc/sysconfig/network | tar xfC - /mnt/lustre/d22 ; ./setuid 0)
+# ls -lR /mnt/lustre/d22/etc
+# $CLEAN
+# $START
+
+echo '== O_CREAT|O_EXCL in subdir ===================== test 23'
+mkdir /mnt/lustre/d23
+./toexcl /mnt/lustre/d23/f23
+./toexcl /mnt/lustre/d23/f23
+$CLEAN
+$START
+
+echo '======================= finished ======================='
 exit
diff --git a/lustre/tests/setuid.c b/lustre/tests/setuid.c
new file mode 100644 (file)
index 0000000..04dba5e
--- /dev/null
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <errno.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/fsuid.h>
+
+int main(int argc, char ** argv)
+{
+        int rc, fsuid;
+
+        if (argc < 2) { 
+                printf("Usage %s fsuid\n", argv[0]);
+                return 1;
+        }
+
+        fsuid = strtoul(argv[2], NULL, 0);
+        rc = setfsuid(fsuid);
+        if (rc) { 
+                printf("mknod(%s) error: %s\n", argv[1], strerror(errno));
+        }
+        return rc;
+} 
index d74ba89..08ba66e 100755 (executable)
@@ -73,7 +73,7 @@ config.xml          Lustre configuration in xml format.
                             40 - mds, ost
                             50 - mdc, osc
                             60 - lov, lovconfig
-                            70 - mountpoint
+                            70 - mountpoint, echo_client
 """
     TODO = """
 --ldap server       LDAP server with lustre config database
@@ -426,6 +426,11 @@ class LCTLInterface:
         rc, out = self.runcmd('device_list')
         return out
 
+    # get lustre version
+    def lustre_version(self):
+        rc, out = self.runcmd('version')
+        return out
+
 # ============================================================
 # Various system-level functions
 # (ideally moved to their own module)
@@ -1137,22 +1142,31 @@ class OSC(Module):
 class ECHO_CLIENT(Module):
     def __init__(self,dom_node):
         Module.__init__(self, 'ECHO_CLIENT', dom_node)
-        self.obd_uuid = get_first_ref(dom_node, 'osc')
-        debug("HERE",self.obd_uuid)
         self.add_module('lustre/obdecho', 'obdecho')
+        self.lov_uuid = get_first_ref(dom_node, 'osc')
+        l = lookup(self.dom_node.parentNode, self.lov_uuid)
+        self.osc = VOSC(l)
 
     def prepare(self):
         if is_prepared(self.uuid):
             return
-        self.info(self.obd_uuid)
+        self.osc.prepare() # XXX This is so cheating. -p
+        self.info(self.lov_uuid)
             
         lctl.newdev(attach="echo_client %s %s" % (self.name, self.uuid),
-                    setup = self.obd_uuid)
+                    setup = self.lov_uuid)
 
     def cleanup(self):
         if not is_prepared(self.uuid):
             return
-        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()
 
 
 class Mountpoint(Module):
@@ -1494,12 +1508,12 @@ def startService(dom_node, module_flag):
         n = MDS(dom_node)
     elif type == 'osc':
         n = VOSC(dom_node)
-    elif type == 'echo_client':
-        n = ECHO_CLIENT(dom_node)
     elif type == 'mdc':
         n = MDC(dom_node)
     elif type == 'mountpoint':
         n = Mountpoint(dom_node)
+    elif type == 'echo_client':
+        n = ECHO_CLIENT(dom_node)
     else:
         panic ("unknown service type:", type)
 
index 1ffe694..2e6324c 100644 (file)
@@ -4,7 +4,7 @@
  *  Copyright (C) 2002 Cluster File Systems, Inc.
  *   Author: Peter J. Braam <braam@clusterfs.com>
  *   Author: Phil Schwan <phil@clusterfs.com>
- *   Author: Robert Read <rread@clusterfs.com> 
+ *   Author: Robert Read <rread@clusterfs.com>
  *
  *   This file is part of Lustre, http://www.lustre.org.
  *
@@ -62,7 +62,7 @@ command_t cmdlist[] = {
         /* Network configuration commands */
         {"==== network config ====", jt_noop, 0, "network config"},
         {"network", jt_ptl_network, 0, "commands that follow apply to net\n"
-         "usage: network <tcp/elan/myrinet>"},       
+         "usage: network <tcp/elan/myrinet>"},
         {"connect", jt_ptl_connect, 0, "connect to a remote nid\n"
          "usage: connect [[<hostname> <port>] | <elan id>]"},
         {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid\n"
@@ -92,9 +92,9 @@ command_t cmdlist[] = {
          "if size is omited the current size is reported.\n"
          "usage: send_mem [size]"},
         {"nagle", jt_ptl_nagle, 0, "enable/disable nagle, omiting the "
-         "argument will cause the current nagle setting to be reported.\n" 
-         "usage: nagle [on/off]"},       
-                
+         "argument will cause the current nagle setting to be reported.\n"
+         "usage: nagle [on/off]"},
+
         /* Device selection commands */
         {"=== device selection ===", jt_noop, 0, "device selection"},
         {"newdev", jt_obd_newdev, 0, "create a new device\n"
@@ -111,7 +111,10 @@ command_t cmdlist[] = {
          "usage: device <devno>"},
         {"device_list", jt_obd_list, 0, "show all devices\n"
          "usage: device_list"},
-         
+        {"lustre_build_version", jt_get_version, 0,
+         "print the build version of lustre\n"
+         "usage: lustre_build_version"},
+
         /* Device configuration commands */
         {"==== device config =====", jt_noop, 0, "device config"},
         {"attach", jt_obd_attach, 0,
@@ -222,7 +225,7 @@ int main(int argc, char **argv)
                 exit(2);
         if (dbg_initialize(argc, argv) < 0)
                 exit(3);
-        
+
         if (argc > 1) {
                 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
         } else {
index 3061b26..5548f9b 100644 (file)
@@ -63,7 +63,7 @@ sub extractpid
 {
     $_ = shift;
 #    print "$_\n";
-    /l. [0-9]* (.*)\):/;
+    /\(\) ([0-9]*)\+[0-9]*\):/;
     return $1;
 }
 
index 83a1aa8..3d7c7bf 100755 (executable)
@@ -253,11 +253,6 @@ class GenConfig:
         osc.appendChild(self.ref("obd", obd_uuid))
         return osc
 
-    def echo_client(self, name, uuid, osc_uuid):
-        ec = self.newService("echo_client", name, uuid)
-        ec.appendChild(self.ref("osc", osc_uuid))
-        return ec
-
     def ost(self, name, uuid, obd_uuid, net_uuid):
         ost = self.newService("ost", name, uuid)
         ost.appendChild(self.ref("network", net_uuid))
@@ -299,6 +294,11 @@ class GenConfig:
         self.addElement(mtpt, "path", path)
         return mtpt
 
+    def echo_client(self, name, uuid, osc_uuid):
+        ec = self.newService("echo_client", name, uuid)
+        ec.appendChild(self.ref("osc", osc_uuid))
+        return ec
+
 ############################################################
 # Utilities to query a DOM tree
 # Using this functions we can treat use config information
@@ -602,7 +602,7 @@ def add_echo_client(gen, lustre, options, args):
     """ add an echo client to the profile for this node. """
     if len(args) < 1:
         usage()
-    osc_name = args[0]
+    lov_name = args[0]
     if options.has_key('node'):
         node_name = options['node']
     else:
@@ -612,8 +612,12 @@ def add_echo_client(gen, lustre, options, args):
     echoname = new_name('ECHO_'+ node_name)
     echo_uuid = new_uuid(echoname)
     node_add_profile(gen, node, 'echo_client', echo_uuid)
-    osc_uuid = name2uuid(lustre, osc_name) # either 'osc' or 'lov'
-    echo = gen.echo_client(echoname, echo_uuid, osc_uuid)
+
+    lov_uuid = name2uuid(lustre, lov_name, tag='lov', fatal=0)
+    if not lov_uuid:
+        lov_uuid = name2uuid(lustre, lov_name, tag='osc', fatal=1)
+
+    echo = gen.echo_client(echoname, echo_uuid, lov_uuid)
     lustre.appendChild(echo)
 
 
index 7dda8ab..a6ccd29 100644 (file)
@@ -41,6 +41,8 @@
 #include <linux/lustre_idl.h>
 #include <linux/lustre_dlm.h>
 #include <linux/obd_lov.h>      /* for IOC_LOV_SET_OSC_ACTIVE */
+#include <linux/obd.h>          /* for struct lov_stripe_md */
+#include <linux/lustre_build_version.h>
 
 #include <unistd.h>
 #include <sys/un.h>
@@ -79,6 +81,8 @@ char *buf = rawbuf;
 int max = sizeof(rawbuf);
 
 static int thread;
+static struct lov_stripe_md saved_lsm;
+static char lsm_valid = 0;
 
 static int getfd(char *func);
 static char *cmdname(char *func);
@@ -96,6 +100,24 @@ do {                                                                    \
         }                                                               \
 } while (0)
 
+#define IOC_PACK(func, data)                                            \
+do {                                                                    \
+        if (obd_ioctl_pack(&data, &buf, max)) {                         \
+                fprintf(stderr, "error: %s: invalid ioctl\n",           \
+                        cmdname(func));                                 \
+                return -2;                                              \
+        }                                                               \
+} while (0)
+
+#define IOC_UNPACK(func, data)                                          \
+do {                                                                    \
+        if (obd_ioctl_unpack(&data, buf, max)) {                        \
+                fprintf(stderr, "error: %s: invalid reply\n",           \
+                        cmdname(func));                                 \
+                return -2;                                              \
+        }                                                               \
+} while (0)
+
 char *obdo_print(struct obdo *obd)
 {
         char buf[1024];
@@ -129,18 +151,14 @@ static int do_name2dev(char *func, char *name)
         data.ioc_inllen1 = strlen(name) + 1;
         data.ioc_inlbuf1 = name;
 
-        if (obd_ioctl_pack(&data, &buf, max)) {
-                fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(func));
-                return -2;
-        }
+        IOC_PACK(func, data);
         rc = ioctl(fd, OBD_IOC_NAME2DEV, buf);
         if (rc < 0) {
                 fprintf(stderr, "error: %s: %s - %s\n", cmdname(func),
                         name, strerror(rc = errno));
                 return rc;
         }
-
-        memcpy((char *)(&data), buf, sizeof(data));
+        IOC_UNPACK(func, data);
 
         return data.ioc_dev + N2D_OFF;
 }
@@ -395,11 +413,7 @@ static int do_device(char *func, int dev)
         if (getfd(func))
                 return -1;
 
-        if (obd_ioctl_pack(&data, &buf, max)) {
-                fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(func));
-                return -2;
-        }
-
+        IOC_PACK(func, data);
         return ioctl(fd, OBD_IOC_DEVICE, buf);
 }
 
@@ -590,11 +604,7 @@ int jt_obd_detach(int argc, char **argv)
                 data.ioc_inlbuf1 = &force;
         }
 
-        if (obd_ioctl_pack(&data, &buf, max)) {
-                fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(argv[0]));
-                return -2;
-        }
-
+        IOC_PACK(argv[0], data);
         rc = ioctl(fd, OBD_IOC_DETACH, buf);
         if (rc < 0)
                 fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]),
@@ -645,6 +655,37 @@ int jt_obd_newdev(int argc, char **argv)
         return rc;
 }
 
+int jt_get_version(int argc, char **argv)
+{
+        int rc;
+        char buf[8192];
+        struct obd_ioctl_data *data = (struct obd_ioctl_data *)buf;
+
+        if (getfd(argv[0]))
+                return -1;
+
+        memset(buf, 0, sizeof(buf));
+        data->ioc_version = OBD_IOCTL_VERSION;
+        data->ioc_addr = conn_addr;
+        data->ioc_cookie = conn_addr;
+        data->ioc_len = sizeof(buf);
+        data->ioc_inllen1 = sizeof(buf) - size_round(sizeof(*data));
+
+        if (argc != 1)
+                return CMD_HELP;
+
+        rc = ioctl(fd, OBD_GET_VERSION, data);
+        if (rc < 0)
+                fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]),
+                        strerror(rc = errno));
+        else {
+                printf("Lustre version: %s\n", data->ioc_bulk);
+        }
+        
+        printf("lctl version: %s\n",BUILD_VERSION);
+        return rc;
+}
+
 int jt_obd_list(int argc, char **argv)
 {
         int rc;
@@ -697,11 +738,7 @@ int jt_obd_attach(int argc, char **argv)
                 data.ioc_inlbuf3 = argv[3];
         }
 
-        if (obd_ioctl_pack(&data, &buf, max)) {
-                fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(argv[0]));
-                return -2;
-        }
-
+        IOC_PACK(argv[0], data);
         rc = ioctl(fd, OBD_IOC_ATTACH, buf);
         if (rc < 0)
                 fprintf(stderr, "error: %s: %x %s\n", cmdname(argv[0]),
@@ -762,10 +799,7 @@ int jt_obd_setup(int argc, char **argv)
                 data.ioc_inlbuf2 = argv[2];
         }
 
-        if (obd_ioctl_pack(&data, &buf, max)) {
-                fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(argv[0]));
-                return -2;
-        }
+        IOC_PACK(argv[0], data);
         rc = ioctl(fd, OBD_IOC_SETUP, buf);
         if (rc < 0)
                 fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]),
@@ -774,15 +808,15 @@ int jt_obd_setup(int argc, char **argv)
         return rc;
 }
 
-
+/* The ioctl API has been extended to provide the LOV stripe metadata to the
+ * caller when applicable.  This utility, however, only saves the LSM for the
+ * latest CREATE. */
 int jt_obd_create(int argc, char **argv)
 {
         struct obd_ioctl_data data;
         struct timeval next_time;
         __u64 count = 1, next_count;
-        int verbose = 1;
-        int mode = 0100644;
-        int rc = 0, i;
+        int verbose = 1, mode = 0100644, rc = 0, i;
         char *end;
 
         IOCINIT(data);
@@ -825,7 +859,14 @@ int jt_obd_create(int argc, char **argv)
                 data.ioc_obdo1.o_valid = OBD_MD_FLTYPE | OBD_MD_FLMODE |
                                 OBD_MD_FLID | OBD_MD_FLUID | OBD_MD_FLGID;;
 
-                rc = ioctl(fd, OBD_IOC_CREATE, &data);
+                data.ioc_inllen1 = sizeof(saved_lsm);
+                data.ioc_inlbuf1 = (char *)&saved_lsm;
+
+                IOC_PACK(argv[0], data);
+                rc = ioctl(fd, OBD_IOC_CREATE, buf);
+                IOC_UNPACK(argv[0], data);
+                fprintf(stderr, "lsm->lsm_o_id: "LPX64"\n",
+                        saved_lsm.lsm_object_id);
                 SHMEM_BUMP();
                 if (rc < 0) {
                         fprintf(stderr, "error: %s: #%d - %s\n",
@@ -839,6 +880,8 @@ int jt_obd_create(int argc, char **argv)
                         break;
                 }
 
+                lsm_valid = 1;
+
                 if (be_verbose(verbose, &next_time, i, &next_count, count))
                         printf("%s: #%d is object id "LPX64"\n",
                                cmdname(argv[0]), i, data.ioc_obdo1.o_id);
@@ -870,7 +913,13 @@ int jt_obd_setattr(int argc, char **argv)
         }
         data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE;
 
-        rc = ioctl(fd, OBD_IOC_SETATTR, &data);
+        if (lsm_valid == 1) {
+                data.ioc_inllen1 = sizeof(saved_lsm);
+                data.ioc_inlbuf1 = (char *)&saved_lsm;
+        }
+
+        IOC_PACK(argv[0], data);
+        rc = ioctl(fd, OBD_IOC_SETATTR, buf);
         if (rc < 0)
                 fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]),
                         strerror(rc = errno));
@@ -921,18 +970,25 @@ int jt_obd_destroy(int argc, char **argv)
         for (i = 1, next_count = verbose; i <= count; i++, id++) {
                 data.ioc_obdo1.o_id = id;
                 data.ioc_obdo1.o_mode = S_IFREG | 0644;
+                data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLMODE;
 
-                rc = ioctl(fd, OBD_IOC_DESTROY, &data);
+                data.ioc_inllen1 = sizeof(saved_lsm);
+                data.ioc_inlbuf1 = (char *)&saved_lsm;
+
+                IOC_PACK(argv[0], data);
+                rc = ioctl(fd, OBD_IOC_DESTROY, buf);
+                IOC_UNPACK(argv[0], data);
                 SHMEM_BUMP();
                 if (rc < 0) {
                         fprintf(stderr, "error: %s: objid "LPX64": %s\n",
                                 cmdname(argv[0]), id, strerror(rc = errno));
                         break;
                 }
+                lsm_valid = 0;
 
                 if (be_verbose(verbose, &next_time, i, &next_count, count))
-                        printf("%s: #%d is object id 0x%Lx\n", cmdname(argv[0]),
-                               i, (long long)data.ioc_obdo1.o_id);
+                        printf("%s: #%d is object id "LPX64"\n",
+                               cmdname(argv[0]), i, id);
         }
 
         return rc;
@@ -959,7 +1015,14 @@ int jt_obd_getattr(int argc, char **argv)
         data.ioc_obdo1.o_valid = 0xffffffff;
         printf("%s: object id "LPX64"\n", cmdname(argv[0]),data.ioc_obdo1.o_id);
 
-        rc = ioctl(fd, OBD_IOC_GETATTR, &data);
+        if (lsm_valid == 1) {
+                data.ioc_inllen1 = sizeof(saved_lsm);
+                data.ioc_inlbuf1 = (char *)&saved_lsm;
+        }
+
+        IOC_PACK(argv[0], data);
+        rc = ioctl(fd, OBD_IOC_GETATTR, buf);
+        IOC_UNPACK(argv[0], data);
         if (rc) {
                 fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]),
                         strerror(rc = errno));
@@ -1131,6 +1194,11 @@ int jt_obd_test_brw(int argc, char **argv)
         data.ioc_count = len;
         data.ioc_offset = thr_offset * len * count;
 
+        if (lsm_valid == 1) {
+                data.ioc_inllen1 = sizeof(saved_lsm);
+                data.ioc_inlbuf1 = (char *)&saved_lsm;
+        }
+
         gettimeofday(&start, NULL);
         next_time.tv_sec = start.tv_sec - verbose;
         next_time.tv_usec = start.tv_usec;
@@ -1140,7 +1208,9 @@ int jt_obd_test_brw(int argc, char **argv)
                        cmdname(argv[0]), write ? "writing" : "reading", count,
                        pages, objid, data.ioc_offset, ctime(&start.tv_sec));
 
-        rc = ioctl(fd, OBD_IOC_OPEN, &data);
+        IOC_PACK(argv[0], data);
+        rc = ioctl(fd, OBD_IOC_OPEN, buf);
+        IOC_UNPACK(argv[0], data);
         if (rc) {
                 fprintf(stderr, "error: brw_open: %s\n", strerror(rc = errno));
                 return rc;
@@ -1148,7 +1218,7 @@ int jt_obd_test_brw(int argc, char **argv)
 
         rw = write ? OBD_IOC_BRW_WRITE : OBD_IOC_BRW_READ;
         for (i = 1, next_count = verbose; i <= count; i++) {
-                rc = ioctl(fd, rw, &data);
+                rc = ioctl(fd, rw, buf);
                 SHMEM_BUMP();
                 if (rc) {
                         fprintf(stderr, "error: %s: #%d - %s on %s\n",
@@ -1177,7 +1247,7 @@ int jt_obd_test_brw(int argc, char **argv)
                                i, pages, diff, (double)i * pages / diff,
                                ctime(&end.tv_sec));
         }
-        rw = ioctl(fd, OBD_IOC_CLOSE, &data);
+        rw = ioctl(fd, OBD_IOC_CLOSE, buf);
         if (rw) {
                 fprintf(stderr, "error: brw_close: %s\n", strerror(rw = errno));
                 if (!rc)
@@ -1288,7 +1358,6 @@ int jt_obd_lov_setconfig(int argc, char **argv)
                 rc = -EINVAL;
                 goto out;
         }
-
         rc = ioctl(fd, OBD_IOC_LOV_SET_CONFIG, buf);
         if (rc)
                 fprintf(stderr, "error: %s: ioctl error: %s\n",
@@ -1340,7 +1409,6 @@ repeat:
                 rc = -EINVAL;
                 goto out;
         }
-
         rc = ioctl(fd, OBD_IOC_LOV_GET_CONFIG, buf);
         if (rc == -ENOSPC) {
                 free(uuidarray);
@@ -1430,13 +1498,8 @@ int jt_obd_ldlm_regress_start(int argc, char **argv)
                 data.ioc_inllen1 = strlen(argstring) + 1;
         }
 
-        if (obd_ioctl_pack(&data, &buf, max)) {
-                fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(argv[0]));
-                return -2;
-        }
-
+        IOC_PACK(argv[0], data);
         rc = ioctl(fd, IOC_LDLM_REGRESS_START, buf);
-
         if (rc)
                 fprintf(stderr, "error: %s: test failed: %s\n",
                         cmdname(argv[0]), strerror(rc = errno));
@@ -1476,13 +1539,8 @@ int jt_obd_lov_set_osc_active(int argc, char **argv)
         /* reuse offset for 'active' */
         data.ioc_offset = atoi(argv[2]);
 
-        if (obd_ioctl_pack(&data, &buf, max)) {
-                fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(argv[0]));
-                return -2;
-        }
-
+        IOC_PACK(argv[0], data);
         rc = ioctl(fd, IOC_LOV_SET_OSC_ACTIVE, buf);
-
         if (rc)
                 fprintf(stderr, "error: %s: failed: %s\n",
                         cmdname(argv[0]), strerror(rc = errno));
@@ -1507,11 +1565,7 @@ int jt_obd_newconn(int argc, char **argv)
                 data.ioc_inlbuf2 = argv[2];
         }
 
-        if (obd_ioctl_pack(&data, &buf, max)) {
-                fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(argv[0]));
-                return -2;
-        }
-
+        IOC_PACK(argv[0], data);
         rc = ioctl(fd, OBD_IOC_RECOVD_NEWCONN, buf);
         if (rc < 0)
                 fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]),
@@ -1532,11 +1586,7 @@ int jt_obd_failconn(int argc, char **argv)
         data.ioc_inllen1 = strlen(argv[1]) + 1;
         data.ioc_inlbuf1 = argv[1];
 
-        if (obd_ioctl_pack(&data, &buf, max)) {
-                fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(argv[0]));
-                return -2;
-        }
-
+        IOC_PACK(argv[0], data);
         rc = ioctl(fd, OBD_IOC_RECOVD_FAILCONN, buf);
         if (rc < 0)
                 fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]),
index 4e934f9..860b908 100644 (file)
@@ -64,7 +64,7 @@ command_t cmdlist[] = {
          "disconnect - break connection to device"},
 
         /* Session operations */
-        {"create", jt_obd_create, 0, "create [count [mode [verbose]]]"},
+        {"create", jt_obd_create, 0, "create <count> [mode [verbose]]"},
         {"destroy", jt_obd_destroy, 0, "destroy <id> [count [verbose]]"},
         {"getattr", jt_obd_getattr, 0, "getattr <id>"},
         {"setattr", jt_obd_setattr, 0, "setattr <id> <mode>"},
index 98aaffa..01ece92 100644 (file)
@@ -58,5 +58,6 @@ int jt_obd_dump_ldlm(int argc, char **argv);
 int jt_obd_lov_set_osc_active(int argc, char **argv);
 int jt_obd_newconn(int argc, char **argv);
 int jt_obd_failconn(int argc, char **argv);
+int jt_get_version(int argc, char **argv);
 
 #endif