1 /* -*- MODE: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 * Lustre Metadata Server (mdd) routines
7 * Copyright (C) 2006 Cluster File Systems, Inc.
8 * Author: Mike Pershin <tappro@clusterfs.com>
10 * This file is part of the Lustre file system, http://www.lustre.org
11 * Lustre is a trademark of Cluster File Systems, Inc.
13 * You may have signed or agreed to another license before downloading
14 * this software. If so, you are bound by the terms and conditions
15 * of that agreement, and the following does not apply to you. See the
16 * LICENSE file included with this distribution for more information.
18 * If you did not agree to a different license, then this copy of Lustre
19 * is open source software; you can redistribute it and/or modify it
20 * under the terms of version 2 of the GNU General Public License as
21 * published by the Free Software Foundation.
23 * In either case, Lustre is distributed in the hope that it will be
24 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
25 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * license text for more details.
29 # define EXPORT_SYMTAB
31 #define DEBUG_SUBSYSTEM S_MDS
33 #include <linux/module.h>
34 #include <lustre_ver.h>
35 #include "mdd_internal.h"
37 void mdd_write_lock(const struct lu_env *env, struct mdd_object *obj)
39 struct dt_object *next = mdd_object_child(obj);
41 next->do_ops->do_write_lock(env, next);
44 void mdd_read_lock(const struct lu_env *env, struct mdd_object *obj)
46 struct dt_object *next = mdd_object_child(obj);
47 next->do_ops->do_read_lock(env, next);
50 void mdd_write_unlock(const struct lu_env *env, struct mdd_object *obj)
52 struct dt_object *next = mdd_object_child(obj);
54 next->do_ops->do_write_unlock(env, next);
57 void mdd_read_unlock(const struct lu_env *env, struct mdd_object *obj)
59 struct dt_object *next = mdd_object_child(obj);
61 next->do_ops->do_read_unlock(env, next);
65 /* Methods for parallel directory locking */
67 void mdd_pdlock_init(struct mdd_object *obj)
69 dynlock_init(&obj->mod_pdlock);
73 unsigned long mdd_name2hash(const char *name)
75 return full_name_hash((unsigned char*)name, strlen(name));
78 struct dynlock_handle *mdd_pdo_write_lock(const struct lu_env *env,
79 struct mdd_object *obj,
82 unsigned long value = mdd_name2hash(name);
83 return dynlock_lock(&obj->mod_pdlock, value, DLT_WRITE, GFP_NOFS);
86 struct dynlock_handle *mdd_pdo_read_lock(const struct lu_env *env,
87 struct mdd_object *obj,
90 unsigned long value = mdd_name2hash(name);
91 return dynlock_lock(&obj->mod_pdlock, value, DLT_READ, GFP_NOFS);
94 void mdd_pdo_write_unlock(const struct lu_env *env, struct mdd_object *obj,
95 struct dynlock_handle *dlh)
97 return dynlock_unlock(&obj->mod_pdlock, dlh);
100 void mdd_pdo_read_unlock(const struct lu_env *env, struct mdd_object *obj,
101 struct dynlock_handle *dlh)
103 return dynlock_unlock(&obj->mod_pdlock, dlh);