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 552782930Sszhou * Common Development and Distribution License (the "License"). 652782930Sszhou * 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 /* 277c478bd9Sstevel@tonic-gate * Loopback mount info - one per mount 287c478bd9Sstevel@tonic-gate */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifndef _SYS_FS_LOFS_INFO_H 317c478bd9Sstevel@tonic-gate #define _SYS_FS_LOFS_INFO_H 327c478bd9Sstevel@tonic-gate 33*d67944fbSScott Rotondo #ifdef _KERNEL 34*d67944fbSScott Rotondo #include <sys/vfs_opreg.h> 35*d67944fbSScott Rotondo #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate struct lnode; 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate struct lobucket { 447c478bd9Sstevel@tonic-gate kmutex_t lh_lock; /* lock protecting bucket contents */ 457c478bd9Sstevel@tonic-gate struct lnode *lh_chain; /* vnode chain for this bucket */ 467c478bd9Sstevel@tonic-gate uint_t lh_count; /* Number of vnodes in chain */ 477c478bd9Sstevel@tonic-gate /* Pad up to 64-byte boundary to avoid false sharing */ 487c478bd9Sstevel@tonic-gate #ifdef _LP64 497c478bd9Sstevel@tonic-gate char _pad[44]; 507c478bd9Sstevel@tonic-gate #else 517c478bd9Sstevel@tonic-gate char _pad[48]; 527c478bd9Sstevel@tonic-gate #endif 537c478bd9Sstevel@tonic-gate }; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate struct lo_retired_ht { 567c478bd9Sstevel@tonic-gate struct lo_retired_ht *lrh_next; 577c478bd9Sstevel@tonic-gate struct lobucket *lrh_table; 587c478bd9Sstevel@tonic-gate uint_t lrh_size; 597c478bd9Sstevel@tonic-gate }; 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate struct loinfo { 627c478bd9Sstevel@tonic-gate struct vfs *li_realvfs; /* real vfs of mount */ 637c478bd9Sstevel@tonic-gate struct vfs *li_mountvfs; /* loopback vfs */ 647c478bd9Sstevel@tonic-gate struct vnode *li_rootvp; /* root vnode of this vfs */ 657c478bd9Sstevel@tonic-gate int li_mflag; /* mount flags to inherit */ 667c478bd9Sstevel@tonic-gate int li_dflag; /* mount flags to not inherit */ 677c478bd9Sstevel@tonic-gate uint_t li_refct; /* # outstanding vnodes */ 687c478bd9Sstevel@tonic-gate volatile uint_t li_htsize; /* # buckets in hashtable */ 697c478bd9Sstevel@tonic-gate struct lobucket *volatile li_hashtable; /* table of per-mount vnodes */ 707c478bd9Sstevel@tonic-gate struct lfsnode *li_lfs; /* list of other vfss */ 717c478bd9Sstevel@tonic-gate kmutex_t li_lfslock; /* lock protecting li_lfs */ 727c478bd9Sstevel@tonic-gate kmutex_t li_htlock; /* protect hashtable, htsize, retired */ 737c478bd9Sstevel@tonic-gate struct lo_retired_ht *li_retired; /* list of retired hashtables */ 747c478bd9Sstevel@tonic-gate int li_flag; /* filesystem behavior flags */ 757c478bd9Sstevel@tonic-gate }; 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* inheritable mount flags - propagated from real vfs to loopback */ 787c478bd9Sstevel@tonic-gate #define INHERIT_VFS_FLAG \ 797c478bd9Sstevel@tonic-gate (VFS_RDONLY|VFS_NOSETUID|VFS_NODEVICES|VFS_XATTR|VFS_NBMAND|VFS_NOEXEC) 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate /* 827c478bd9Sstevel@tonic-gate * "nosub" is used to provide NFS server-like semantics for lo_lookup(): never 837c478bd9Sstevel@tonic-gate * traverse mount points for sub-mounts. The lookup will instead look under 847c478bd9Sstevel@tonic-gate * the mount point. 857c478bd9Sstevel@tonic-gate */ 867c478bd9Sstevel@tonic-gate #define MNTOPT_LOFS_NOSUB "nosub" 877c478bd9Sstevel@tonic-gate #define MNTOPT_LOFS_SUB "sub" 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* 907c478bd9Sstevel@tonic-gate * Flag values (for li_flag) 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate #define LO_NOSUB 0x02 /* don't traverse sub-mounts */ 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* 957c478bd9Sstevel@tonic-gate * lfsnodes are allocated as new real vfs's are encountered 967c478bd9Sstevel@tonic-gate * when looking up things in a loopback name space 977c478bd9Sstevel@tonic-gate * It contains a new vfs which is paired with the real vfs 987c478bd9Sstevel@tonic-gate * so that vfs ops (fsstat) can get to the correct real vfs 997c478bd9Sstevel@tonic-gate * given just a loopback vfs 1007c478bd9Sstevel@tonic-gate */ 1017c478bd9Sstevel@tonic-gate struct lfsnode { 1027c478bd9Sstevel@tonic-gate struct lfsnode *lfs_next; /* next in loinfo list */ 1037c478bd9Sstevel@tonic-gate struct vfs *lfs_realvfs; /* real vfs */ 1047c478bd9Sstevel@tonic-gate struct vnode *lfs_realrootvp; /* real root vp */ 1057c478bd9Sstevel@tonic-gate struct vfs lfs_vfs; /* new loopback vfs */ 1067c478bd9Sstevel@tonic-gate }; 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate #define vtoli(VFSP) ((struct loinfo *)((VFSP)->vfs_data)) 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1117c478bd9Sstevel@tonic-gate extern struct vfs *lo_realvfs(struct vfs *, struct vnode **); 1127c478bd9Sstevel@tonic-gate extern void lofs_subrinit(void); 1137c478bd9Sstevel@tonic-gate extern void lofs_subrfini(void); 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate extern void lsetup(struct loinfo *, uint_t); 1167c478bd9Sstevel@tonic-gate extern void ldestroy(struct loinfo *); 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate extern const struct fs_operation_def lo_vnodeops_template[]; 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate extern struct vnodeops *lo_vnodeops; 1217c478bd9Sstevel@tonic-gate extern vfsops_t *lo_vfsops; 1227c478bd9Sstevel@tonic-gate extern struct mod_ops mod_fsops; 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1287c478bd9Sstevel@tonic-gate } 1297c478bd9Sstevel@tonic-gate #endif 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate #endif /* _SYS_FS_LOFS_INFO_H */ 132