Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nilfs2: move ioctl interface and disk layout to uapi separately

The header file "include/linux/nilfs2_fs.h" is composed of parts for
ioctl and disk format, and both are intended to be shared with user
space programs.

This moves them to the uapi directory "include/uapi/linux" splitting the
file to "nilfs2_api.h" and "nilfs2_ondisk.h". The following minor
changes are accompanied by this migration:

- nilfs_direct_node struct in nilfs2/direct.h is converged to
nilfs2_ondisk.h because it's an on-disk structure.
- inline functions nilfs_rec_len_from_disk() and
nilfs_rec_len_to_disk() are moved to nilfs2/dir.c.

Link: http://lkml.kernel.org/r/1465825507-3407-4-git-send-email-konishi.ryusuke@lab.ntt.co.jp
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ryusuke Konishi and committed by
Linus Torvalds
e63e88bc 4ce5c342

+348 -329
+2 -1
Documentation/filesystems/nilfs2.txt
··· 267 267 `-- file (ino=yy) 268 268 ( regular file, directory, or symlink ) 269 269 270 - For detail on the format of each file, please see include/linux/nilfs2_fs.h. 270 + For detail on the format of each file, please see nilfs2_ondisk.h 271 + located at include/uapi/linux directory. 271 272 272 273 There are no patents or other intellectual property that we protect 273 274 with regard to the design of NILFS2. It is allowed to replicate the
+1 -1
Documentation/ioctl/ioctl-number.txt
··· 248 248 'm' 00 drivers/scsi/megaraid/megaraid_ioctl.h conflict! 249 249 'm' 00-1F net/irda/irmod.h conflict! 250 250 'n' 00-7F linux/ncp_fs.h and fs/ncpfs/ioctl.c 251 - 'n' 80-8F linux/nilfs2_fs.h NILFS2 251 + 'n' 80-8F uapi/linux/nilfs2_api.h NILFS2 252 252 'n' E0-FF linux/matroxfb.h matroxfb 253 253 'o' 00-1F fs/ocfs2/ocfs2_fs.h OCFS2 254 254 'o' 00-03 mtd/ubi-user.h conflict! (OCFS2 and UBI overlaps)
+2 -1
MAINTAINERS
··· 8258 8258 S: Supported 8259 8259 F: Documentation/filesystems/nilfs2.txt 8260 8260 F: fs/nilfs2/ 8261 - F: include/linux/nilfs2_fs.h 8262 8261 F: include/trace/events/nilfs2.h 8262 + F: include/uapi/linux/nilfs2_api.h 8263 + F: include/uapi/linux/nilfs2_ondisk.h 8263 8264 8264 8265 NINJA SCSI-3 / NINJA SCSI-32Bi (16bit/CardBus) PCMCIA SCSI HOST ADAPTER DRIVER 8265 8266 M: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
+1 -1
fs/nilfs2/bmap.h
··· 22 22 #include <linux/types.h> 23 23 #include <linux/fs.h> 24 24 #include <linux/buffer_head.h> 25 - #include <linux/nilfs2_fs.h> 25 + #include <linux/nilfs2_ondisk.h> /* nilfs_binfo, nilfs_inode, etc */ 26 26 #include "alloc.h" 27 27 #include "dat.h" 28 28
+1 -1
fs/nilfs2/btree.h
··· 22 22 #include <linux/types.h> 23 23 #include <linux/buffer_head.h> 24 24 #include <linux/list.h> 25 - #include <linux/nilfs2_fs.h> 25 + #include <linux/nilfs2_ondisk.h> /* nilfs_btree_node */ 26 26 #include "btnode.h" 27 27 #include "bmap.h" 28 28
-1
fs/nilfs2/cpfile.c
··· 21 21 #include <linux/string.h> 22 22 #include <linux/buffer_head.h> 23 23 #include <linux/errno.h> 24 - #include <linux/nilfs2_fs.h> 25 24 #include "mdt.h" 26 25 #include "cpfile.h" 27 26
+2 -1
fs/nilfs2/cpfile.h
··· 21 21 22 22 #include <linux/fs.h> 23 23 #include <linux/buffer_head.h> 24 - #include <linux/nilfs2_fs.h> 24 + #include <linux/nilfs2_api.h> /* nilfs_cpstat */ 25 + #include <linux/nilfs2_ondisk.h> /* nilfs_inode, nilfs_checkpoint */ 25 26 26 27 27 28 int nilfs_cpfile_get_checkpoint(struct inode *, __u64, int,
+1
fs/nilfs2/dat.h
··· 22 22 #include <linux/types.h> 23 23 #include <linux/buffer_head.h> 24 24 #include <linux/fs.h> 25 + #include <linux/nilfs2_ondisk.h> /* nilfs_inode, nilfs_checkpoint */ 25 26 26 27 27 28 struct nilfs_palloc_req;
+22
fs/nilfs2/dir.c
··· 42 42 #include "nilfs.h" 43 43 #include "page.h" 44 44 45 + static inline unsigned int nilfs_rec_len_from_disk(__le16 dlen) 46 + { 47 + unsigned int len = le16_to_cpu(dlen); 48 + 49 + #if (PAGE_SIZE >= 65536) 50 + if (len == NILFS_MAX_REC_LEN) 51 + return 1 << 16; 52 + #endif 53 + return len; 54 + } 55 + 56 + static inline __le16 nilfs_rec_len_to_disk(unsigned int len) 57 + { 58 + #if (PAGE_SIZE >= 65536) 59 + if (len == (1 << 16)) 60 + return cpu_to_le16(NILFS_MAX_REC_LEN); 61 + 62 + BUG_ON(len > (1 << 16)); 63 + #endif 64 + return cpu_to_le16(len); 65 + } 66 + 45 67 /* 46 68 * nilfs uses block-sized chunks. Arguably, sector-sized ones would be 47 69 * more robust, but we have what we have
-10
fs/nilfs2/direct.h
··· 24 24 #include "bmap.h" 25 25 26 26 27 - /** 28 - * struct nilfs_direct_node - direct node 29 - * @dn_flags: flags 30 - * @dn_pad: padding 31 - */ 32 - struct nilfs_direct_node { 33 - __u8 dn_flags; 34 - __u8 pad[7]; 35 - }; 36 - 37 27 #define NILFS_DIRECT_NBLOCKS (NILFS_BMAP_SIZE / sizeof(__le64) - 1) 38 28 #define NILFS_DIRECT_KEY_MIN 0 39 29 #define NILFS_DIRECT_KEY_MAX (NILFS_DIRECT_NBLOCKS - 1)
-1
fs/nilfs2/ifile.h
··· 23 23 24 24 #include <linux/fs.h> 25 25 #include <linux/buffer_head.h> 26 - #include <linux/nilfs2_fs.h> 27 26 #include "mdt.h" 28 27 #include "alloc.h" 29 28
-1
fs/nilfs2/ioctl.c
··· 25 25 #include <linux/compat.h> /* compat_ptr() */ 26 26 #include <linux/mount.h> /* mnt_want_write_file(), mnt_drop_write_file() */ 27 27 #include <linux/buffer_head.h> 28 - #include <linux/nilfs2_fs.h> 29 28 #include "nilfs.h" 30 29 #include "segment.h" 31 30 #include "bmap.h"
+2 -1
fs/nilfs2/nilfs.h
··· 23 23 #include <linux/buffer_head.h> 24 24 #include <linux/spinlock.h> 25 25 #include <linux/blkdev.h> 26 - #include <linux/nilfs2_fs.h> 26 + #include <linux/nilfs2_api.h> 27 + #include <linux/nilfs2_ondisk.h> 27 28 #include "the_nilfs.h" 28 29 #include "bmap.h" 29 30
-1
fs/nilfs2/segment.h
··· 23 23 #include <linux/fs.h> 24 24 #include <linux/buffer_head.h> 25 25 #include <linux/workqueue.h> 26 - #include <linux/nilfs2_fs.h> 27 26 #include "nilfs.h" 28 27 29 28 struct nilfs_root;
-1
fs/nilfs2/sufile.c
··· 22 22 #include <linux/string.h> 23 23 #include <linux/buffer_head.h> 24 24 #include <linux/errno.h> 25 - #include <linux/nilfs2_fs.h> 26 25 #include "mdt.h" 27 26 #include "sufile.h" 28 27
-1
fs/nilfs2/sufile.h
··· 21 21 22 22 #include <linux/fs.h> 23 23 #include <linux/buffer_head.h> 24 - #include <linux/nilfs2_fs.h> 25 24 #include "mdt.h" 26 25 27 26
+22 -306
include/linux/nilfs2_fs.h include/uapi/linux/nilfs2_ondisk.h
··· 1 1 /* 2 - * nilfs2_fs.h - NILFS2 on-disk structures and common declarations. 2 + * nilfs2_ondisk.h - NILFS2 on-disk structures 3 3 * 4 4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 5 * ··· 7 7 * it under the terms of the GNU Lesser General Public License as published 8 8 * by the Free Software Foundation; either version 2.1 of the License, or 9 9 * (at your option) any later version. 10 - * 11 - * This program is distributed in the hope that it will be useful, 12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 - * GNU Lesser General Public License for more details. 15 - * 16 - * Written by Koji Sato and Ryusuke Konishi. 17 10 */ 18 11 /* 19 12 * linux/include/linux/ext2_fs.h ··· 23 30 * Copyright (C) 1991, 1992 Linus Torvalds 24 31 */ 25 32 26 - #ifndef _LINUX_NILFS_FS_H 27 - #define _LINUX_NILFS_FS_H 33 + #ifndef _LINUX_NILFS2_ONDISK_H 34 + #define _LINUX_NILFS2_ONDISK_H 28 35 29 36 #include <linux/types.h> 30 - #include <linux/ioctl.h> 31 37 #include <linux/magic.h> 32 - #include <linux/bug.h> 33 38 34 39 35 40 #define NILFS_INODE_BMAP_SIZE 7 41 + 36 42 /** 37 43 * struct nilfs_inode - structure of an inode on disk 38 44 * @i_blocks: blocks count ··· 48 56 * @i_bmap: block mapping 49 57 * @i_xattr: extended attributes 50 58 * @i_generation: file generation (for NFS) 51 - * @i_pad: padding 59 + * @i_pad: padding 52 60 */ 53 61 struct nilfs_inode { 54 62 __le64 i_blocks; ··· 330 338 #define NILFS_DIR_ROUND (NILFS_DIR_PAD - 1) 331 339 #define NILFS_DIR_REC_LEN(name_len) (((name_len) + 12 + NILFS_DIR_ROUND) & \ 332 340 ~NILFS_DIR_ROUND) 333 - #define NILFS_MAX_REC_LEN ((1<<16)-1) 334 - 335 - static inline unsigned int nilfs_rec_len_from_disk(__le16 dlen) 336 - { 337 - unsigned int len = le16_to_cpu(dlen); 338 - 339 - #if !defined(__KERNEL__) || (PAGE_SIZE >= 65536) 340 - if (len == NILFS_MAX_REC_LEN) 341 - return 1 << 16; 342 - #endif 343 - return len; 344 - } 345 - 346 - static inline __le16 nilfs_rec_len_to_disk(unsigned int len) 347 - { 348 - #if !defined(__KERNEL__) || (PAGE_SIZE >= 65536) 349 - if (len == (1 << 16)) 350 - return cpu_to_le16(NILFS_MAX_REC_LEN); 351 - else if (len > (1 << 16)) 352 - BUG(); 353 - #endif 354 - return cpu_to_le16(len); 355 - } 341 + #define NILFS_MAX_REC_LEN ((1 << 16) - 1) 356 342 357 343 /** 358 344 * struct nilfs_finfo - file information ··· 344 374 __le64 fi_cno; 345 375 __le32 fi_nblocks; 346 376 __le32 fi_ndatablk; 347 - /* array of virtual block numbers */ 348 377 }; 349 378 350 379 /** 351 - * struct nilfs_binfo_v - information for the block to which a virtual block number is assigned 380 + * struct nilfs_binfo_v - information on a data block (except DAT) 352 381 * @bi_vblocknr: virtual block number 353 382 * @bi_blkoff: block offset 354 383 */ ··· 357 388 }; 358 389 359 390 /** 360 - * struct nilfs_binfo_dat - information for the block which belongs to the DAT file 391 + * struct nilfs_binfo_dat - information on a DAT node block 361 392 * @bi_blkoff: block offset 362 393 * @bi_level: level 363 394 * @bi_pad: padding ··· 423 454 #define NILFS_SS_GC 0x0010 /* segment written for cleaner operation */ 424 455 425 456 /** 426 - * struct nilfs_btree_node - B-tree node 457 + * struct nilfs_btree_node - header of B-tree node block 427 458 * @bn_flags: flags 428 459 * @bn_level: level 429 460 * @bn_nchildren: number of children ··· 443 474 #define NILFS_BTREE_LEVEL_DATA 0 444 475 #define NILFS_BTREE_LEVEL_NODE_MIN (NILFS_BTREE_LEVEL_DATA + 1) 445 476 #define NILFS_BTREE_LEVEL_MAX 14 /* Max level (exclusive) */ 477 + 478 + /** 479 + * struct nilfs_direct_node - header of built-in bmap array 480 + * @dn_flags: flags 481 + * @dn_pad: padding 482 + */ 483 + struct nilfs_direct_node { 484 + __u8 dn_flags; 485 + __u8 pad[7]; 486 + }; 446 487 447 488 /** 448 489 * struct nilfs_palloc_group_desc - block group descriptor ··· 553 574 NILFS_CHECKPOINT_FNS(MINOR, minor) 554 575 555 576 /** 556 - * struct nilfs_cpinfo - checkpoint information 557 - * @ci_flags: flags 558 - * @ci_pad: padding 559 - * @ci_cno: checkpoint number 560 - * @ci_create: creation timestamp 561 - * @ci_nblk_inc: number of blocks incremented by this checkpoint 562 - * @ci_inodes_count: inodes count 563 - * @ci_blocks_count: blocks count 564 - * @ci_next: next checkpoint number in snapshot list 565 - */ 566 - struct nilfs_cpinfo { 567 - __u32 ci_flags; 568 - __u32 ci_pad; 569 - __u64 ci_cno; 570 - __u64 ci_create; 571 - __u64 ci_nblk_inc; 572 - __u64 ci_inodes_count; 573 - __u64 ci_blocks_count; 574 - __u64 ci_next; 575 - }; 576 - 577 - #define NILFS_CPINFO_FNS(flag, name) \ 578 - static inline int \ 579 - nilfs_cpinfo_##name(const struct nilfs_cpinfo *cpinfo) \ 580 - { \ 581 - return !!(cpinfo->ci_flags & (1UL << NILFS_CHECKPOINT_##flag)); \ 582 - } 583 - 584 - NILFS_CPINFO_FNS(SNAPSHOT, snapshot) 585 - NILFS_CPINFO_FNS(INVALID, invalid) 586 - NILFS_CPINFO_FNS(MINOR, minor) 587 - 588 - 589 - /** 590 577 * struct nilfs_cpfile_header - checkpoint file header 591 578 * @ch_ncheckpoints: number of checkpoints 592 579 * @ch_nsnapshots: number of snapshots ··· 564 619 struct nilfs_snapshot_list ch_snapshot_list; 565 620 }; 566 621 567 - #define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET \ 622 + #define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET \ 568 623 ((sizeof(struct nilfs_cpfile_header) + \ 569 624 sizeof(struct nilfs_checkpoint) - 1) / \ 570 625 sizeof(struct nilfs_checkpoint)) ··· 588 643 NILFS_SEGMENT_USAGE_ACTIVE, 589 644 NILFS_SEGMENT_USAGE_DIRTY, 590 645 NILFS_SEGMENT_USAGE_ERROR, 591 - 592 - /* ... */ 593 646 }; 594 647 595 648 #define NILFS_SEGMENT_USAGE_FNS(flag, name) \ ··· 642 699 /* ... */ 643 700 }; 644 701 645 - #define NILFS_SUFILE_FIRST_SEGMENT_USAGE_OFFSET \ 702 + #define NILFS_SUFILE_FIRST_SEGMENT_USAGE_OFFSET \ 646 703 ((sizeof(struct nilfs_sufile_header) + \ 647 704 sizeof(struct nilfs_segment_usage) - 1) / \ 648 705 sizeof(struct nilfs_segment_usage)) 649 706 650 - /** 651 - * nilfs_suinfo - segment usage information 652 - * @sui_lastmod: timestamp of last modification 653 - * @sui_nblocks: number of written blocks in segment 654 - * @sui_flags: segment usage flags 655 - */ 656 - struct nilfs_suinfo { 657 - __u64 sui_lastmod; 658 - __u32 sui_nblocks; 659 - __u32 sui_flags; 660 - }; 661 - 662 - #define NILFS_SUINFO_FNS(flag, name) \ 663 - static inline int \ 664 - nilfs_suinfo_##name(const struct nilfs_suinfo *si) \ 665 - { \ 666 - return si->sui_flags & (1UL << NILFS_SEGMENT_USAGE_##flag); \ 667 - } 668 - 669 - NILFS_SUINFO_FNS(ACTIVE, active) 670 - NILFS_SUINFO_FNS(DIRTY, dirty) 671 - NILFS_SUINFO_FNS(ERROR, error) 672 - 673 - static inline int nilfs_suinfo_clean(const struct nilfs_suinfo *si) 674 - { 675 - return !si->sui_flags; 676 - } 677 - 678 - /* ioctl */ 679 - /** 680 - * nilfs_suinfo_update - segment usage information update 681 - * @sup_segnum: segment number 682 - * @sup_flags: flags for which fields are active in sup_sui 683 - * @sup_reserved: reserved necessary for alignment 684 - * @sup_sui: segment usage information 685 - */ 686 - struct nilfs_suinfo_update { 687 - __u64 sup_segnum; 688 - __u32 sup_flags; 689 - __u32 sup_reserved; 690 - struct nilfs_suinfo sup_sui; 691 - }; 692 - 693 - enum { 694 - NILFS_SUINFO_UPDATE_LASTMOD, 695 - NILFS_SUINFO_UPDATE_NBLOCKS, 696 - NILFS_SUINFO_UPDATE_FLAGS, 697 - __NR_NILFS_SUINFO_UPDATE_FIELDS, 698 - }; 699 - 700 - #define NILFS_SUINFO_UPDATE_FNS(flag, name) \ 701 - static inline void \ 702 - nilfs_suinfo_update_set_##name(struct nilfs_suinfo_update *sup) \ 703 - { \ 704 - sup->sup_flags |= 1UL << NILFS_SUINFO_UPDATE_##flag; \ 705 - } \ 706 - static inline void \ 707 - nilfs_suinfo_update_clear_##name(struct nilfs_suinfo_update *sup) \ 708 - { \ 709 - sup->sup_flags &= ~(1UL << NILFS_SUINFO_UPDATE_##flag); \ 710 - } \ 711 - static inline int \ 712 - nilfs_suinfo_update_##name(const struct nilfs_suinfo_update *sup) \ 713 - { \ 714 - return !!(sup->sup_flags & (1UL << NILFS_SUINFO_UPDATE_##flag));\ 715 - } 716 - 717 - NILFS_SUINFO_UPDATE_FNS(LASTMOD, lastmod) 718 - NILFS_SUINFO_UPDATE_FNS(NBLOCKS, nblocks) 719 - NILFS_SUINFO_UPDATE_FNS(FLAGS, flags) 720 - 721 - enum { 722 - NILFS_CHECKPOINT, 723 - NILFS_SNAPSHOT, 724 - }; 725 - 726 - /** 727 - * struct nilfs_cpmode - change checkpoint mode structure 728 - * @cm_cno: checkpoint number 729 - * @cm_mode: mode of checkpoint 730 - * @cm_pad: padding 731 - */ 732 - struct nilfs_cpmode { 733 - __u64 cm_cno; 734 - __u32 cm_mode; 735 - __u32 cm_pad; 736 - }; 737 - 738 - /** 739 - * struct nilfs_argv - argument vector 740 - * @v_base: pointer on data array from userspace 741 - * @v_nmembs: number of members in data array 742 - * @v_size: size of data array in bytes 743 - * @v_flags: flags 744 - * @v_index: start number of target data items 745 - */ 746 - struct nilfs_argv { 747 - __u64 v_base; 748 - __u32 v_nmembs; /* number of members */ 749 - __u16 v_size; /* size of members */ 750 - __u16 v_flags; 751 - __u64 v_index; 752 - }; 753 - 754 - /** 755 - * struct nilfs_period - period of checkpoint numbers 756 - * @p_start: start checkpoint number (inclusive) 757 - * @p_end: end checkpoint number (exclusive) 758 - */ 759 - struct nilfs_period { 760 - __u64 p_start; 761 - __u64 p_end; 762 - }; 763 - 764 - /** 765 - * struct nilfs_cpstat - checkpoint statistics 766 - * @cs_cno: checkpoint number 767 - * @cs_ncps: number of checkpoints 768 - * @cs_nsss: number of snapshots 769 - */ 770 - struct nilfs_cpstat { 771 - __u64 cs_cno; 772 - __u64 cs_ncps; 773 - __u64 cs_nsss; 774 - }; 775 - 776 - /** 777 - * struct nilfs_sustat - segment usage statistics 778 - * @ss_nsegs: number of segments 779 - * @ss_ncleansegs: number of clean segments 780 - * @ss_ndirtysegs: number of dirty segments 781 - * @ss_ctime: creation time of the last segment 782 - * @ss_nongc_ctime: creation time of the last segment not for GC 783 - * @ss_prot_seq: least sequence number of segments which must not be reclaimed 784 - */ 785 - struct nilfs_sustat { 786 - __u64 ss_nsegs; 787 - __u64 ss_ncleansegs; 788 - __u64 ss_ndirtysegs; 789 - __u64 ss_ctime; 790 - __u64 ss_nongc_ctime; 791 - __u64 ss_prot_seq; 792 - }; 793 - 794 - /** 795 - * struct nilfs_vinfo - virtual block number information 796 - * @vi_vblocknr: virtual block number 797 - * @vi_start: start checkpoint number (inclusive) 798 - * @vi_end: end checkpoint number (exclusive) 799 - * @vi_blocknr: disk block number 800 - */ 801 - struct nilfs_vinfo { 802 - __u64 vi_vblocknr; 803 - __u64 vi_start; 804 - __u64 vi_end; 805 - __u64 vi_blocknr; 806 - }; 807 - 808 - /** 809 - * struct nilfs_vdesc - descriptor of virtual block number 810 - * @vd_ino: inode number 811 - * @vd_cno: checkpoint number 812 - * @vd_vblocknr: virtual block number 813 - * @vd_period: period of checkpoint numbers 814 - * @vd_blocknr: disk block number 815 - * @vd_offset: logical block offset inside a file 816 - * @vd_flags: flags (data or node block) 817 - * @vd_pad: padding 818 - */ 819 - struct nilfs_vdesc { 820 - __u64 vd_ino; 821 - __u64 vd_cno; 822 - __u64 vd_vblocknr; 823 - struct nilfs_period vd_period; 824 - __u64 vd_blocknr; 825 - __u64 vd_offset; 826 - __u32 vd_flags; 827 - __u32 vd_pad; 828 - }; 829 - 830 - /** 831 - * struct nilfs_bdesc - descriptor of disk block number 832 - * @bd_ino: inode number 833 - * @bd_oblocknr: disk block address (for skipping dead blocks) 834 - * @bd_blocknr: disk block address 835 - * @bd_offset: logical block offset inside a file 836 - * @bd_level: level in the b-tree organization 837 - * @bd_pad: padding 838 - */ 839 - struct nilfs_bdesc { 840 - __u64 bd_ino; 841 - __u64 bd_oblocknr; 842 - __u64 bd_blocknr; 843 - __u64 bd_offset; 844 - __u32 bd_level; 845 - __u32 bd_pad; 846 - }; 847 - 848 - #define NILFS_IOCTL_IDENT 'n' 849 - 850 - #define NILFS_IOCTL_CHANGE_CPMODE \ 851 - _IOW(NILFS_IOCTL_IDENT, 0x80, struct nilfs_cpmode) 852 - #define NILFS_IOCTL_DELETE_CHECKPOINT \ 853 - _IOW(NILFS_IOCTL_IDENT, 0x81, __u64) 854 - #define NILFS_IOCTL_GET_CPINFO \ 855 - _IOR(NILFS_IOCTL_IDENT, 0x82, struct nilfs_argv) 856 - #define NILFS_IOCTL_GET_CPSTAT \ 857 - _IOR(NILFS_IOCTL_IDENT, 0x83, struct nilfs_cpstat) 858 - #define NILFS_IOCTL_GET_SUINFO \ 859 - _IOR(NILFS_IOCTL_IDENT, 0x84, struct nilfs_argv) 860 - #define NILFS_IOCTL_GET_SUSTAT \ 861 - _IOR(NILFS_IOCTL_IDENT, 0x85, struct nilfs_sustat) 862 - #define NILFS_IOCTL_GET_VINFO \ 863 - _IOWR(NILFS_IOCTL_IDENT, 0x86, struct nilfs_argv) 864 - #define NILFS_IOCTL_GET_BDESCS \ 865 - _IOWR(NILFS_IOCTL_IDENT, 0x87, struct nilfs_argv) 866 - #define NILFS_IOCTL_CLEAN_SEGMENTS \ 867 - _IOW(NILFS_IOCTL_IDENT, 0x88, struct nilfs_argv[5]) 868 - #define NILFS_IOCTL_SYNC \ 869 - _IOR(NILFS_IOCTL_IDENT, 0x8A, __u64) 870 - #define NILFS_IOCTL_RESIZE \ 871 - _IOW(NILFS_IOCTL_IDENT, 0x8B, __u64) 872 - #define NILFS_IOCTL_SET_ALLOC_RANGE \ 873 - _IOW(NILFS_IOCTL_IDENT, 0x8C, __u64[2]) 874 - #define NILFS_IOCTL_SET_SUINFO \ 875 - _IOW(NILFS_IOCTL_IDENT, 0x8D, struct nilfs_argv) 876 - 877 - #endif /* _LINUX_NILFS_FS_H */ 707 + #endif /* _LINUX_NILFS2_ONDISK_H */
+292
include/uapi/linux/nilfs2_api.h
··· 1 + /* 2 + * nilfs2_api.h - NILFS2 user space API 3 + * 4 + * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU Lesser General Public License as published 8 + * by the Free Software Foundation; either version 2.1 of the License, or 9 + * (at your option) any later version. 10 + */ 11 + 12 + #ifndef _LINUX_NILFS2_API_H 13 + #define _LINUX_NILFS2_API_H 14 + 15 + #include <linux/types.h> 16 + #include <linux/ioctl.h> 17 + 18 + /** 19 + * struct nilfs_cpinfo - checkpoint information 20 + * @ci_flags: flags 21 + * @ci_pad: padding 22 + * @ci_cno: checkpoint number 23 + * @ci_create: creation timestamp 24 + * @ci_nblk_inc: number of blocks incremented by this checkpoint 25 + * @ci_inodes_count: inodes count 26 + * @ci_blocks_count: blocks count 27 + * @ci_next: next checkpoint number in snapshot list 28 + */ 29 + struct nilfs_cpinfo { 30 + __u32 ci_flags; 31 + __u32 ci_pad; 32 + __u64 ci_cno; 33 + __u64 ci_create; 34 + __u64 ci_nblk_inc; 35 + __u64 ci_inodes_count; 36 + __u64 ci_blocks_count; 37 + __u64 ci_next; 38 + }; 39 + 40 + /* checkpoint flags */ 41 + enum { 42 + NILFS_CPINFO_SNAPSHOT, 43 + NILFS_CPINFO_INVALID, 44 + NILFS_CPINFO_SKETCH, 45 + NILFS_CPINFO_MINOR, 46 + }; 47 + 48 + #define NILFS_CPINFO_FNS(flag, name) \ 49 + static inline int \ 50 + nilfs_cpinfo_##name(const struct nilfs_cpinfo *cpinfo) \ 51 + { \ 52 + return !!(cpinfo->ci_flags & (1UL << NILFS_CPINFO_##flag)); \ 53 + } 54 + 55 + NILFS_CPINFO_FNS(SNAPSHOT, snapshot) 56 + NILFS_CPINFO_FNS(INVALID, invalid) 57 + NILFS_CPINFO_FNS(MINOR, minor) 58 + 59 + /** 60 + * nilfs_suinfo - segment usage information 61 + * @sui_lastmod: timestamp of last modification 62 + * @sui_nblocks: number of written blocks in segment 63 + * @sui_flags: segment usage flags 64 + */ 65 + struct nilfs_suinfo { 66 + __u64 sui_lastmod; 67 + __u32 sui_nblocks; 68 + __u32 sui_flags; 69 + }; 70 + 71 + /* segment usage flags */ 72 + enum { 73 + NILFS_SUINFO_ACTIVE, 74 + NILFS_SUINFO_DIRTY, 75 + NILFS_SUINFO_ERROR, 76 + }; 77 + 78 + #define NILFS_SUINFO_FNS(flag, name) \ 79 + static inline int \ 80 + nilfs_suinfo_##name(const struct nilfs_suinfo *si) \ 81 + { \ 82 + return si->sui_flags & (1UL << NILFS_SUINFO_##flag); \ 83 + } 84 + 85 + NILFS_SUINFO_FNS(ACTIVE, active) 86 + NILFS_SUINFO_FNS(DIRTY, dirty) 87 + NILFS_SUINFO_FNS(ERROR, error) 88 + 89 + static inline int nilfs_suinfo_clean(const struct nilfs_suinfo *si) 90 + { 91 + return !si->sui_flags; 92 + } 93 + 94 + /** 95 + * nilfs_suinfo_update - segment usage information update 96 + * @sup_segnum: segment number 97 + * @sup_flags: flags for which fields are active in sup_sui 98 + * @sup_reserved: reserved necessary for alignment 99 + * @sup_sui: segment usage information 100 + */ 101 + struct nilfs_suinfo_update { 102 + __u64 sup_segnum; 103 + __u32 sup_flags; 104 + __u32 sup_reserved; 105 + struct nilfs_suinfo sup_sui; 106 + }; 107 + 108 + enum { 109 + NILFS_SUINFO_UPDATE_LASTMOD, 110 + NILFS_SUINFO_UPDATE_NBLOCKS, 111 + NILFS_SUINFO_UPDATE_FLAGS, 112 + __NR_NILFS_SUINFO_UPDATE_FIELDS, 113 + }; 114 + 115 + #define NILFS_SUINFO_UPDATE_FNS(flag, name) \ 116 + static inline void \ 117 + nilfs_suinfo_update_set_##name(struct nilfs_suinfo_update *sup) \ 118 + { \ 119 + sup->sup_flags |= 1UL << NILFS_SUINFO_UPDATE_##flag; \ 120 + } \ 121 + static inline void \ 122 + nilfs_suinfo_update_clear_##name(struct nilfs_suinfo_update *sup) \ 123 + { \ 124 + sup->sup_flags &= ~(1UL << NILFS_SUINFO_UPDATE_##flag); \ 125 + } \ 126 + static inline int \ 127 + nilfs_suinfo_update_##name(const struct nilfs_suinfo_update *sup) \ 128 + { \ 129 + return !!(sup->sup_flags & (1UL << NILFS_SUINFO_UPDATE_##flag));\ 130 + } 131 + 132 + NILFS_SUINFO_UPDATE_FNS(LASTMOD, lastmod) 133 + NILFS_SUINFO_UPDATE_FNS(NBLOCKS, nblocks) 134 + NILFS_SUINFO_UPDATE_FNS(FLAGS, flags) 135 + 136 + enum { 137 + NILFS_CHECKPOINT, 138 + NILFS_SNAPSHOT, 139 + }; 140 + 141 + /** 142 + * struct nilfs_cpmode - change checkpoint mode structure 143 + * @cm_cno: checkpoint number 144 + * @cm_mode: mode of checkpoint 145 + * @cm_pad: padding 146 + */ 147 + struct nilfs_cpmode { 148 + __u64 cm_cno; 149 + __u32 cm_mode; 150 + __u32 cm_pad; 151 + }; 152 + 153 + /** 154 + * struct nilfs_argv - argument vector 155 + * @v_base: pointer on data array from userspace 156 + * @v_nmembs: number of members in data array 157 + * @v_size: size of data array in bytes 158 + * @v_flags: flags 159 + * @v_index: start number of target data items 160 + */ 161 + struct nilfs_argv { 162 + __u64 v_base; 163 + __u32 v_nmembs; /* number of members */ 164 + __u16 v_size; /* size of members */ 165 + __u16 v_flags; 166 + __u64 v_index; 167 + }; 168 + 169 + /** 170 + * struct nilfs_period - period of checkpoint numbers 171 + * @p_start: start checkpoint number (inclusive) 172 + * @p_end: end checkpoint number (exclusive) 173 + */ 174 + struct nilfs_period { 175 + __u64 p_start; 176 + __u64 p_end; 177 + }; 178 + 179 + /** 180 + * struct nilfs_cpstat - checkpoint statistics 181 + * @cs_cno: checkpoint number 182 + * @cs_ncps: number of checkpoints 183 + * @cs_nsss: number of snapshots 184 + */ 185 + struct nilfs_cpstat { 186 + __u64 cs_cno; 187 + __u64 cs_ncps; 188 + __u64 cs_nsss; 189 + }; 190 + 191 + /** 192 + * struct nilfs_sustat - segment usage statistics 193 + * @ss_nsegs: number of segments 194 + * @ss_ncleansegs: number of clean segments 195 + * @ss_ndirtysegs: number of dirty segments 196 + * @ss_ctime: creation time of the last segment 197 + * @ss_nongc_ctime: creation time of the last segment not for GC 198 + * @ss_prot_seq: least sequence number of segments which must not be reclaimed 199 + */ 200 + struct nilfs_sustat { 201 + __u64 ss_nsegs; 202 + __u64 ss_ncleansegs; 203 + __u64 ss_ndirtysegs; 204 + __u64 ss_ctime; 205 + __u64 ss_nongc_ctime; 206 + __u64 ss_prot_seq; 207 + }; 208 + 209 + /** 210 + * struct nilfs_vinfo - virtual block number information 211 + * @vi_vblocknr: virtual block number 212 + * @vi_start: start checkpoint number (inclusive) 213 + * @vi_end: end checkpoint number (exclusive) 214 + * @vi_blocknr: disk block number 215 + */ 216 + struct nilfs_vinfo { 217 + __u64 vi_vblocknr; 218 + __u64 vi_start; 219 + __u64 vi_end; 220 + __u64 vi_blocknr; 221 + }; 222 + 223 + /** 224 + * struct nilfs_vdesc - descriptor of virtual block number 225 + * @vd_ino: inode number 226 + * @vd_cno: checkpoint number 227 + * @vd_vblocknr: virtual block number 228 + * @vd_period: period of checkpoint numbers 229 + * @vd_blocknr: disk block number 230 + * @vd_offset: logical block offset inside a file 231 + * @vd_flags: flags (data or node block) 232 + * @vd_pad: padding 233 + */ 234 + struct nilfs_vdesc { 235 + __u64 vd_ino; 236 + __u64 vd_cno; 237 + __u64 vd_vblocknr; 238 + struct nilfs_period vd_period; 239 + __u64 vd_blocknr; 240 + __u64 vd_offset; 241 + __u32 vd_flags; 242 + __u32 vd_pad; 243 + }; 244 + 245 + /** 246 + * struct nilfs_bdesc - descriptor of disk block number 247 + * @bd_ino: inode number 248 + * @bd_oblocknr: disk block address (for skipping dead blocks) 249 + * @bd_blocknr: disk block address 250 + * @bd_offset: logical block offset inside a file 251 + * @bd_level: level in the b-tree organization 252 + * @bd_pad: padding 253 + */ 254 + struct nilfs_bdesc { 255 + __u64 bd_ino; 256 + __u64 bd_oblocknr; 257 + __u64 bd_blocknr; 258 + __u64 bd_offset; 259 + __u32 bd_level; 260 + __u32 bd_pad; 261 + }; 262 + 263 + #define NILFS_IOCTL_IDENT 'n' 264 + 265 + #define NILFS_IOCTL_CHANGE_CPMODE \ 266 + _IOW(NILFS_IOCTL_IDENT, 0x80, struct nilfs_cpmode) 267 + #define NILFS_IOCTL_DELETE_CHECKPOINT \ 268 + _IOW(NILFS_IOCTL_IDENT, 0x81, __u64) 269 + #define NILFS_IOCTL_GET_CPINFO \ 270 + _IOR(NILFS_IOCTL_IDENT, 0x82, struct nilfs_argv) 271 + #define NILFS_IOCTL_GET_CPSTAT \ 272 + _IOR(NILFS_IOCTL_IDENT, 0x83, struct nilfs_cpstat) 273 + #define NILFS_IOCTL_GET_SUINFO \ 274 + _IOR(NILFS_IOCTL_IDENT, 0x84, struct nilfs_argv) 275 + #define NILFS_IOCTL_GET_SUSTAT \ 276 + _IOR(NILFS_IOCTL_IDENT, 0x85, struct nilfs_sustat) 277 + #define NILFS_IOCTL_GET_VINFO \ 278 + _IOWR(NILFS_IOCTL_IDENT, 0x86, struct nilfs_argv) 279 + #define NILFS_IOCTL_GET_BDESCS \ 280 + _IOWR(NILFS_IOCTL_IDENT, 0x87, struct nilfs_argv) 281 + #define NILFS_IOCTL_CLEAN_SEGMENTS \ 282 + _IOW(NILFS_IOCTL_IDENT, 0x88, struct nilfs_argv[5]) 283 + #define NILFS_IOCTL_SYNC \ 284 + _IOR(NILFS_IOCTL_IDENT, 0x8A, __u64) 285 + #define NILFS_IOCTL_RESIZE \ 286 + _IOW(NILFS_IOCTL_IDENT, 0x8B, __u64) 287 + #define NILFS_IOCTL_SET_ALLOC_RANGE \ 288 + _IOW(NILFS_IOCTL_IDENT, 0x8C, __u64[2]) 289 + #define NILFS_IOCTL_SET_SUINFO \ 290 + _IOW(NILFS_IOCTL_IDENT, 0x8D, struct nilfs_argv) 291 + 292 + #endif /* _LINUX_NILFS2_API_H */