nilfs-utils: fsck: add necessary constants and function declarations
PATCH v4 1/15 nilfs-utils: fsck: add necessary constants and function declarations
Hi,
This patch adds several additional constants, function declarations and move useful macro from mkfs.c file into nilfs.h.
With the best regards,
Vyacheslav Dubeyko.
--
From: Vyacheslav Dubeyko <[email protected]>
Subject: [PATCH v4 01/15] nilfs-utils: fsck: add necessary constants and function declarations
This patch adds several additional constants, function declarations and move useful macro from mkfs.c file into nilfs.h.
Signed-off-by Vyacheslav Dubeyko <[email protected]>
--- include/nilfs.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/nilfs2_fs.h | 5 +++++ sbin/mkfs/mkfs.c | 1 - 3 files changed, 60 insertions(+), 1 deletion(-)
include/nilfs.h +55 -0
@@ -87,6 +87,16 @@ typedef __u64 sector_t; // XXX: __u64 ??typedef sector_t nilfs_blkoff_t ;typedef __u64 nilfs_cno_t ; +#ifndef NILFS_FALSE +# define NILFS_FALSE (0) +#endif + +#ifndef NILFS_TRUE +# define NILFS_TRUE (1) +#endif + +#define DEFAULT_SECTOR_SIZE 512 +#define NILFS_FSTYPE "nilfs2"#define NILFS_CNO_MIN ((nilfs_cno_t)1)
@@ -98,6 +108,12 @@ typedef __u64 nilfs_cno_t;#define NILFS_SB_COMMIT_INTERVAL 0x4000#define NILFS_SB_BLOCK_MAX 0x8000 +#define NILFS_PRIMARY_SB_SEG 0 +#define NILFS_SECONDARY_SB_SEG (sb) ((struct nilfs_superblock *)sb->s_nsegments) +#define NILFS_SB_LOG 0 + +#define ROUNDUP_DIV (n, m) (((n) - 1) / (m) + 1) +/** * struct nilfs - nilfs object * @n_sb: superblock
@@ -285,6 +301,11 @@ struct nilfs_super_block *nilfs_sb_read(int devfd);int nilfs_sb_write (int devfd,struct nilfs_super_block *sbp,int mask);int nilfs_read_sb (struct nilfs *); +int nilfs_sb_read_unchecked (int devfd, +struct nilfs_super_block **sbp); +int nilfs_sb_is_valid (int devfd, +struct nilfs_super_block *sbp, +__u64 *check_mask);ssize_t nilfs_get_segment (struct nilfs *,unsigned long ,void **);int nilfs_put_segment (struct nilfs *,void *);
@@ -292,6 +313,11 @@ size_t nilfs_get_block_size(struct nilfs *);__u64 nilfs_get_segment_seqnum (const struct nilfs *,void *,__u64 );__u64 nilfs_get_reserved_segments (const struct nilfs *nilfs); +int nilfs_ss_header_is_valid (__u64 segment, +struct nilfs_super_block *sbp, +struct nilfs_segment_summary *ss_ptr, +__u16 *check_mask); +int nilfs_change_cpmode (struct nilfs *,nilfs_cno_t ,int );ssize_t nilfs_get_cpinfo (struct nilfs *,nilfs_cno_t ,int ,struct nilfs_cpinfo *,size_t );
@@ -319,4 +345,33 @@ static inline __u32 nilfs_get_blocks_per_segment(const struct nilfs *nilfs) return le32_to_cpu(nilfs->n_sb->s_blocks_per_segment); } +/* Convert segment number into start disk block */ +static inline __u64 seg_num_to_start_block (__u64 segment, +struct nilfs_super_block *sbp) +{ +if (0 == segment) +return le64_to_cpu (sbp->s_first_data_block); + +return segment *le32_to_cpu (sbp->s_blocks_per_segment); +} + +static inline __u64 block_to_seg_num (__u64 block, +struct nilfs_super_block *sbp) +{ +return block /le32_to_cpu (sbp->s_blocks_per_segment); +} + +/* +* The population count. +* This is better when most bits in x are 0. +* http://en.wikipedia.org/wiki/Hamming_weight +*/ +static inline int popcount_4 (__u64 x) +{ +int count; +for (count =0 ; x; count++) + x &= x -1 ; +return count; +} +#endif /* NILFS_H */
include/nilfs2_fs.h +5 -0
@@ -124,6 +124,11 @@ struct nilfs_super_root {#define NILFS_RESIZE_FS 0x0004/* Resize required */ /* +* Behavior when detecting errors flags +*/ +#define NILFS_ERRORS_CONTINUE 1/* Continue execution */ + +/* * Mount flags (sbi->s_mount_opt) */ #define NILFS_MOUNT_ERROR_MODE 0x0070/* Error mode mask */
sbin/mkfs/mkfs.c +0 -1
@@ -81,7 +81,6 @@typedef __u64 blocknr_t ;#define BUG_ON (x) assert(!(x)) -#define ROUNDUP_DIV (n,m) (((n) - 1) / (m) + 1)#define max_t (type,x,y) \ ({ type __x = (x); type __y = (y); __x > __y ? __x : __y; })
Signature · 8 lines
1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html