Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/fuse/fuse_node.h
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | struct fuse_vnode_data { | ||||
/** self **/ | /** self **/ | ||||
uint64_t nid; | uint64_t nid; | ||||
uint64_t generation; | uint64_t generation; | ||||
/** parent **/ | /** parent **/ | ||||
uint64_t parent_nid; | uint64_t parent_nid; | ||||
/** I/O **/ | /** I/O **/ | ||||
/* List of file handles for all of the vnode's open file descriptors */ | /* | ||||
* List of file handles for all of the vnode's open file descriptors. | |||||
* Protected by the vnode lock. | |||||
*/ | |||||
LIST_HEAD(, fuse_filehandle) handles; | LIST_HEAD(, fuse_filehandle) handles; | ||||
/** flags **/ | /** flags **/ | ||||
uint32_t flag; | uint32_t flag; | ||||
cem: All of these fields seem to be protected by the vnode lock. It might be better to put a struct… | |||||
Done Inline ActionsExcept that much of it isn't protected by the vnode lock. Maybe it should be, but it's not. So I'm auditing the fields one by one. I'll audit those fields in a separate commit, if that's ok. asomers: Except that much of it isn't protected by the vnode lock. Maybe it should be, but it's not. | |||||
Done Inline ActionsWorks for me cem: Works for me | |||||
/** meta **/ | /** meta **/ | ||||
/* The monotonic time after which the attr cache is invalid */ | /* | ||||
* The monotonic time after which the attr cache is invalid, protected | |||||
* by the vnode lock. | |||||
*/ | |||||
struct bintime attr_cache_timeout; | struct bintime attr_cache_timeout; | ||||
Done Inline ActionsImplied in this diff is that this entry is also vnode-locked. cem: Implied in this diff is that this entry is also vnode-locked. | |||||
/* | /* | ||||
* Monotonic time after which the entry is invalid. Used for lookups | * Monotonic time after which the entry is invalid. Used for lookups | ||||
* by nodeid instead of pathname. | * by nodeid instead of pathname. | ||||
*/ | */ | ||||
struct bintime entry_cache_timeout; | struct bintime entry_cache_timeout; | ||||
/* Cached file attributes, protected by the vnode lock */ | |||||
struct vattr cached_attrs; | struct vattr cached_attrs; | ||||
uint64_t nlookup; | uint64_t nlookup; | ||||
enum vtype vtype; | enum vtype vtype; | ||||
}; | }; | ||||
/* | /* | ||||
* This overlays the fid structure (see mount.h). Mostly the same as the types | * This overlays the fid structure (see mount.h). Mostly the same as the types | ||||
* used by UFS and ext2. | * used by UFS and ext2. | ||||
*/ | */ | ||||
struct fuse_fid { | struct fuse_fid { | ||||
uint16_t len; /* Length of structure. */ | uint16_t len; /* Length of structure. */ | ||||
uint16_t pad; /* Force 32-bit alignment. */ | uint16_t pad; /* Force 32-bit alignment. */ | ||||
uint32_t gen; /* Generation number. */ | uint32_t gen; /* Generation number. */ | ||||
uint64_t nid; /* FUSE node id. */ | uint64_t nid; /* FUSE node id. */ | ||||
}; | }; | ||||
#define VTOFUD(vp) \ | #define VTOFUD(vp) \ | ||||
((struct fuse_vnode_data *)((vp)->v_data)) | ((struct fuse_vnode_data *)((vp)->v_data)) | ||||
#define VTOI(vp) (VTOFUD(vp)->nid) | #define VTOI(vp) (VTOFUD(vp)->nid) | ||||
static inline bool | static inline bool | ||||
fuse_vnode_attr_cache_valid(struct vnode *vp) | fuse_vnode_attr_cache_valid(struct vnode *vp) | ||||
{ | { | ||||
struct bintime now; | struct bintime now; | ||||
ASSERT_VOP_LOCKED(vp, __func__); | |||||
getbinuptime(&now); | getbinuptime(&now); | ||||
return (bintime_cmp(&(VTOFUD(vp)->attr_cache_timeout), &now, >)); | return (bintime_cmp(&(VTOFUD(vp)->attr_cache_timeout), &now, >)); | ||||
} | } | ||||
static inline struct vattr* | static inline struct vattr* | ||||
VTOVA(struct vnode *vp) | VTOVA(struct vnode *vp) | ||||
{ | { | ||||
ASSERT_VOP_LOCKED(vp, __func__); | |||||
if (fuse_vnode_attr_cache_valid(vp)) | if (fuse_vnode_attr_cache_valid(vp)) | ||||
return &(VTOFUD(vp)->cached_attrs); | return &(VTOFUD(vp)->cached_attrs); | ||||
else | else | ||||
return NULL; | return NULL; | ||||
} | } | ||||
static inline void | static inline void | ||||
fuse_vnode_clear_attr_cache(struct vnode *vp) | fuse_vnode_clear_attr_cache(struct vnode *vp) | ||||
{ | { | ||||
ASSERT_VOP_ELOCKED(vp, __func__); | |||||
bintime_clear(&VTOFUD(vp)->attr_cache_timeout); | bintime_clear(&VTOFUD(vp)->attr_cache_timeout); | ||||
} | } | ||||
static uint32_t inline | static uint32_t inline | ||||
fuse_vnode_hash(uint64_t id) | fuse_vnode_hash(uint64_t id) | ||||
{ | { | ||||
return (fnv_32_buf(&id, sizeof(id), FNV1_32_INIT)); | return (fnv_32_buf(&id, sizeof(id), FNV1_32_INIT)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |
All of these fields seem to be protected by the vnode lock. It might be better to put a struct-level comment documenting that, and then only document exceptions to the rule.