17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*d67944fbSScott Rotondo * Common Development and Distribution License (the "License"). 6*d67944fbSScott Rotondo * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*d67944fbSScott Rotondo * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_FS_TMPNODE_H 277c478bd9Sstevel@tonic-gate #define _SYS_FS_TMPNODE_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/t_lock.h> 307c478bd9Sstevel@tonic-gate #include <vm/seg.h> 317c478bd9Sstevel@tonic-gate #include <vm/seg_vn.h> 32*d67944fbSScott Rotondo #include <sys/vfs_opreg.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * tmpnode is the file system dependent node for tmpfs. 407c478bd9Sstevel@tonic-gate * 417c478bd9Sstevel@tonic-gate * tn_rwlock protects access of the directory list at tn_dir 427c478bd9Sstevel@tonic-gate * as well as syncronizing read and writes to the tmpnode 437c478bd9Sstevel@tonic-gate * 447c478bd9Sstevel@tonic-gate * tn_contents protects growing, shrinking, reading and writing 457c478bd9Sstevel@tonic-gate * the file along with tn_rwlock (see below). 467c478bd9Sstevel@tonic-gate * 477c478bd9Sstevel@tonic-gate * tn_tlock protects updates to tn_mode and tn_nlink 487c478bd9Sstevel@tonic-gate * 497c478bd9Sstevel@tonic-gate * tm_contents in the tmount filesystem data structure protects 507c478bd9Sstevel@tonic-gate * tn_forw and tn_back which are used to maintain a linked 517c478bd9Sstevel@tonic-gate * list of all tmpfs files associated with that file system 527c478bd9Sstevel@tonic-gate * 537c478bd9Sstevel@tonic-gate * The anon array represents the secondary store for tmpfs. 547c478bd9Sstevel@tonic-gate * To grow or shrink the file or fill in holes requires 557c478bd9Sstevel@tonic-gate * manipulation of the anon array. These operations are protected 567c478bd9Sstevel@tonic-gate * by a combination of tn_rwlock and tn_contents. Growing or shrinking 577c478bd9Sstevel@tonic-gate * the array requires the write lock on tn_rwlock and tn_contents. 587c478bd9Sstevel@tonic-gate * Filling in a slot in the array requires the write lock on tn_contents. 597c478bd9Sstevel@tonic-gate * Reading the array requires the read lock on tn_contents. 607c478bd9Sstevel@tonic-gate * 617c478bd9Sstevel@tonic-gate * The ordering of the locking is: 627c478bd9Sstevel@tonic-gate * tn_rwlock -> tn_contents -> page locks on pages in file 637c478bd9Sstevel@tonic-gate * 647c478bd9Sstevel@tonic-gate * tn_tlock doesn't require any tmpnode locks 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate struct tmpnode { 687c478bd9Sstevel@tonic-gate struct tmpnode *tn_back; /* linked list of tmpnodes */ 697c478bd9Sstevel@tonic-gate struct tmpnode *tn_forw; /* linked list of tmpnodes */ 707c478bd9Sstevel@tonic-gate union { 717c478bd9Sstevel@tonic-gate struct { 727c478bd9Sstevel@tonic-gate struct tdirent *un_dirlist; /* dirent list */ 737c478bd9Sstevel@tonic-gate uint_t un_dirents; /* number of dirents */ 747c478bd9Sstevel@tonic-gate } un_dirstruct; 757c478bd9Sstevel@tonic-gate char *un_symlink; /* pointer to symlink */ 767c478bd9Sstevel@tonic-gate struct { 777c478bd9Sstevel@tonic-gate struct anon_hdr *un_anon; /* anon backing for file */ 787c478bd9Sstevel@tonic-gate pgcnt_t un_size; /* size repres. by array */ 797c478bd9Sstevel@tonic-gate } un_anonstruct; 807c478bd9Sstevel@tonic-gate } un_tmpnode; 817c478bd9Sstevel@tonic-gate struct vnode *tn_vnode; /* vnode for this tmpnode */ 827c478bd9Sstevel@tonic-gate int tn_gen; /* pseudo gen number for tfid */ 837c478bd9Sstevel@tonic-gate struct vattr tn_attr; /* attributes */ 847c478bd9Sstevel@tonic-gate krwlock_t tn_contents; /* vm side -serialize mods */ 857c478bd9Sstevel@tonic-gate krwlock_t tn_rwlock; /* rw,trunc size - serialize */ 867c478bd9Sstevel@tonic-gate /* mods and directory updates */ 877c478bd9Sstevel@tonic-gate kmutex_t tn_tlock; /* time, flag, and nlink lock */ 887c478bd9Sstevel@tonic-gate struct tmpnode *tn_xattrdp; /* ext. attribute directory */ 897c478bd9Sstevel@tonic-gate uint_t tn_flags; /* tmpnode specific flags */ 907c478bd9Sstevel@tonic-gate }; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate #define tn_dir un_tmpnode.un_dirstruct.un_dirlist 937c478bd9Sstevel@tonic-gate #define tn_dirents un_tmpnode.un_dirstruct.un_dirents 947c478bd9Sstevel@tonic-gate #define tn_symlink un_tmpnode.un_symlink 957c478bd9Sstevel@tonic-gate #define tn_anon un_tmpnode.un_anonstruct.un_anon 967c478bd9Sstevel@tonic-gate #define tn_asize un_tmpnode.un_anonstruct.un_size 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate /* 997c478bd9Sstevel@tonic-gate * tmnode flag values. 1007c478bd9Sstevel@tonic-gate */ 1017c478bd9Sstevel@tonic-gate #define ISXATTR 0x1 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* 1047c478bd9Sstevel@tonic-gate * Attributes 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate #define tn_mask tn_attr.va_mask 1077c478bd9Sstevel@tonic-gate #define tn_type tn_attr.va_type 1087c478bd9Sstevel@tonic-gate #define tn_mode tn_attr.va_mode 1097c478bd9Sstevel@tonic-gate #define tn_uid tn_attr.va_uid 1107c478bd9Sstevel@tonic-gate #define tn_gid tn_attr.va_gid 1117c478bd9Sstevel@tonic-gate #define tn_fsid tn_attr.va_fsid 1127c478bd9Sstevel@tonic-gate #define tn_nodeid tn_attr.va_nodeid 1137c478bd9Sstevel@tonic-gate #define tn_nlink tn_attr.va_nlink 1147c478bd9Sstevel@tonic-gate #define tn_size tn_attr.va_size 1157c478bd9Sstevel@tonic-gate #define tn_atime tn_attr.va_atime 1167c478bd9Sstevel@tonic-gate #define tn_mtime tn_attr.va_mtime 1177c478bd9Sstevel@tonic-gate #define tn_ctime tn_attr.va_ctime 1187c478bd9Sstevel@tonic-gate #define tn_rdev tn_attr.va_rdev 1197c478bd9Sstevel@tonic-gate #define tn_blksize tn_attr.va_blksize 1207c478bd9Sstevel@tonic-gate #define tn_nblocks tn_attr.va_nblocks 1217c478bd9Sstevel@tonic-gate #define tn_seq tn_attr.va_seq 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate /* 1247c478bd9Sstevel@tonic-gate * tmpfs directories are made up of a linked list of tdirent structures 1257c478bd9Sstevel@tonic-gate * hanging off directory tmpnodes. File names are not fixed length, 1267c478bd9Sstevel@tonic-gate * but are null terminated. 1277c478bd9Sstevel@tonic-gate */ 1287c478bd9Sstevel@tonic-gate struct tdirent { 1297c478bd9Sstevel@tonic-gate struct tmpnode *td_tmpnode; /* tnode for this file */ 1307c478bd9Sstevel@tonic-gate struct tdirent *td_next; /* next directory entry */ 1317c478bd9Sstevel@tonic-gate struct tdirent *td_prev; /* prev directory entry */ 1327c478bd9Sstevel@tonic-gate uint_t td_offset; /* "offset" of dir entry */ 1337c478bd9Sstevel@tonic-gate uint_t td_hash; /* a hash of td_name */ 1347c478bd9Sstevel@tonic-gate struct tdirent *td_link; /* linked via the hash table */ 1357c478bd9Sstevel@tonic-gate struct tmpnode *td_parent; /* parent, dir we are in */ 1367c478bd9Sstevel@tonic-gate char *td_name; /* must be null terminated */ 1377c478bd9Sstevel@tonic-gate /* max length is MAXNAMELEN */ 1387c478bd9Sstevel@tonic-gate }; 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate /* 1417c478bd9Sstevel@tonic-gate * tfid overlays the fid structure (for VFS_VGET) 1427c478bd9Sstevel@tonic-gate */ 1437c478bd9Sstevel@tonic-gate struct tfid { 1447c478bd9Sstevel@tonic-gate uint16_t tfid_len; 1457c478bd9Sstevel@tonic-gate ino32_t tfid_ino; 1467c478bd9Sstevel@tonic-gate int32_t tfid_gen; 1477c478bd9Sstevel@tonic-gate }; 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate #define ESAME (-1) /* trying to rename linked files (special) */ 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate extern struct vnodeops *tmp_vnodeops; 1527c478bd9Sstevel@tonic-gate extern const struct fs_operation_def tmp_vnodeops_template[]; 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1557c478bd9Sstevel@tonic-gate } 1567c478bd9Sstevel@tonic-gate #endif 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate #endif /* _SYS_FS_TMPNODE_H */ 159