-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Howells
committed
Apr 3, 2009
1 parent
ac8729b
commit 986f7f3
Showing
5 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 4c515dd47ab41be3f89e757d441661795470b376 | ||
refs/heads/master: 955d00917f0c094e0f2fb88df967e980ab66b8ca |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
fscache-y := \ | ||
cache.o \ | ||
cookie.o \ | ||
fsdef.o \ | ||
main.o | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* netfs cookie management | ||
* | ||
* Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved. | ||
* Written by David Howells (dhowells@redhat.com) | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version | ||
* 2 of the License, or (at your option) any later version. | ||
*/ | ||
|
||
#define FSCACHE_DEBUG_LEVEL COOKIE | ||
#include <linux/module.h> | ||
#include <linux/slab.h> | ||
#include "internal.h" | ||
|
||
struct kmem_cache *fscache_cookie_jar; | ||
|
||
/* | ||
* initialise an cookie jar slab element prior to any use | ||
*/ | ||
void fscache_cookie_init_once(void *_cookie) | ||
{ | ||
struct fscache_cookie *cookie = _cookie; | ||
|
||
memset(cookie, 0, sizeof(*cookie)); | ||
spin_lock_init(&cookie->lock); | ||
INIT_HLIST_HEAD(&cookie->backing_objects); | ||
} | ||
|
||
/* | ||
* destroy a cookie | ||
*/ | ||
void __fscache_cookie_put(struct fscache_cookie *cookie) | ||
{ | ||
struct fscache_cookie *parent; | ||
|
||
_enter("%p", cookie); | ||
|
||
for (;;) { | ||
_debug("FREE COOKIE %p", cookie); | ||
parent = cookie->parent; | ||
BUG_ON(!hlist_empty(&cookie->backing_objects)); | ||
kmem_cache_free(fscache_cookie_jar, cookie); | ||
|
||
if (!parent) | ||
break; | ||
|
||
cookie = parent; | ||
BUG_ON(atomic_read(&cookie->usage) <= 0); | ||
if (!atomic_dec_and_test(&cookie->usage)) | ||
break; | ||
} | ||
|
||
_leave(""); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters