Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/tmpfs Two fixes from rmind
details: https://anonhg.NetBSD.org/src/rev/2f58c4701534
branches: trunk
changeset: 347360:2f58c4701534
user: skrll <skrll%NetBSD.org@localhost>
date: Mon Aug 22 23:07:36 2016 +0000
description:
Two fixes from rmind
- tmpfs_node_get: restore (decrement) the node count on the error path.
- tmpfs_bytes_max: save the value of uvmexp.freetarg (since it is
unlocked/racy).
diffstat:
sys/fs/tmpfs/tmpfs_mem.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diffs (42 lines):
diff -r ef03e6f01eab -r 2f58c4701534 sys/fs/tmpfs/tmpfs_mem.c
--- a/sys/fs/tmpfs/tmpfs_mem.c Mon Aug 22 22:53:02 2016 +0000
+++ b/sys/fs/tmpfs/tmpfs_mem.c Mon Aug 22 23:07:36 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_mem.c,v 1.8 2014/06/13 11:57:48 pooka Exp $ */
+/* $NetBSD: tmpfs_mem.c,v 1.9 2016/08/22 23:07:36 skrll Exp $ */
/*
* Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.8 2014/06/13 11:57:48 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.9 2016/08/22 23:07:36 skrll Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -116,12 +116,13 @@
tmpfs_bytes_max(struct tmpfs_mount *mp)
{
psize_t freepages = tmpfs_mem_info(false);
+ int freetarg = uvmexp.freetarg; // XXX unlocked
uint64_t avail_mem;
- if (freepages < uvmexp.freetarg) {
+ if (freepages < freetarg) {
freepages = 0;
} else {
- freepages -= uvmexp.freetarg;
+ freepages -= freetarg;
}
avail_mem = round_page(mp->tm_bytes_used) + (freepages << PAGE_SHIFT);
return MIN(mp->tm_mem_limit, avail_mem);
@@ -187,6 +188,7 @@
return NULL;
}
if (!tmpfs_mem_incr(mp, sizeof(struct tmpfs_node))) {
+ atomic_dec_uint(&mp->tm_nodes_cnt);
return NULL;
}
return pool_get(&tmpfs_node_pool, PR_WAITOK);
Home |
Main Index |
Thread Index |
Old Index