Whamcloud - gitweb
393cd99205f31b0c0bcf85f4e8950a3aee7a0fbc
[fs/lustre-release.git] / lustre / mdd / mdd_trans.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
30  * Use is subject to license terms.
31  *
32  * Copyright (c) 2011 Whamcloud, Inc.
33  *
34  */
35 /*
36  * This file is part of Lustre, http://www.lustre.org/
37  * Lustre is a trademark of Sun Microsystems, Inc.
38  *
39  * lustre/mdd/mdd_trans.c
40  *
41  * Lustre Metadata Server (mdd) routines
42  *
43  * Author: Wang Di <wangdi@clusterfs.com>
44  */
45
46 #ifndef EXPORT_SYMTAB
47 # define EXPORT_SYMTAB
48 #endif
49 #define DEBUG_SUBSYSTEM S_MDS
50
51 #include <linux/module.h>
52 #ifdef HAVE_EXT4_LDISKFS
53 #include <ldiskfs/ldiskfs_jbd2.h>
54 #else
55 #include <linux/jbd.h>
56 #endif
57 #include <obd.h>
58 #include <obd_class.h>
59 #include <lustre_ver.h>
60 #include <obd_support.h>
61 #include <lprocfs_status.h>
62
63 #ifdef HAVE_EXT4_LDISKFS
64 #include <ldiskfs/ldiskfs.h>
65 #else
66 #include <linux/ldiskfs_fs.h>
67 #endif
68 #include <lustre_mds.h>
69 #include <lustre/lustre_idl.h>
70
71 #include "mdd_internal.h"
72
73 int mdd_txn_stop_cb(const struct lu_env *env, struct thandle *txn,
74                     void *cookie)
75 {
76         struct mdd_device *mdd = cookie;
77         struct obd_device *obd = mdd2obd_dev(mdd);
78
79         LASSERT(obd);
80         return mds_lov_write_objids(obd);
81 }
82
83 struct thandle *mdd_trans_create(const struct lu_env *env,
84                                  struct mdd_device *mdd)
85 {
86         return mdd_child_ops(mdd)->dt_trans_create(env, mdd->mdd_child);
87 }
88
89 int mdd_trans_start(const struct lu_env *env, struct mdd_device *mdd,
90                     struct thandle *th)
91 {
92         return mdd_child_ops(mdd)->dt_trans_start(env, mdd->mdd_child, th);
93 }
94
95 void mdd_trans_stop(const struct lu_env *env, struct mdd_device *mdd,
96                     int result, struct thandle *handle)
97 {
98         handle->th_result = result;
99         mdd_child_ops(mdd)->dt_trans_stop(env, handle);
100 }