Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 133234
b: refs/heads/master
c: 2db2aac
h: refs/heads/master
v: v3
  • Loading branch information
Abhijith Das authored and Steven Whitehouse committed Mar 24, 2009
1 parent cd3507f commit c5f41b8
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6f04c1c7fe9566d777fb7961391690866839e722
refs/heads/master: 2db2aac255c38e75ad17c0b24feb589ccfccc0ae
82 changes: 82 additions & 0 deletions trunk/fs/gfs2/locking.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,86 @@ struct lmh_wrapper {
const struct lm_lockops *lw_ops;
};

struct nolock_lockspace {
unsigned int nl_lvb_size;
};

/**
* nolock_get_lock - get a lm_lock_t given a descripton of the lock
* @lockspace: the lockspace the lock lives in
* @name: the name of the lock
* @lockp: return the lm_lock_t here
*
* Returns: 0 on success, -EXXX on failure
*/

static int nolock_get_lock(void *lockspace, struct lm_lockname *name,
void **lockp)
{
*lockp = lockspace;
return 0;
}

/**
* nolock_put_lock - get rid of a lock structure
* @lock: the lock to throw away
*
*/

static void nolock_put_lock(void *lock)
{
}

/**
* nolock_hold_lvb - hold on to a lock value block
* @lock: the lock the LVB is associated with
* @lvbp: return the lm_lvb_t here
*
* Returns: 0 on success, -EXXX on failure
*/

static int nolock_hold_lvb(void *lock, char **lvbp)
{
struct nolock_lockspace *nl = lock;
int error = 0;

*lvbp = kzalloc(nl->nl_lvb_size, GFP_KERNEL);
if (!*lvbp)
error = -ENOMEM;

return error;
}

/**
* nolock_unhold_lvb - release a LVB
* @lock: the lock the LVB is associated with
* @lvb: the lock value block
*
*/

static void nolock_unhold_lvb(void *lock, char *lvb)
{
kfree(lvb);
}

static int nolock_mount(char *table_name, char *host_data,
lm_callback_t cb, void *cb_data,
unsigned int min_lvb_size, int flags,
struct lm_lockstruct *lockstruct,
struct kobject *fskobj);
static void nolock_unmount(void *lockspace);

/* List of registered low-level locking protocols. A file system selects one
of them by name at mount time, e.g. lock_nolock, lock_dlm. */

static const struct lm_lockops nolock_ops = {
.lm_proto_name = "lock_nolock",
.lm_mount = nolock_mount,
.lm_unmount = nolock_unmount,
.lm_get_lock = nolock_get_lock,
.lm_put_lock = nolock_put_lock,
.lm_hold_lvb = nolock_hold_lvb,
.lm_unhold_lvb = nolock_unhold_lvb,
};

static struct lmh_wrapper nolock_proto = {
Expand All @@ -53,6 +121,7 @@ static int nolock_mount(char *table_name, char *host_data,
{
char *c;
unsigned int jid;
struct nolock_lockspace *nl;

c = strstr(host_data, "jid=");
if (!c)
Expand All @@ -62,15 +131,28 @@ static int nolock_mount(char *table_name, char *host_data,
sscanf(c, "%u", &jid);
}

nl = kzalloc(sizeof(struct nolock_lockspace), GFP_KERNEL);
if (!nl)
return -ENOMEM;

nl->nl_lvb_size = min_lvb_size;

lockstruct->ls_jid = jid;
lockstruct->ls_first = 1;
lockstruct->ls_lvb_size = min_lvb_size;
lockstruct->ls_lockspace = nl;
lockstruct->ls_ops = &nolock_ops;
lockstruct->ls_flags = LM_LSFLAG_LOCAL;

return 0;
}

static void nolock_unmount(void *lockspace)
{
struct nolock_lockspace *nl = lockspace;
kfree(nl);
}

/**
* gfs2_register_lockproto - Register a low-level locking protocol
* @proto: the protocol definition
Expand Down

0 comments on commit c5f41b8

Please sign in to comment.