Update tmpfs link count handling for ino64.

Add a new TMPFS_LINK_MAX to use in place of LINK_MAX for link overflow
checks and pathconf() reporting.  Rather than storing a full 64-bit
link count, just use a plain int and use INT_MAX as TMPFS_LINK_MAX.

Discussed with:	bde
Reviewed by:	kib (part of a larger patch)
Sponsored by:	Chelsio Communications
This commit is contained in:
John Baldwin 2017-12-19 20:19:07 +00:00
parent c24008cc39
commit 35b1a3abd3
3 changed files with 9 additions and 6 deletions

View File

@ -188,8 +188,8 @@ struct tmpfs_node {
uid_t tn_uid; /* (v) */
gid_t tn_gid; /* (v) */
mode_t tn_mode; /* (v) */
int tn_links; /* (v) */
u_long tn_flags; /* (v) */
nlink_t tn_links; /* (v) */
struct timespec tn_atime; /* (vi) */
struct timespec tn_mtime; /* (vi) */
struct timespec tn_ctime; /* (vi) */
@ -297,6 +297,8 @@ LIST_HEAD(tmpfs_node_list, tmpfs_node);
#define tn_reg tn_spec.tn_reg
#define tn_fifo tn_spec.tn_fifo
#define TMPFS_LINK_MAX INT_MAX
#define TMPFS_NODE_LOCK(node) mtx_lock(&(node)->tn_interlock)
#define TMPFS_NODE_UNLOCK(node) mtx_unlock(&(node)->tn_interlock)
#define TMPFS_NODE_MTX(node) (&(node)->tn_interlock)

View File

@ -739,8 +739,8 @@ tmpfs_alloc_file(struct vnode *dvp, struct vnode **vpp, struct vattr *vap,
if (vap->va_type == VDIR) {
/* Ensure that we do not overflow the maximum number of links
* imposed by the system. */
MPASS(dnode->tn_links <= LINK_MAX);
if (dnode->tn_links == LINK_MAX) {
MPASS(dnode->tn_links <= TMPFS_LINK_MAX);
if (dnode->tn_links == TMPFS_LINK_MAX) {
return (EMLINK);
}

View File

@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/dirent.h>
#include <sys/fcntl.h>
#include <sys/limits.h>
#include <sys/lockf.h>
#include <sys/lock.h>
#include <sys/mount.h>
@ -618,8 +619,8 @@ tmpfs_link(struct vop_link_args *v)
/* Ensure that we do not overflow the maximum number of links imposed
* by the system. */
MPASS(node->tn_links <= LINK_MAX);
if (node->tn_links == LINK_MAX) {
MPASS(node->tn_links <= TMPFS_LINK_MAX);
if (node->tn_links == TMPFS_LINK_MAX) {
error = EMLINK;
goto out;
}
@ -1349,7 +1350,7 @@ tmpfs_pathconf(struct vop_pathconf_args *v)
switch (name) {
case _PC_LINK_MAX:
*retval = LINK_MAX;
*retval = TMPFS_LINK_MAX;
break;
case _PC_NAME_MAX: