| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: vfs_wapbl.c,v 1.83 2016/10/02 16:44:02 jdolecek Exp $ */ | | 1 | /* $NetBSD: vfs_wapbl.c,v 1.84 2016/10/02 16:52:27 jdolecek Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Wasabi Systems, Inc. | | 8 | * by Wasabi Systems, Inc. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -26,27 +26,27 @@ | | | @@ -26,27 +26,27 @@ |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * This implements file system independent write ahead filesystem logging. | | 33 | * This implements file system independent write ahead filesystem logging. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #define WAPBL_INTERNAL | | 36 | #define WAPBL_INTERNAL |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.83 2016/10/02 16:44:02 jdolecek Exp $"); | | 39 | __KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.84 2016/10/02 16:52:27 jdolecek Exp $"); |
40 | | | 40 | |
41 | #include <sys/param.h> | | 41 | #include <sys/param.h> |
42 | #include <sys/bitops.h> | | 42 | #include <sys/bitops.h> |
43 | #include <sys/time.h> | | 43 | #include <sys/time.h> |
44 | #include <sys/wapbl.h> | | 44 | #include <sys/wapbl.h> |
45 | #include <sys/wapbl_replay.h> | | 45 | #include <sys/wapbl_replay.h> |
46 | | | 46 | |
47 | #ifdef _KERNEL | | 47 | #ifdef _KERNEL |
48 | | | 48 | |
49 | #include <sys/atomic.h> | | 49 | #include <sys/atomic.h> |
50 | #include <sys/conf.h> | | 50 | #include <sys/conf.h> |
51 | #include <sys/file.h> | | 51 | #include <sys/file.h> |
52 | #include <sys/kauth.h> | | 52 | #include <sys/kauth.h> |
| @@ -1936,36 +1936,39 @@ wapbl_register_deallocation(struct wapbl | | | @@ -1936,36 +1936,39 @@ wapbl_register_deallocation(struct wapbl |
1936 | | | 1936 | |
1937 | wapbl_jlock_assert(wl); | | 1937 | wapbl_jlock_assert(wl); |
1938 | | | 1938 | |
1939 | mutex_enter(&wl->wl_mtx); | | 1939 | mutex_enter(&wl->wl_mtx); |
1940 | /* XXX should eventually instead tie this into resource estimation */ | | 1940 | /* XXX should eventually instead tie this into resource estimation */ |
1941 | /* | | 1941 | /* |
1942 | * XXX this panic needs locking/mutex analysis and the | | 1942 | * XXX this panic needs locking/mutex analysis and the |
1943 | * ability to cope with the failure. | | 1943 | * ability to cope with the failure. |
1944 | */ | | 1944 | */ |
1945 | /* XXX this XXX doesn't have enough XXX */ | | 1945 | /* XXX this XXX doesn't have enough XXX */ |
1946 | if (__predict_false(wl->wl_dealloccnt >= wl->wl_dealloclim)) | | 1946 | if (__predict_false(wl->wl_dealloccnt >= wl->wl_dealloclim)) |
1947 | panic("wapbl_register_deallocation: out of resources"); | | 1947 | panic("wapbl_register_deallocation: out of resources"); |
1948 | | | 1948 | |
| | | 1949 | wl->wl_dealloccnt++; |
| | | 1950 | mutex_exit(&wl->wl_mtx); |
| | | 1951 | |
1949 | wd = pool_get(&wapbl_dealloc_pool, PR_WAITOK); | | 1952 | wd = pool_get(&wapbl_dealloc_pool, PR_WAITOK); |
1950 | wd->wd_blkno = blk; | | 1953 | wd->wd_blkno = blk; |
1951 | wd->wd_len = len; | | 1954 | wd->wd_len = len; |
1952 | | | 1955 | |
| | | 1956 | mutex_enter(&wl->wl_mtx); |
1953 | SIMPLEQ_INSERT_TAIL(&wl->wl_dealloclist, wd, wd_entries); | | 1957 | SIMPLEQ_INSERT_TAIL(&wl->wl_dealloclist, wd, wd_entries); |
1954 | wl->wl_dealloccnt++; | | 1958 | mutex_exit(&wl->wl_mtx); |
1955 | | | 1959 | |
1956 | WAPBL_PRINTF(WAPBL_PRINT_ALLOC, | | 1960 | WAPBL_PRINTF(WAPBL_PRINT_ALLOC, |
1957 | ("wapbl_register_deallocation: blk=%"PRId64" len=%d\n", blk, len)); | | 1961 | ("wapbl_register_deallocation: blk=%"PRId64" len=%d\n", blk, len)); |
1958 | mutex_exit(&wl->wl_mtx); | | | |
1959 | } | | 1962 | } |
1960 | | | 1963 | |
1961 | /****************************************************************/ | | 1964 | /****************************************************************/ |
1962 | | | 1965 | |
1963 | static void | | 1966 | static void |
1964 | wapbl_inodetrk_init(struct wapbl *wl, u_int size) | | 1967 | wapbl_inodetrk_init(struct wapbl *wl, u_int size) |
1965 | { | | 1968 | { |
1966 | | | 1969 | |
1967 | wl->wl_inohash = hashinit(size, HASH_LIST, true, &wl->wl_inohashmask); | | 1970 | wl->wl_inohash = hashinit(size, HASH_LIST, true, &wl->wl_inohashmask); |
1968 | if (atomic_inc_uint_nv(&wapbl_ino_pool_refcount) == 1) { | | 1971 | if (atomic_inc_uint_nv(&wapbl_ino_pool_refcount) == 1) { |
1969 | pool_init(&wapbl_ino_pool, sizeof(struct wapbl_ino), 0, 0, 0, | | 1972 | pool_init(&wapbl_ino_pool, sizeof(struct wapbl_ino), 0, 0, 0, |
1970 | "wapblinopl", &pool_allocator_nointr, IPL_NONE); | | 1973 | "wapblinopl", &pool_allocator_nointr, IPL_NONE); |
1971 | } | | 1974 | } |