minix-v3-support.patch
Quoted 3 lines · Andrew Morton
Quoted 3 lines
Daniel, it'd be good if you could review and test these changes please.
Also, a signed-off-by from yourself and from Andries, please...
Thanks a lot to Andries! The patch looks much more elegant now than before. And it continues performing well, as before.
---
fs/minix/bitmap.c | 69 +++++++++------ fs/minix/dir.c | 162 +++++++++++++++++++++++++------------ fs/minix/inode.c | 49 ++++++++--- fs/minix/itree_common.c | 16 ++- fs/minix/itree_v1.c | 4 fs/minix/itree_v2.c | 7 - fs/minix/minix.h | 12 -- include/linux/magic.h | 1 include/linux/minix_fs.h | 25 +++++ 9 files changed, 233 insertions(+), 112 deletions(-)
fs/minix/bitmap.c renamed from fs/minix/bitmap.c~minix-v3-support +40 -29
@@ -26,14 +26,14 @@ static unsigned long count_free(struct bfor (i=0 ; i<numblocks-1 ; i++) {if (!(bh=map[i]))return (0 ); -for (j=0 ; j<BLOCK_SIZE ; j++) +for (j=0 ; j<bh->b_size; j++) sum += nibblemap[bh->b_data[j] &0xf ] + nibblemap[(bh->b_data[j]>>4 ) &0xf ]; }if (numblocks==0 || !(bh=map[numblocks-1 ]))return (0 ); - i = ((numbits-(numblocks-1 )*BLOCK_SIZE *8 )/16 )*2 ; + i = ((numbits - (numblocks-1 ) * bh->b_size *8 ) /16 ) *2 ;for (j=0 ; j<i; j++) { sum += nibblemap[bh->b_data[j] &0xf ] + nibblemap[(bh->b_data[j]>>4 ) &0xf ];
@@ -48,28 +48,29 @@ static unsigned long count_free(struct breturn (sum); } -void minix_free_block (struct inode * inode,int block) +void minix_free_block (struct inode *inode,unsigned long block) { -struct super_block * sb = inode->i_sb; -struct minix_sb_info * sbi =minix_sb (sb); -struct buffer_head * bh; -unsigned int bit,zone; +struct super_block *sb = inode->i_sb; +struct minix_sb_info *sbi =minix_sb (sb); +struct buffer_head *bh; +int k = sb->s_blocksize_bits +3 ; +unsigned long bit, zone;if (block < sbi->s_firstdatazone || block >= sbi->s_nzones) {printk ("Trying to free block not in datazone\n" );return ; } zone = block - sbi->s_firstdatazone +1 ; - bit = zone &8191 ; - zone >>=13 ; + bit = zone & ((1 <<k) -1 ); + zone >>= k;if (zone >= sbi->s_zmap_blocks) {printk ("minix_free_block: nonexistent bitmap buffer\n" );return ; } bh = sbi->s_zmap[zone];lock_kernel (); -if (!minix_test_and_clear_bit (bit,bh->b_data)) -printk ("free_block (%s:%d): bit already cleared\n" , +if (!minix_test_and_clear_bit (bit, bh->b_data)) +printk ("minix_free_block (%s:%lu): bit already cleared\n" , sb->s_id, block);unlock_kernel ();mark_buffer_dirty (bh);
@@ -79,6 +80,7 @@ void minix_free_block(struct inode * inoint minix_new_block (struct inode * inode) {struct minix_sb_info *sbi =minix_sb (inode->i_sb); +int bits_per_zone =8 * inode->i_sb->s_blocksize;int i;for (i =0 ; i < sbi->s_zmap_blocks; i++) {
@@ -86,11 +88,12 @@ int minix_new_block(struct inode * inodeint j;lock_kernel (); -if ((j =minix_find_first_zero_bit (bh->b_data,8192 )) <8192 ) { -minix_set_bit (j,bh->b_data); + j =minix_find_first_zero_bit (bh->b_data, bits_per_zone); +if (j < bits_per_zone) { +minix_set_bit (j, bh->b_data);unlock_kernel ();mark_buffer_dirty (bh); - j += i*8192 + sbi->s_firstdatazone-1 ; + j += i * bits_per_zone + sbi->s_firstdatazone-1 ;if (j < sbi->s_firstdatazone || j >= sbi->s_nzones)break ;return j;
@@ -137,6 +140,7 @@ minix_V2_raw_inode(struct super_block *sint block;struct minix_sb_info *sbi =minix_sb (sb);struct minix2_inode *p; +int minix2_inodes_per_block = sb->s_blocksize /sizeof (struct minix2_inode ); *bh =NULL ;if (!ino || ino > sbi->s_ninodes) {
@@ -146,14 +150,14 @@ minix_V2_raw_inode(struct super_block *s } ino--; block =2 + sbi->s_imap_blocks + sbi->s_zmap_blocks + - ino /MINIX2_INODES_PER_BLOCK ; + ino / minix2_inodes_per_block; *bh =sb_bread (sb, block);if (!*bh) {printk ("Unable to read inode block\n" );return NULL ; } p = (void *)(*bh)->b_data; -return p + ino %MINIX2_INODES_PER_BLOCK ; +return p + ino % minix2_inodes_per_block; }/* Clear the link count and mode of a deleted inode on disk. */
@@ -185,26 +189,30 @@ static void minix_clear_inode(struct inovoid minix_free_inode (struct inode * inode) { +struct super_block *sb = inode->i_sb;struct minix_sb_info *sbi =minix_sb (inode->i_sb); -struct buffer_head * bh; -unsigned long ino; +struct buffer_head *bh; +int k = sb->s_blocksize_bits +3 ; +unsigned long ino, bit; ino = inode->i_ino;if (ino <1 || ino > sbi->s_ninodes) {printk ("minix_free_inode: inode 0 or nonexistent inode\n" ); goto out; } -if ((ino >>13 ) >= sbi->s_imap_blocks) { + bit = ino & ((1 <<k) -1 ); + ino >>= k; +if (ino >= sbi->s_imap_blocks) {printk ("minix_free_inode: nonexistent imap in superblock\n" ); goto out; }minix_clear_inode (inode);/* clear on-disk copy */ - bh = sbi->s_imap[ino >>13 ]; + bh = sbi->s_imap[ino];lock_kernel (); -if (!minix_test_and_clear_bit (ino &8191 , bh->b_data)) -printk ("minix_free_inode: bit %lu already cleared\n" , ino); +if (!minix_test_and_clear_bit (bit, bh->b_data)) +printk ("minix_free_inode: bit %lu already cleared\n" , bit);unlock_kernel ();mark_buffer_dirty (bh); out:
@@ -217,35 +225,38 @@ struct inode * minix_new_inode(const strstruct minix_sb_info *sbi =minix_sb (sb);struct inode *inode =new_inode (sb);struct buffer_head * bh; -int i,j; +int bits_per_zone =8 * sb->s_blocksize; +unsigned long j; +int i;if (!inode) { *error = -ENOMEM ;return NULL ; } - j =8192 ; + j = bits_per_zone; bh =NULL ; *error = -ENOSPC ;lock_kernel ();for (i =0 ; i < sbi->s_imap_blocks; i++) { bh = sbi->s_imap[i]; -if ((j =minix_find_first_zero_bit (bh->b_data,8192 )) <8192 ) + j =minix_find_first_zero_bit (bh->b_data, bits_per_zone); +if (j < bits_per_zone)break ; } -if (!bh || j >=8192 ) { +if (!bh || j >= bits_per_zone) {unlock_kernel ();iput (inode);return NULL ; } -if (minix_test_and_set_bit (j,bh->b_data)) {/* shouldn't happen */ -printk ("new_inode: bit already set\n" ); +if (minix_test_and_set_bit (j, bh->b_data)) {/* shouldn't happen */ unlock_kernel (); +printk ("minix_new_inode: bit already set\n" );iput (inode);return NULL ; }unlock_kernel ();mark_buffer_dirty (bh); - j += i*8192 ; + j += i * bits_per_zone;if (!j || j > sbi->s_ninodes) {iput (inode);return NULL ;
fs/minix/dir.c renamed from fs/minix/dir.c~minix-v3-support +111 -51
281 lines not on this page · raw message
fs/minix/inode.c renamed from fs/minix/inode.c~minix-v3-support +38 -11
103 lines not on this page · raw message
fs/minix/itree_common.c renamed from fs/minix/itree_common.c~minix-v3-support +9 -7
@@ -23,7 +23,7 @@ static inline int verify_chain(Indirectstatic inline block_t *block_end (struct buffer_head *bh) { -return (block_t *)((char *)bh->b_data +BLOCK_SIZE ); +return (block_t *)((char *)bh->b_data + bh->b_size); } static inline Indirect *get_branch(struct inode *inode,
@@ -85,7 +85,7 @@ static int alloc_branch(struct inode *in branch[n].key =cpu_to_block (nr); bh =sb_getblk (inode->i_sb, parent);lock_buffer (bh); -memset (bh->b_data,0 ,BLOCK_SIZE ); +memset (bh->b_data,0 , bh->b_size); branch[n].bh = bh; branch[n].p = (block_t *) bh->b_data + offsets[n]; *branch[n].p = branch[n].key;
@@ -292,6 +292,7 @@ static void free_branches(struct inode *static inline void truncate (struct inode * inode) { +struct super_block *sb = inode->i_sb;block_t *idata =i_data (inode);int offsets[DEPTH ];Indirect chain[DEPTH ];
@@ -301,7 +302,7 @@ static inline void truncate (struct inodint first_whole;long iblock; - iblock = (inode->i_size +BLOCK_SIZE -1 ) >>10 ; + iblock = (inode->i_size + sb->s_blocksize -1 ) >> sb->s_blocksize_bits;block_truncate_page (inode->i_mapping, inode->i_size, get_block); n =block_to_path (inode, iblock, offsets);
@@ -346,15 +347,16 @@ do_indirects:mark_inode_dirty (inode); } -static inline unsigned nblocks (loff_t size) +static inline unsigned nblocks (loff_t size,struct super_block *sb) { +int k = sb->s_blocksize_bits -10 ;unsigned blocks, res, direct =DIRECT , i =DEPTH ; - blocks = (size +BLOCK_SIZE -1 ) >>BLOCK_SIZE_BITS ; + blocks = (size + sb->s_blocksize -1 ) >> (BLOCK_SIZE_BITS + k); res = blocks;while (--i && blocks > direct) { blocks -= direct; - blocks +=BLOCK_SIZE /sizeof (block_t) -1 ; - blocks /=BLOCK_SIZE /sizeof (block_t); + blocks += sb->s_blocksize/sizeof (block_t) -1 ; + blocks /= sb->s_blocksize/sizeof (block_t); res += blocks; direct =1 ; }
fs/minix/itree_v1.c renamed from fs/minix/itree_v1.c~minix-v3-support +2 -2
@@ -55,7 +55,7 @@ void V1_minix_truncate(struct inode * intruncate (inode); } -unsigned V1_minix_blocks (loff_t size) +unsigned V1_minix_blocks (loff_t size,struct super_block *sb) { -return nblocks (size); +return nblocks (size, sb); }
fs/minix/itree_v2.c renamed from fs/minix/itree_v2.c~minix-v3-support +4 -3
@@ -23,10 +23,11 @@ static inline block_t *i_data(struct inostatic int block_to_path (struct inode * inode,long block,int offsets[DEPTH ]) {int n =0 ; +struct super_block *sb = inode->i_sb;if (block <0 ) {printk ("minix_bmap: block<0\n" ); - }else if (block >= (minix_sb (inode->i_sb)->s_max_size/BLOCK_SIZE )) { + }else if (block >= (minix_sb (inode->i_sb)->s_max_size/sb->s_blocksize)) {printk ("minix_bmap: block>big\n" ); }else if (block <7 ) { offsets[n++] = block;
@@ -60,7 +61,7 @@ void V2_minix_truncate(struct inode * intruncate (inode); } -unsigned V2_minix_blocks (loff_t size) +unsigned V2_minix_blocks (loff_t size,struct super_block *sb) { -return nblocks (size); +return nblocks (size, sb); }
fs/minix/minix.h renamed from fs/minix/minix.h~minix-v3-support +4 -8
@@ -7,11 +7,10 @@* truncated. Else they will be disallowed (ENAMETOOLONG). */ #define NO_TRUNCATE 1 -#define INODE_VERSION (inode) minix_sb(inode->i_sb)->s_version -#define MINIX_V1 0x0001/* original minix fs */ #define MINIX_V2 0x0002/* minix V2 fs */ +#define MINIX_V3 0x0003/* minix V3 fs */ /* * minix fs inode data in memory
@@ -52,12 +51,10 @@ extern struct inode * minix_new_inode(coextern void minix_free_inode (struct inode * inode);extern unsigned long minix_count_free_inodes (struct minix_sb_info *sbi);extern int minix_new_block (struct inode * inode); -extern void minix_free_block (struct inode * inode,int block); +extern void minix_free_block (struct inode *inode,unsigned long block);extern unsigned long minix_count_free_blocks (struct minix_sb_info *sbi); -extern int minix_getattr (struct vfsmount *,struct dentry *,struct kstat *); -extern void V2_minix_truncate (struct inode *);extern void V1_minix_truncate (struct inode *);extern void V2_minix_truncate (struct inode *);extern void minix_truncate (struct inode *);
@@ -65,8 +62,8 @@ extern int minix_sync_inode(struct inodeextern void minix_set_inode (struct inode *,dev_t );extern int V1_minix_get_block (struct inode *,long ,struct buffer_head *,int );extern int V2_minix_get_block (struct inode *,long ,struct buffer_head *,int ); -extern unsigned V1_minix_blocks (loff_t ); -extern unsigned V2_minix_blocks (loff_t ); +extern unsigned V1_minix_blocks (loff_t ,struct super_block *); +extern unsigned V2_minix_blocks (loff_t ,struct super_block *);extern struct minix_dir_entry *minix_find_entry (struct dentry *,struct page **);extern int minix_add_link (struct dentry *,struct inode *);
@@ -76,7 +73,6 @@ extern int minix_empty_dir(struct inode*extern void minix_set_link (struct minix_dir_entry *,struct page *,struct inode *);extern struct minix_dir_entry *minix_dotdot (struct inode *,struct page **);extern ino_t minix_inode_by_name (struct dentry *); -extern int minix_sync_file (struct file *,struct dentry *,int );extern struct inode_operations minix_file_inode_operations;
include/linux/magic.h renamed from include/linux/magic.h~minix-v3-support +1 -0
@@ -18,6 +18,7 @@#define MINIX_SUPER_MAGIC2 0x138F/* minix fs, 30 char names */ #define MINIX2_SUPER_MAGIC 0x2468/* minix V2 fs */ #define MINIX2_SUPER_MAGIC2 0x2478/* minix V2 fs, 30 char names */ +#define MINIX3_SUPER_MAGIC 0x4d5a/* minix V3 fs */ #define MSDOS_SUPER_MAGIC 0x4d44/* MD */ #define NCP_SUPER_MAGIC 0x564c/* Guess, what 0x564c is :-) */
include/linux/minix_fs.h renamed from include/linux/minix_fs.h~minix-v3-support +24 -1
@@ -25,7 +25,6 @@#define MINIX_ERROR_FS 0x0002/* fs has errors. */ #define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode))) -#define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode)))/* * This is the original minix inode layout on disk.
@@ -75,9 +74,33 @@ struct minix_super_block { __u32 s_zones; }; +/* +* V3 minix super-block data on disk +*/ +struct minix3_super_block { +__u16 s_ninodes; +__u16 s_nzones; +__u16 s_pad0; +__u16 s_imap_blocks; +__u16 s_zmap_blocks; +__u16 s_firstdatazone; +__u16 s_log_zone_size; +__u16 s_pad1; +__u32 s_max_size; +__u32 s_zones; +__u16 s_magic; +__u16 s_pad2; +__u16 s_blocksize; +__u8 s_disk_version; +}; +struct minix_dir_entry {__u16 inode;char name[0 ]; }; +struct minix3_dir_entry { +__u32 inode; +char name[0 ]; +};#endif
---
minix-v3-support.patch
Quoted 4 lines · Daniel Aragonés
On Mon, Jan 08, 2007 at 04:06:53PM -0800, Andrew Morton wrote:
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Daniel, it'd be good if you could review and test these changes please.
Also, a signed-off-by from yourself and from Andries, please...
Thanks a lot to Andries! The patch looks much more elegant now than before. And it continues performing well, as before.
Signed-off-by Daniel Aragones <[email protected]>
While you guys are hacking on minix stuff, is anyone interested in looking at http://bugzilla.kernel.org/show_bug.cgi?id=7758 ?
Thanks,
Daniel