162306a36Sopenharmony_ci========================== 262306a36Sopenharmony_ciReference counting in pnfs 362306a36Sopenharmony_ci========================== 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciThe are several inter-related caches. We have layouts which can 662306a36Sopenharmony_cireference multiple devices, each of which can reference multiple data servers. 762306a36Sopenharmony_ciEach data server can be referenced by multiple devices. Each device 862306a36Sopenharmony_cican be referenced by multiple layouts. To keep all of this straight, 962306a36Sopenharmony_ciwe need to reference count. 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_cistruct pnfs_layout_hdr 1362306a36Sopenharmony_ci====================== 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ciThe on-the-wire command LAYOUTGET corresponds to struct 1662306a36Sopenharmony_cipnfs_layout_segment, usually referred to by the variable name lseg. 1762306a36Sopenharmony_ciEach nfs_inode may hold a pointer to a cache of these layout 1862306a36Sopenharmony_cisegments in nfsi->layout, of type struct pnfs_layout_hdr. 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ciWe reference the header for the inode pointing to it, across each 2162306a36Sopenharmony_cioutstanding RPC call that references it (LAYOUTGET, LAYOUTRETURN, 2262306a36Sopenharmony_ciLAYOUTCOMMIT), and for each lseg held within. 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ciEach header is also (when non-empty) put on a list associated with 2562306a36Sopenharmony_cistruct nfs_client (cl_layouts). Being put on this list does not bump 2662306a36Sopenharmony_cithe reference count, as the layout is kept around by the lseg that 2762306a36Sopenharmony_cikeeps it in the list. 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_cideviceid_cache 3062306a36Sopenharmony_ci============== 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_cilsegs reference device ids, which are resolved per nfs_client and 3362306a36Sopenharmony_cilayout driver type. The device ids are held in a RCU cache (struct 3462306a36Sopenharmony_cinfs4_deviceid_cache). The cache itself is referenced across each 3562306a36Sopenharmony_cimount. The entries (struct nfs4_deviceid) themselves are held across 3662306a36Sopenharmony_cithe lifetime of each lseg referencing them. 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ciRCU is used because the deviceid is basically a write once, read many 3962306a36Sopenharmony_cidata structure. The hlist size of 32 buckets needs better 4062306a36Sopenharmony_cijustification, but seems reasonable given that we can have multiple 4162306a36Sopenharmony_cideviceid's per filesystem, and multiple filesystems per nfs_client. 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ciThe hash code is copied from the nfsd code base. A discussion of 4462306a36Sopenharmony_cihashing and variations of this algorithm can be found `here. 4562306a36Sopenharmony_ci<http://groups.google.com/group/comp.lang.c/browse_thread/thread/9522965e2b8d3809>`_ 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_cidata server cache 4862306a36Sopenharmony_ci================= 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_cifile driver devices refer to data servers, which are kept in a module 5162306a36Sopenharmony_cilevel cache. Its reference is held over the lifetime of the deviceid 5262306a36Sopenharmony_cipointing to it. 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_cilseg 5562306a36Sopenharmony_ci==== 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_cilseg maintains an extra reference corresponding to the NFS_LSEG_VALID 5862306a36Sopenharmony_cibit which holds it in the pnfs_layout_hdr's list. When the final lseg 5962306a36Sopenharmony_ciis removed from the pnfs_layout_hdr's list, the NFS_LAYOUT_DESTROYED 6062306a36Sopenharmony_cibit is set, preventing any new lsegs from being added. 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_cilayout drivers 6362306a36Sopenharmony_ci============== 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ciPNFS utilizes what is called layout drivers. The STD defines 4 basic 6662306a36Sopenharmony_cilayout types: "files", "objects", "blocks", and "flexfiles". For each 6762306a36Sopenharmony_ciof these types there is a layout-driver with a common function-vectors 6862306a36Sopenharmony_citable which are called by the nfs-client pnfs-core to implement the 6962306a36Sopenharmony_cidifferent layout types. 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ciFiles-layout-driver code is in: fs/nfs/filelayout/.. directory 7262306a36Sopenharmony_ciBlocks-layout-driver code is in: fs/nfs/blocklayout/.. directory 7362306a36Sopenharmony_ciFlexfiles-layout-driver code is in: fs/nfs/flexfilelayout/.. directory 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ciblocks-layout setup 7662306a36Sopenharmony_ci=================== 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ciTODO: Document the setup needs of the blocks layout driver 79