STRUCT THE_NILFS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct the_nilfs(9) πŸ’…

okay so bestie, welcome to the Kernel API Manual β€” yes that's the manual name, we're fancy now β€” and today's main character is struct the_nilfs, the struct that supervises multiple nilfs mount points. like, all of them. she's the momager. πŸŽ€


✨ NAME ✨

struct the_nilfs β€” the struct that supervises multiple nilfs mount points. she runs the whole friend group, no cap. πŸ‘‘


🌸 SYNOPSIS 🌸

struct the_nilfs {
    unsigned long           ns_flags;
    int ns_flushed_device;
    struct super_block     *ns_sb;
    struct block_device    *ns_bdev;
    struct rw_semaphore     ns_sem;
    struct mutex            ns_snapshot_mount_mutex;
    struct buffer_head     *ns_sbh[2];
    struct nilfs_super_block *ns_sbp[2];
    time64_t ns_sbwtime;
    unsigned int            ns_sbwcount;
    unsigned int            ns_sbsize;
    unsigned int            ns_mount_state;
    unsigned int            ns_sb_update_freq;
    u64 ns_seg_seq;
    __u64 ns_segnum;
    __u64 ns_nextnum;
    unsigned long           ns_pseg_offset;
    __u64 ns_cno;
    time64_t ns_ctime;
    time64_t ns_nongc_ctime;
    atomic_t ns_ndirtyblks;
    spinlock_t ns_last_segment_lock;
    sector_t ns_last_pseg;
    u64 ns_last_seq;
    __u64 ns_last_cno;
    u64 ns_prot_seq;
    u64 ns_prev_seq;
    struct nilfs_sc_info   *ns_writer;
    struct rw_semaphore     ns_segctor_sem;
    struct inode           *ns_dat;
    struct inode           *ns_cpfile;
    struct inode           *ns_sufile;
    struct rb_root          ns_cptree;
    spinlock_t ns_cptree_lock;
    struct list_head        ns_dirty_files;
    spinlock_t ns_inode_lock;
    struct list_head        ns_gc_inodes;
    unsigned long           ns_mount_opt;
    uid_t ns_resuid;
    gid_t ns_resgid;
    unsigned long           ns_interval;
    unsigned long           ns_watermark;
    unsigned int            ns_blocksize_bits;
    unsigned int            ns_blocksize;
    unsigned long           ns_nsegments;
    unsigned long           ns_blocks_per_segment;
    unsigned long           ns_r_segments_percentage;
    unsigned long           ns_nrsvsegs;
    unsigned long           ns_first_data_block;
    int ns_inode_size;
    unsigned int            ns_first_ino;
    u32 ns_crc_seed;
    struct kobject ns_dev_kobj;
    struct completion ns_dev_kobj_unregister;
    struct nilfs_sysfs_dev_subgroups *ns_dev_subgroups;
 };

like, look at her. that's a lot of fields and every single one is doing her part. we love a hardworking queen. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

she's the struct that supervises multiple nilfs mount points. literally her whole job. now let's meet the members one by one, because they all deserve their moment. πŸ’–


πŸ’œ MEMBERS πŸ’œ

  • ns_flags β€” flags. short, sweet, iconic.
  • ns_flushed_device β€” a flag indicating if all volatile data was flushed. basically the "did everyone make it home safe" check. 😭
  • ns_sb β€” back pointer to the super block instance.
  • ns_bdev β€” the block device.
  • ns_sem β€” semaphore for shared states. sharing is caring but lock it first, bestie.
  • ns_snapshot_mount_mutex β€” mutex to protect snapshot mounts. do not skip the mutex, i'm begging. πŸ™ˆ
  • ns_sbh β€” buffer heads of on-disk super blocks.
  • ns_sbp β€” pointers to super block data.
  • ns_sbwtime β€” previous write time of super block.
  • ns_sbwcount β€” write count of super block.
  • ns_sbsize β€” size of valid data in super block.
  • ns_mount_state β€” file system state.
  • ns_sb_update_freq β€” interval of periodical update of superblocks (in seconds). yes, seconds, keep the units, they matter. ⏰
  • ns_seg_seq β€” segment sequence counter.
  • ns_segnum β€” index number of the latest full segment.
  • ns_nextnum β€” index number of the full segment index to be used next.
  • ns_pseg_offset β€” offset of next partial segment in the current full segment.
  • ns_cno β€” next checkpoint number.
  • ns_ctime β€” write time of the last segment.
  • ns_nongc_ctime β€” write time of the last segment not for cleaner operation. not the cleaner's, okay? different vibe entirely.
  • ns_ndirtyblks β€” Number of dirty data blocks. capital N, that's canon, we don't question the source.
  • ns_last_segment_lock β€” lock protecting fields for the latest segment.
  • ns_last_pseg β€” start block number of the latest segment.
  • ns_last_seq β€” sequence value of the latest segment.
  • ns_last_cno β€” checkpoint number of the latest segment.
  • ns_prot_seq β€” least sequence number of segments which must not be reclaimed. hands off, protected, do not touch. 🚫
  • ns_prev_seq β€” base sequence number used to decide if advance log cursor.
  • ns_writer β€” log writer. the scribe. the note-taker of the group chat. ✍️
  • ns_segctor_sem β€” semaphore protecting log write.
  • ns_dat β€” DAT file inode.
  • ns_cpfile β€” checkpoint file inode.
  • ns_sufile β€” segusage file inode.
  • ns_cptree β€” rb-tree of all mounted checkpoints (nilfs_root).
  • ns_cptree_lock β€” lock protecting ns_cptree.
  • ns_dirty_files β€” list of dirty files.
  • ns_inode_lock β€” lock protecting ns_dirty_files. see how she pairs them up? iconic behavior.
  • ns_gc_inodes β€” dummy inodes to keep live blocks.
  • ns_mount_opt β€” mount options.
  • ns_resuid β€” uid for reserved blocks.
  • ns_resgid β€” gid for reserved blocks.
  • ns_interval β€” checkpoint creation interval.
  • ns_watermark β€” watermark for the number of dirty buffers.
  • ns_blocksize_bits β€” bit length of block size.
  • ns_blocksize β€” block size.
  • ns_nsegments β€” number of segments in filesystem.
  • ns_blocks_per_segment β€” number of blocks per segment.
  • ns_r_segments_percentage β€” reserved segments percentage.
  • ns_nrsvsegs β€” number of reserved segments.
  • ns_first_data_block β€” block number of first data block.
  • ns_inode_size β€” size of on-disk inode.
  • ns_first_ino β€” first not-special inode number.
  • ns_crc_seed β€” seed value of CRC32 calculation.
  • ns_dev_kobj β€” literally /sys/fs/<nilfs>/<device>. she lives there rent free. 🏠
  • ns_dev_kobj_unregister β€” completion state.
  • ns_dev_subgroups β€” <device> subgroups pointer.

πŸ”₯ SEE ALSO πŸ”₯

  • Kernel file ./fs/nilfs2/the_nilfs.h
  • struct nilfs_root(9)

ok but fr fr, go read ./fs/nilfs2/the_nilfs.h when you're done here. iykyk. πŸ“–βœ¨

and that's the whole page, bestie β€” brought to you by the source ./fs/nilfs2, dated October 2026. periodt. πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from