^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0+ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * nilfs.h - NILFS local header file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Written by Koji Sato and Ryusuke Konishi.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef _NILFS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define _NILFS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/buffer_head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/nilfs2_api.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/nilfs2_ondisk.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "the_nilfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "bmap.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * struct nilfs_inode_info - nilfs inode data in memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * @i_flags: inode flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * @i_state: dynamic state flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * @i_bmap: pointer on i_bmap_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * @i_bmap_data: raw block mapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * @i_xattr: <TODO>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * @i_dir_start_lookup: page index of last successful search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * @i_cno: checkpoint number for GC inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * @i_btnode_cache: cached pages of b-tree nodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * @i_dirty: list for connecting dirty files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * @xattr_sem: semaphore for extended attributes processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * @i_bh: buffer contains disk inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * @i_root: root object of the current filesystem tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * @vfs_inode: VFS inode object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct nilfs_inode_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) __u32 i_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) unsigned long i_state; /* Dynamic state flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct nilfs_bmap *i_bmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct nilfs_bmap i_bmap_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) __u64 i_xattr; /* sector_t ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) __u32 i_dir_start_lookup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) __u64 i_cno; /* check point number for GC inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct address_space i_btnode_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct list_head i_dirty; /* List for connecting dirty files */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #ifdef CONFIG_NILFS_XATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * Extended attributes can be read independently of the main file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * data. Taking i_sem even when reading would cause contention
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * between readers of EAs and writers of regular file data, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * instead we synchronize on xattr_sem when reading or changing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * EAs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct rw_semaphore xattr_sem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct buffer_head *i_bh; /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * i_bh contains a new or dirty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * disk inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct nilfs_root *i_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct inode vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static inline struct nilfs_inode_info *NILFS_I(const struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) return container_of(inode, struct nilfs_inode_info, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static inline struct nilfs_inode_info *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) NILFS_BMAP_I(const struct nilfs_bmap *bmap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) return container_of(bmap, struct nilfs_inode_info, i_bmap_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) static inline struct inode *NILFS_BTNC_I(struct address_space *btnc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct nilfs_inode_info *ii =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) container_of(btnc, struct nilfs_inode_info, i_btnode_cache);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return &ii->vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * Dynamic state flags of NILFS on-memory inode (i_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) NILFS_I_NEW = 0, /* Inode is newly created */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) NILFS_I_DIRTY, /* The file is dirty */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) NILFS_I_QUEUED, /* inode is in dirty_files list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) NILFS_I_BUSY, /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * Inode is grabbed by a segment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * constructor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) NILFS_I_COLLECTED, /* All dirty blocks are collected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) NILFS_I_UPDATED, /* The file has been written back */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) NILFS_I_INODE_SYNC, /* dsync is not allowed for inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) NILFS_I_BMAP, /* has bmap and btnode_cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) NILFS_I_GCINODE, /* inode for GC, on memory only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * commit flags for nilfs_commit_super and nilfs_sync_super
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) NILFS_SB_COMMIT = 0, /* Commit a super block alternately */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) NILFS_SB_COMMIT_ALL /* Commit both super blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * Macros to check inode numbers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define NILFS_MDT_INO_BITS \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) (BIT(NILFS_DAT_INO) | BIT(NILFS_CPFILE_INO) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) BIT(NILFS_SUFILE_INO) | BIT(NILFS_IFILE_INO) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) BIT(NILFS_ATIME_INO) | BIT(NILFS_SKETCH_INO))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define NILFS_SYS_INO_BITS (BIT(NILFS_ROOT_INO) | NILFS_MDT_INO_BITS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #define NILFS_FIRST_INO(sb) (((struct the_nilfs *)sb->s_fs_info)->ns_first_ino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define NILFS_MDT_INODE(sb, ino) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) ((ino) < NILFS_FIRST_INO(sb) && (NILFS_MDT_INO_BITS & BIT(ino)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) #define NILFS_VALID_INODE(sb, ino) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) ((ino) >= NILFS_FIRST_INO(sb) || (NILFS_SYS_INO_BITS & BIT(ino)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * struct nilfs_transaction_info: context information for synchronization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * @ti_magic: Magic number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * @ti_save: Backup of journal_info field of task_struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * @ti_flags: Flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * @ti_count: Nest level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct nilfs_transaction_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) u32 ti_magic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) void *ti_save;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * This should never be used. If it happens,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * one of other filesystems has a bug.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) unsigned short ti_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) unsigned short ti_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* ti_magic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #define NILFS_TI_MAGIC 0xd9e392fb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /* ti_flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) #define NILFS_TI_DYNAMIC_ALLOC 0x0001 /* Allocated from slab */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #define NILFS_TI_SYNC 0x0002 /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * Force to construct segment at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * end of transaction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #define NILFS_TI_GC 0x0004 /* GC context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #define NILFS_TI_COMMIT 0x0008 /* Change happened or not */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #define NILFS_TI_WRITER 0x0010 /* Constructor context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) int nilfs_transaction_begin(struct super_block *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) struct nilfs_transaction_info *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) int nilfs_transaction_commit(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) void nilfs_transaction_abort(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static inline void nilfs_set_transaction_flag(unsigned int flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct nilfs_transaction_info *ti = current->journal_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) ti->ti_flags |= flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static inline int nilfs_test_transaction_flag(unsigned int flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) struct nilfs_transaction_info *ti = current->journal_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (ti == NULL || ti->ti_magic != NILFS_TI_MAGIC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) return !!(ti->ti_flags & flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static inline int nilfs_doing_gc(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) return nilfs_test_transaction_flag(NILFS_TI_GC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static inline int nilfs_doing_construction(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) return nilfs_test_transaction_flag(NILFS_TI_WRITER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * function prototype
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #ifdef CONFIG_NILFS_POSIX_ACL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #error "NILFS: not yet supported POSIX ACL"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) extern int nilfs_acl_chmod(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) extern int nilfs_init_acl(struct inode *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) static inline int nilfs_acl_chmod(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static inline int nilfs_init_acl(struct inode *inode, struct inode *dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) inode->i_mode &= ~current_umask();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) #define NILFS_ATIME_DISABLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) /* Flags that should be inherited by new inodes from their parent. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #define NILFS_FL_INHERITED \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) (FS_SECRM_FL | FS_UNRM_FL | FS_COMPR_FL | FS_SYNC_FL | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) FS_COMPRBLK_FL | FS_NOCOMP_FL | FS_NOTAIL_FL | FS_DIRSYNC_FL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) /* Mask out flags that are inappropriate for the given type of inode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) static inline __u32 nilfs_mask_flags(umode_t mode, __u32 flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) if (S_ISDIR(mode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) return flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) else if (S_ISREG(mode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) return flags & ~(FS_DIRSYNC_FL | FS_TOPDIR_FL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) return flags & (FS_NODUMP_FL | FS_NOATIME_FL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /* dir.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) extern int nilfs_add_link(struct dentry *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) extern ino_t nilfs_inode_by_name(struct inode *, const struct qstr *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) extern int nilfs_make_empty(struct inode *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) extern struct nilfs_dir_entry *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) nilfs_find_entry(struct inode *, const struct qstr *, struct page **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) extern int nilfs_delete_entry(struct nilfs_dir_entry *, struct page *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) extern int nilfs_empty_dir(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) extern struct nilfs_dir_entry *nilfs_dotdot(struct inode *, struct page **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) extern void nilfs_set_link(struct inode *, struct nilfs_dir_entry *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) struct page *, struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /* file.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) extern int nilfs_sync_file(struct file *, loff_t, loff_t, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) /* ioctl.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) long nilfs_ioctl(struct file *, unsigned int, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) long nilfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, struct nilfs_argv *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) void **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) /* inode.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) void nilfs_inode_add_blocks(struct inode *inode, int n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) void nilfs_inode_sub_blocks(struct inode *inode, int n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) extern struct inode *nilfs_new_inode(struct inode *, umode_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) extern int nilfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) extern void nilfs_set_inode_flags(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) extern int nilfs_read_inode_common(struct inode *, struct nilfs_inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) extern void nilfs_write_inode_common(struct inode *, struct nilfs_inode *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) struct inode *nilfs_ilookup(struct super_block *sb, struct nilfs_root *root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) unsigned long ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct inode *nilfs_iget_locked(struct super_block *sb, struct nilfs_root *root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) unsigned long ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) struct inode *nilfs_iget(struct super_block *sb, struct nilfs_root *root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) unsigned long ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) extern struct inode *nilfs_iget_for_gc(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) unsigned long ino, __u64 cno);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) extern void nilfs_update_inode(struct inode *, struct buffer_head *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) extern void nilfs_truncate(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) extern void nilfs_evict_inode(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) extern int nilfs_setattr(struct dentry *, struct iattr *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) extern void nilfs_write_failed(struct address_space *mapping, loff_t to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) int nilfs_permission(struct inode *inode, int mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) extern int nilfs_inode_dirty(struct inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) int nilfs_set_file_dirty(struct inode *inode, unsigned int nr_dirty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) extern int __nilfs_mark_inode_dirty(struct inode *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) extern void nilfs_dirty_inode(struct inode *, int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) __u64 start, __u64 len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) static inline int nilfs_mark_inode_dirty(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return __nilfs_mark_inode_dirty(inode, I_DIRTY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) static inline int nilfs_mark_inode_dirty_sync(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) return __nilfs_mark_inode_dirty(inode, I_DIRTY_SYNC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) /* super.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) extern struct inode *nilfs_alloc_inode(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) __printf(2, 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) void __nilfs_msg(struct super_block *sb, const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) extern __printf(3, 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) void __nilfs_error(struct super_block *sb, const char *function,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) #ifdef CONFIG_PRINTK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) #define nilfs_msg(sb, level, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) __nilfs_msg(sb, level fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) #define nilfs_error(sb, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) __nilfs_error(sb, __func__, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) #define nilfs_msg(sb, level, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) no_printk(level fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) (void)(sb); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) #define nilfs_error(sb, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) no_printk(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) __nilfs_error(sb, "", " "); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) #endif /* CONFIG_PRINTK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) #define nilfs_crit(sb, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) nilfs_msg(sb, KERN_CRIT, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) #define nilfs_err(sb, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) nilfs_msg(sb, KERN_ERR, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) #define nilfs_warn(sb, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) nilfs_msg(sb, KERN_WARNING, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) #define nilfs_info(sb, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) nilfs_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) extern struct nilfs_super_block *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) extern int nilfs_store_magic_and_option(struct super_block *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) struct nilfs_super_block *, char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) extern int nilfs_check_feature_compatibility(struct super_block *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) struct nilfs_super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) extern void nilfs_set_log_cursor(struct nilfs_super_block *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) struct the_nilfs *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) struct nilfs_super_block **nilfs_prepare_super(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) int flip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) int nilfs_commit_super(struct super_block *sb, int flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) int nilfs_cleanup_super(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) int nilfs_resize_fs(struct super_block *sb, __u64 newsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) struct nilfs_root **root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) /* gcinode.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) int nilfs_gccache_submit_read_data(struct inode *, sector_t, sector_t, __u64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) struct buffer_head **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) int nilfs_gccache_submit_read_node(struct inode *, sector_t, __u64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) struct buffer_head **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) int nilfs_gccache_wait_and_mark_dirty(struct buffer_head *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) int nilfs_init_gcinode(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) void nilfs_remove_all_gcinodes(struct the_nilfs *nilfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) /* sysfs.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) int __init nilfs_sysfs_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) void nilfs_sysfs_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) int nilfs_sysfs_create_device_group(struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) void nilfs_sysfs_delete_device_group(struct the_nilfs *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) int nilfs_sysfs_create_snapshot_group(struct nilfs_root *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) void nilfs_sysfs_delete_snapshot_group(struct nilfs_root *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) * Inodes and files operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) extern const struct file_operations nilfs_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) extern const struct inode_operations nilfs_file_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) extern const struct file_operations nilfs_file_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) extern const struct address_space_operations nilfs_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) extern const struct inode_operations nilfs_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) extern const struct inode_operations nilfs_special_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) extern const struct inode_operations nilfs_symlink_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) * filesystem type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) extern struct file_system_type nilfs_fs_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) #endif /* _NILFS_H */