svn commit: r312799 - stable/10/sys/fs/tmpfs
Konstantin Belousov
kib at FreeBSD.org
Thu Jan 26 10:35:06 UTC 2017
Author: kib
Date: Thu Jan 26 10:35:04 2017
New Revision: 312799
URL: https://svnweb.freebsd.org/changeset/base/312799
Log:
MFC r312124 (by mjg):
tmpfs: manage tm_pages_used with atomics.
Modified:
stable/10/sys/fs/tmpfs/tmpfs.h
stable/10/sys/fs/tmpfs/tmpfs_subr.c
stable/10/sys/fs/tmpfs/tmpfs_vfsops.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/fs/tmpfs/tmpfs.h
==============================================================================
--- stable/10/sys/fs/tmpfs/tmpfs.h Thu Jan 26 10:29:23 2017 (r312798)
+++ stable/10/sys/fs/tmpfs/tmpfs.h Thu Jan 26 10:35:04 2017 (r312799)
@@ -312,12 +312,12 @@ struct tmpfs_mount {
/* Maximum number of memory pages available for use by the file
* system, set during mount time. This variable must never be
* used directly as it may be bigger than the current amount of
- * free memory; in the extreme case, it will hold the SIZE_MAX
+ * free memory; in the extreme case, it will hold the ULONG_MAX
* value. */
- size_t tm_pages_max;
+ u_long tm_pages_max;
/* Number of pages in use by the file system. */
- size_t tm_pages_used;
+ u_long tm_pages_used;
/* Pointer to the node representing the root directory of this
* file system. */
Modified: stable/10/sys/fs/tmpfs/tmpfs_subr.c
==============================================================================
--- stable/10/sys/fs/tmpfs/tmpfs_subr.c Thu Jan 26 10:29:23 2017 (r312798)
+++ stable/10/sys/fs/tmpfs/tmpfs_subr.c Thu Jan 26 10:35:04 2017 (r312799)
@@ -129,7 +129,7 @@ tmpfs_pages_check_avail(struct tmpfs_mou
if (tmpfs_mem_avail() < req_pages)
return (0);
- if (tmp->tm_pages_max != SIZE_MAX &&
+ if (tmp->tm_pages_max != ULONG_MAX &&
tmp->tm_pages_max < req_pages + tmpfs_pages_used(tmp))
return (0);
@@ -327,9 +327,7 @@ tmpfs_free_node(struct tmpfs_mount *tmp,
case VREG:
uobj = node->tn_reg.tn_aobj;
if (uobj != NULL) {
- TMPFS_LOCK(tmp);
- tmp->tm_pages_used -= uobj->size;
- TMPFS_UNLOCK(tmp);
+ atomic_subtract_long(&tmp->tm_pages_used, uobj->size);
KASSERT((uobj->flags & OBJ_TMPFS) == 0,
("leaked OBJ_TMPFS node %p vm_obj %p", node, uobj));
vm_object_deallocate(uobj);
@@ -1413,9 +1411,7 @@ retry:
uobj->size = newpages;
VM_OBJECT_WUNLOCK(uobj);
- TMPFS_LOCK(tmp);
- tmp->tm_pages_used += (newpages - oldpages);
- TMPFS_UNLOCK(tmp);
+ atomic_add_long(&tmp->tm_pages_used, newpages - oldpages);
node->tn_size = newsize;
return (0);
Modified: stable/10/sys/fs/tmpfs/tmpfs_vfsops.c
==============================================================================
--- stable/10/sys/fs/tmpfs/tmpfs_vfsops.c Thu Jan 26 10:29:23 2017 (r312798)
+++ stable/10/sys/fs/tmpfs/tmpfs_vfsops.c Thu Jan 26 10:35:04 2017 (r312799)
@@ -395,7 +395,7 @@ tmpfs_statfs(struct mount *mp, struct st
sbp->f_bsize = PAGE_SIZE;
used = tmpfs_pages_used(tmp);
- if (tmp->tm_pages_max != SIZE_MAX)
+ if (tmp->tm_pages_max != ULONG_MAX)
sbp->f_blocks = tmp->tm_pages_max;
else
sbp->f_blocks = used + tmpfs_mem_avail();
More information about the svn-src-stable
mailing list