linux/include/uapi/linux/nilfs2_api.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */
   2/*
   3 * nilfs2_api.h - NILFS2 user space API
   4 *
   5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
   6 *
   7 * This program is free software; you can redistribute it and/or modify
   8 * it under the terms of the GNU Lesser General Public License as published
   9 * by the Free Software Foundation; either version 2.1 of the License, or
  10 * (at your option) any later version.
  11 */
  12
  13#ifndef _LINUX_NILFS2_API_H
  14#define _LINUX_NILFS2_API_H
  15
  16#include <linux/types.h>
  17#include <linux/ioctl.h>
  18
  19/**
  20 * struct nilfs_cpinfo - checkpoint information
  21 * @ci_flags: flags
  22 * @ci_pad: padding
  23 * @ci_cno: checkpoint number
  24 * @ci_create: creation timestamp
  25 * @ci_nblk_inc: number of blocks incremented by this checkpoint
  26 * @ci_inodes_count: inodes count
  27 * @ci_blocks_count: blocks count
  28 * @ci_next: next checkpoint number in snapshot list
  29 */
  30struct nilfs_cpinfo {
  31        __u32 ci_flags;
  32        __u32 ci_pad;
  33        __u64 ci_cno;
  34        __u64 ci_create;
  35        __u64 ci_nblk_inc;
  36        __u64 ci_inodes_count;
  37        __u64 ci_blocks_count;
  38        __u64 ci_next;
  39};
  40
  41/* checkpoint flags */
  42enum {
  43        NILFS_CPINFO_SNAPSHOT,
  44        NILFS_CPINFO_INVALID,
  45        NILFS_CPINFO_SKETCH,
  46        NILFS_CPINFO_MINOR,
  47};
  48
  49#define NILFS_CPINFO_FNS(flag, name)                                    \
  50static inline int                                                       \
  51nilfs_cpinfo_##name(const struct nilfs_cpinfo *cpinfo)                  \
  52{                                                                       \
  53        return !!(cpinfo->ci_flags & (1UL << NILFS_CPINFO_##flag));     \
  54}
  55
  56NILFS_CPINFO_FNS(SNAPSHOT, snapshot)
  57NILFS_CPINFO_FNS(INVALID, invalid)
  58NILFS_CPINFO_FNS(MINOR, minor)
  59
  60/**
  61 * nilfs_suinfo - segment usage information
  62 * @sui_lastmod: timestamp of last modification
  63 * @sui_nblocks: number of written blocks in segment
  64 * @sui_flags: segment usage flags
  65 */
  66struct nilfs_suinfo {
  67        __u64 sui_lastmod;
  68        __u32 sui_nblocks;
  69        __u32 sui_flags;
  70};
  71
  72/* segment usage flags */
  73enum {
  74        NILFS_SUINFO_ACTIVE,
  75        NILFS_SUINFO_DIRTY,
  76        NILFS_SUINFO_ERROR,
  77};
  78
  79#define NILFS_SUINFO_FNS(flag, name)                                    \
  80static inline int                                                       \
  81nilfs_suinfo_##name(const struct nilfs_suinfo *si)                      \
  82{                                                                       \
  83        return si->sui_flags & (1UL << NILFS_SUINFO_##flag);            \
  84}
  85
  86NILFS_SUINFO_FNS(ACTIVE, active)
  87NILFS_SUINFO_FNS(DIRTY, dirty)
  88NILFS_SUINFO_FNS(ERROR, error)
  89
  90static inline int nilfs_suinfo_clean(const struct nilfs_suinfo *si)
  91{
  92        return !si->sui_flags;
  93}
  94
  95/**
  96 * nilfs_suinfo_update - segment usage information update
  97 * @sup_segnum: segment number
  98 * @sup_flags: flags for which fields are active in sup_sui
  99 * @sup_reserved: reserved necessary for alignment
 100 * @sup_sui: segment usage information
 101 */
 102struct nilfs_suinfo_update {
 103        __u64 sup_segnum;
 104        __u32 sup_flags;
 105        __u32 sup_reserved;
 106        struct nilfs_suinfo sup_sui;
 107};
 108
 109enum {
 110        NILFS_SUINFO_UPDATE_LASTMOD,
 111        NILFS_SUINFO_UPDATE_NBLOCKS,
 112        NILFS_SUINFO_UPDATE_FLAGS,
 113        __NR_NILFS_SUINFO_UPDATE_FIELDS,
 114};
 115
 116#define NILFS_SUINFO_UPDATE_FNS(flag, name)                             \
 117static inline void                                                      \
 118nilfs_suinfo_update_set_##name(struct nilfs_suinfo_update *sup)         \
 119{                                                                       \
 120        sup->sup_flags |= 1UL << NILFS_SUINFO_UPDATE_##flag;            \
 121}                                                                       \
 122static inline void                                                      \
 123nilfs_suinfo_update_clear_##name(struct nilfs_suinfo_update *sup)       \
 124{                                                                       \
 125        sup->sup_flags &= ~(1UL << NILFS_SUINFO_UPDATE_##flag);         \
 126}                                                                       \
 127static inline int                                                       \
 128nilfs_suinfo_update_##name(const struct nilfs_suinfo_update *sup)       \
 129{                                                                       \
 130        return !!(sup->sup_flags & (1UL << NILFS_SUINFO_UPDATE_##flag));\
 131}
 132
 133NILFS_SUINFO_UPDATE_FNS(LASTMOD, lastmod)
 134NILFS_SUINFO_UPDATE_FNS(NBLOCKS, nblocks)
 135NILFS_SUINFO_UPDATE_FNS(FLAGS, flags)
 136
 137enum {
 138        NILFS_CHECKPOINT,
 139        NILFS_SNAPSHOT,
 140};
 141
 142/**
 143 * struct nilfs_cpmode - change checkpoint mode structure
 144 * @cm_cno: checkpoint number
 145 * @cm_mode: mode of checkpoint
 146 * @cm_pad: padding
 147 */
 148struct nilfs_cpmode {
 149        __u64 cm_cno;
 150        __u32 cm_mode;
 151        __u32 cm_pad;
 152};
 153
 154/**
 155 * struct nilfs_argv - argument vector
 156 * @v_base: pointer on data array from userspace
 157 * @v_nmembs: number of members in data array
 158 * @v_size: size of data array in bytes
 159 * @v_flags: flags
 160 * @v_index: start number of target data items
 161 */
 162struct nilfs_argv {
 163        __u64 v_base;
 164        __u32 v_nmembs; /* number of members */
 165        __u16 v_size;   /* size of members */
 166        __u16 v_flags;
 167        __u64 v_index;
 168};
 169
 170/**
 171 * struct nilfs_period - period of checkpoint numbers
 172 * @p_start: start checkpoint number (inclusive)
 173 * @p_end: end checkpoint number (exclusive)
 174 */
 175struct nilfs_period {
 176        __u64 p_start;
 177        __u64 p_end;
 178};
 179
 180/**
 181 * struct nilfs_cpstat - checkpoint statistics
 182 * @cs_cno: checkpoint number
 183 * @cs_ncps: number of checkpoints
 184 * @cs_nsss: number of snapshots
 185 */
 186struct nilfs_cpstat {
 187        __u64 cs_cno;
 188        __u64 cs_ncps;
 189        __u64 cs_nsss;
 190};
 191
 192/**
 193 * struct nilfs_sustat - segment usage statistics
 194 * @ss_nsegs: number of segments
 195 * @ss_ncleansegs: number of clean segments
 196 * @ss_ndirtysegs: number of dirty segments
 197 * @ss_ctime: creation time of the last segment
 198 * @ss_nongc_ctime: creation time of the last segment not for GC
 199 * @ss_prot_seq: least sequence number of segments which must not be reclaimed
 200 */
 201struct nilfs_sustat {
 202        __u64 ss_nsegs;
 203        __u64 ss_ncleansegs;
 204        __u64 ss_ndirtysegs;
 205        __u64 ss_ctime;
 206        __u64 ss_nongc_ctime;
 207        __u64 ss_prot_seq;
 208};
 209
 210/**
 211 * struct nilfs_vinfo - virtual block number information
 212 * @vi_vblocknr: virtual block number
 213 * @vi_start: start checkpoint number (inclusive)
 214 * @vi_end: end checkpoint number (exclusive)
 215 * @vi_blocknr: disk block number
 216 */
 217struct nilfs_vinfo {
 218        __u64 vi_vblocknr;
 219        __u64 vi_start;
 220        __u64 vi_end;
 221        __u64 vi_blocknr;
 222};
 223
 224/**
 225 * struct nilfs_vdesc - descriptor of virtual block number
 226 * @vd_ino: inode number
 227 * @vd_cno: checkpoint number
 228 * @vd_vblocknr: virtual block number
 229 * @vd_period: period of checkpoint numbers
 230 * @vd_blocknr: disk block number
 231 * @vd_offset: logical block offset inside a file
 232 * @vd_flags: flags (data or node block)
 233 * @vd_pad: padding
 234 */
 235struct nilfs_vdesc {
 236        __u64 vd_ino;
 237        __u64 vd_cno;
 238        __u64 vd_vblocknr;
 239        struct nilfs_period vd_period;
 240        __u64 vd_blocknr;
 241        __u64 vd_offset;
 242        __u32 vd_flags;
 243        __u32 vd_pad;
 244};
 245
 246/**
 247 * struct nilfs_bdesc - descriptor of disk block number
 248 * @bd_ino: inode number
 249 * @bd_oblocknr: disk block address (for skipping dead blocks)
 250 * @bd_blocknr: disk block address
 251 * @bd_offset: logical block offset inside a file
 252 * @bd_level: level in the b-tree organization
 253 * @bd_pad: padding
 254 */
 255struct nilfs_bdesc {
 256        __u64 bd_ino;
 257        __u64 bd_oblocknr;
 258        __u64 bd_blocknr;
 259        __u64 bd_offset;
 260        __u32 bd_level;
 261        __u32 bd_pad;
 262};
 263
 264#define NILFS_IOCTL_IDENT       'n'
 265
 266#define NILFS_IOCTL_CHANGE_CPMODE                                       \
 267        _IOW(NILFS_IOCTL_IDENT, 0x80, struct nilfs_cpmode)
 268#define NILFS_IOCTL_DELETE_CHECKPOINT                                   \
 269        _IOW(NILFS_IOCTL_IDENT, 0x81, __u64)
 270#define NILFS_IOCTL_GET_CPINFO                                          \
 271        _IOR(NILFS_IOCTL_IDENT, 0x82, struct nilfs_argv)
 272#define NILFS_IOCTL_GET_CPSTAT                                          \
 273        _IOR(NILFS_IOCTL_IDENT, 0x83, struct nilfs_cpstat)
 274#define NILFS_IOCTL_GET_SUINFO                                          \
 275        _IOR(NILFS_IOCTL_IDENT, 0x84, struct nilfs_argv)
 276#define NILFS_IOCTL_GET_SUSTAT                                          \
 277        _IOR(NILFS_IOCTL_IDENT, 0x85, struct nilfs_sustat)
 278#define NILFS_IOCTL_GET_VINFO                                           \
 279        _IOWR(NILFS_IOCTL_IDENT, 0x86, struct nilfs_argv)
 280#define NILFS_IOCTL_GET_BDESCS                                          \
 281        _IOWR(NILFS_IOCTL_IDENT, 0x87, struct nilfs_argv)
 282#define NILFS_IOCTL_CLEAN_SEGMENTS                                      \
 283        _IOW(NILFS_IOCTL_IDENT, 0x88, struct nilfs_argv[5])
 284#define NILFS_IOCTL_SYNC                                                \
 285        _IOR(NILFS_IOCTL_IDENT, 0x8A, __u64)
 286#define NILFS_IOCTL_RESIZE                                              \
 287        _IOW(NILFS_IOCTL_IDENT, 0x8B, __u64)
 288#define NILFS_IOCTL_SET_ALLOC_RANGE                                     \
 289        _IOW(NILFS_IOCTL_IDENT, 0x8C, __u64[2])
 290#define NILFS_IOCTL_SET_SUINFO                                          \
 291        _IOW(NILFS_IOCTL_IDENT, 0x8D, struct nilfs_argv)
 292
 293#endif /* _LINUX_NILFS2_API_H */
 294