The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/fuse/fuse_node.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-3-Clause
    3  *
    4  * Copyright (c) 2007-2009 Google Inc. and Amit Singh
    5  * All rights reserved.
    6  * 
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions are
    9  * met:
   10  * 
   11  * * Redistributions of source code must retain the above copyright
   12  *   notice, this list of conditions and the following disclaimer.
   13  * * Redistributions in binary form must reproduce the above
   14  *   copyright notice, this list of conditions and the following disclaimer
   15  *   in the documentation and/or other materials provided with the
   16  *   distribution.
   17  * * Neither the name of Google Inc. nor the names of its
   18  *   contributors may be used to endorse or promote products derived from
   19  *   this software without specific prior written permission.
   20  * 
   21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   32  * 
   33  * Copyright (C) 2005 Csaba Henk.
   34  * All rights reserved.
   35  *
   36  * Copyright (c) 2019 The FreeBSD Foundation
   37  *
   38  * Portions of this software were developed by BFF Storage Systems, LLC under
   39  * sponsorship from the FreeBSD Foundation.
   40  * 
   41  * Redistribution and use in source and binary forms, with or without
   42  * modification, are permitted provided that the following conditions
   43  * are met:
   44  * 1. Redistributions of source code must retain the above copyright
   45  *    notice, this list of conditions and the following disclaimer.
   46  * 2. Redistributions in binary form must reproduce the above copyright
   47  *    notice, this list of conditions and the following disclaimer in the
   48  *    documentation and/or other materials provided with the distribution.
   49  * 
   50  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   51  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   52  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   53  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
   54  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   55  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   56  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   57  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   58  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   59  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   60  * SUCH DAMAGE.
   61  *
   62  * $FreeBSD$
   63  */
   64 
   65 #ifndef _FUSE_NODE_H_
   66 #define _FUSE_NODE_H_
   67 
   68 #include <sys/fnv_hash.h>
   69 #include <sys/types.h>
   70 #include <sys/mutex.h>
   71 
   72 #include "fuse_file.h"
   73 
   74 #define FN_REVOKED              0x00000020
   75 #define FN_FLUSHINPROG          0x00000040
   76 #define FN_FLUSHWANT            0x00000080
   77 /* 
   78  * Indicates that the file's size is dirty; the kernel has changed it but not
   79  * yet send the change to the daemon.  When this bit is set, the
   80  * cache_attrs.va_size field does not time out.
   81  */
   82 #define FN_SIZECHANGE           0x00000100
   83 #define FN_DIRECTIO             0x00000200
   84 /* Indicates that parent_nid is valid */
   85 #define FN_PARENT_NID           0x00000400
   86 
   87 /* 
   88  * Indicates that the file's cached timestamps are dirty.  They will be flushed
   89  * during the next SETATTR or WRITE.  Until then, the cached fields will not
   90  * time out.
   91  */
   92 #define FN_MTIMECHANGE          0x00000800
   93 #define FN_CTIMECHANGE          0x00001000
   94 #define FN_ATIMECHANGE          0x00002000
   95 
   96 struct fuse_vnode_data {
   97         /** self **/
   98         uint64_t        nid;
   99         uint64_t        generation;
  100 
  101         /** parent **/
  102         uint64_t        parent_nid;
  103 
  104         /** I/O **/
  105         /* List of file handles for all of the vnode's open file descriptors */
  106         LIST_HEAD(, fuse_filehandle)    handles;
  107 
  108         /** flags **/
  109         uint32_t        flag;
  110 
  111         /** meta **/
  112         /* The monotonic time after which the attr cache is invalid */
  113         struct bintime  attr_cache_timeout;
  114         /* 
  115          * Monotonic time after which the entry is invalid.  Used for lookups
  116          * by nodeid instead of pathname.
  117          */
  118         struct bintime  entry_cache_timeout;
  119         /*
  120          * Monotonic time of the last FUSE operation that modified the file
  121          * size.  Used to avoid races between mutator ops like VOP_SETATTR and
  122          * unlocked accessor ops like VOP_LOOKUP.
  123          */
  124         struct timespec last_local_modify;
  125         struct vattr    cached_attrs;
  126         uint64_t        nlookup;
  127         enum vtype      vtype;
  128 };
  129 
  130 /*
  131  * This overlays the fid structure (see mount.h). Mostly the same as the types
  132  * used by UFS and ext2.
  133  */
  134 struct fuse_fid {
  135         uint16_t        len;    /* Length of structure. */
  136         uint16_t        pad;    /* Force 32-bit alignment. */
  137         uint32_t        gen;    /* Generation number. */
  138         uint64_t        nid;    /* FUSE node id. */
  139 };
  140 
  141 #define VTOFUD(vp) \
  142         ((struct fuse_vnode_data *)((vp)->v_data))
  143 #define VTOI(vp)    (VTOFUD(vp)->nid)
  144 static inline bool
  145 fuse_vnode_attr_cache_valid(struct vnode *vp)
  146 {
  147         struct bintime now;
  148 
  149         getbinuptime(&now);
  150         return (bintime_cmp(&(VTOFUD(vp)->attr_cache_timeout), &now, >));
  151 }
  152 
  153 static inline struct vattr*
  154 VTOVA(struct vnode *vp)
  155 {
  156         if (fuse_vnode_attr_cache_valid(vp))
  157                 return &(VTOFUD(vp)->cached_attrs);
  158         else
  159                 return NULL;
  160 }
  161 
  162 static inline void
  163 fuse_vnode_clear_attr_cache(struct vnode *vp)
  164 {
  165         bintime_clear(&VTOFUD(vp)->attr_cache_timeout);
  166 }
  167 
  168 static uint32_t inline
  169 fuse_vnode_hash(uint64_t id)
  170 {
  171         return (fnv_32_buf(&id, sizeof(id), FNV1_32_INIT));
  172 }
  173 
  174 #define VTOILLU(vp) ((uint64_t)(VTOFUD(vp) ? VTOI(vp) : 0))
  175 
  176 #define FUSE_NULL_ID 0
  177 
  178 extern struct vop_vector fuse_fifoops;
  179 extern struct vop_vector fuse_vnops;
  180 
  181 int fuse_vnode_cmp(struct vnode *vp, void *nidp);
  182 
  183 static inline void
  184 fuse_vnode_setparent(struct vnode *vp, struct vnode *dvp)
  185 {
  186         if (dvp != NULL && vp->v_type == VDIR) {
  187                 MPASS(dvp->v_type == VDIR);
  188                 VTOFUD(vp)->parent_nid = VTOI(dvp);
  189                 VTOFUD(vp)->flag |= FN_PARENT_NID;
  190         } else {
  191                 VTOFUD(vp)->flag &= ~FN_PARENT_NID;
  192         }
  193 }
  194 
  195 int fuse_vnode_size(struct vnode *vp, off_t *filesize, struct ucred *cred,
  196         struct thread *td);
  197 
  198 void fuse_vnode_destroy(struct vnode *vp);
  199 
  200 int fuse_vnode_get(struct mount *mp, struct fuse_entry_out *feo,
  201     uint64_t nodeid, struct vnode *dvp, struct vnode **vpp,
  202     struct componentname *cnp, enum vtype vtyp);
  203 
  204 void fuse_vnode_open(struct vnode *vp, int32_t fuse_open_flags,
  205     struct thread *td);
  206 
  207 int fuse_vnode_savesize(struct vnode *vp, struct ucred *cred, pid_t pid);
  208 
  209 int fuse_vnode_setsize(struct vnode *vp, off_t newsize, bool from_server);
  210 
  211 void fuse_vnode_undirty_cached_timestamps(struct vnode *vp, bool atime);
  212 
  213 void fuse_vnode_update(struct vnode *vp, int flags);
  214 
  215 void fuse_node_init(void);
  216 void fuse_node_destroy(void);
  217 #endif /* _FUSE_NODE_H_ */

Cache object: 1ee066aaa7590adae8a0af79f7bbcea3


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.