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

Merge branch 'hpfs' (patches from Mikulas)

Merge hpfs upddate from Mikulas Patocka.

* emailed patches from Mikulas Patocka <mikulas@twibright.com>:
hpfs: update ctime and mtime on directory modification
hpfs: support hotfixes

+100 -21
+33 -6
fs/hpfs/buffer.c
··· 10 10 #include <linux/blkdev.h> 11 11 #include "hpfs_fn.h" 12 12 13 + secno hpfs_search_hotfix_map(struct super_block *s, secno sec) 14 + { 15 + unsigned i; 16 + struct hpfs_sb_info *sbi = hpfs_sb(s); 17 + for (i = 0; unlikely(i < sbi->n_hotfixes); i++) { 18 + if (sbi->hotfix_from[i] == sec) { 19 + return sbi->hotfix_to[i]; 20 + } 21 + } 22 + return sec; 23 + } 24 + 25 + unsigned hpfs_search_hotfix_map_for_range(struct super_block *s, secno sec, unsigned n) 26 + { 27 + unsigned i; 28 + struct hpfs_sb_info *sbi = hpfs_sb(s); 29 + for (i = 0; unlikely(i < sbi->n_hotfixes); i++) { 30 + if (sbi->hotfix_from[i] >= sec && sbi->hotfix_from[i] < sec + n) { 31 + n = sbi->hotfix_from[i] - sec; 32 + } 33 + } 34 + return n; 35 + } 36 + 13 37 void hpfs_prefetch_sectors(struct super_block *s, unsigned secno, int n) 14 38 { 15 39 struct buffer_head *bh; 16 40 struct blk_plug plug; 17 41 18 42 if (n <= 0 || unlikely(secno >= hpfs_sb(s)->sb_fs_size)) 43 + return; 44 + 45 + if (unlikely(hpfs_search_hotfix_map_for_range(s, secno, n) != n)) 19 46 return; 20 47 21 48 bh = sb_find_get_block(s, secno); ··· 78 51 79 52 cond_resched(); 80 53 81 - *bhp = bh = sb_bread(s, secno); 54 + *bhp = bh = sb_bread(s, hpfs_search_hotfix_map(s, secno)); 82 55 if (bh != NULL) 83 56 return bh->b_data; 84 57 else { ··· 98 71 99 72 cond_resched(); 100 73 101 - if ((*bhp = bh = sb_getblk(s, secno)) != NULL) { 74 + if ((*bhp = bh = sb_getblk(s, hpfs_search_hotfix_map(s, secno))) != NULL) { 102 75 if (!buffer_uptodate(bh)) wait_on_buffer(bh); 103 76 set_buffer_uptodate(bh); 104 77 return bh->b_data; ··· 126 99 127 100 hpfs_prefetch_sectors(s, secno, 4 + ahead); 128 101 129 - if (!(qbh->bh[0] = sb_bread(s, secno + 0))) goto bail0; 130 - if (!(qbh->bh[1] = sb_bread(s, secno + 1))) goto bail1; 131 - if (!(qbh->bh[2] = sb_bread(s, secno + 2))) goto bail2; 132 - if (!(qbh->bh[3] = sb_bread(s, secno + 3))) goto bail3; 102 + if (!hpfs_map_sector(s, secno + 0, &qbh->bh[0], 0)) goto bail0; 103 + if (!hpfs_map_sector(s, secno + 1, &qbh->bh[1], 0)) goto bail1; 104 + if (!hpfs_map_sector(s, secno + 2, &qbh->bh[2], 0)) goto bail2; 105 + if (!hpfs_map_sector(s, secno + 3, &qbh->bh[3], 0)) goto bail3; 133 106 134 107 if (likely(qbh->bh[1]->b_data == qbh->bh[0]->b_data + 1 * 512) && 135 108 likely(qbh->bh[2]->b_data == qbh->bh[0]->b_data + 2 * 512) &&
+7 -2
fs/hpfs/file.c
··· 83 83 if (s) { 84 84 if (bh_result->b_size >> 9 < n_secs) 85 85 n_secs = bh_result->b_size >> 9; 86 + n_secs = hpfs_search_hotfix_map_for_range(inode->i_sb, s, n_secs); 87 + if (unlikely(!n_secs)) { 88 + s = hpfs_search_hotfix_map(inode->i_sb, s); 89 + n_secs = 1; 90 + } 86 91 map_bh(bh_result, inode->i_sb, s); 87 92 bh_result->b_size = n_secs << 9; 88 93 goto ret_0; ··· 106 101 inode->i_blocks++; 107 102 hpfs_i(inode)->mmu_private += 512; 108 103 set_buffer_new(bh_result); 109 - map_bh(bh_result, inode->i_sb, s); 104 + map_bh(bh_result, inode->i_sb, hpfs_search_hotfix_map(inode->i_sb, s)); 110 105 ret_0: 111 106 r = 0; 112 107 ret_r: ··· 186 181 187 182 static sector_t _hpfs_bmap(struct address_space *mapping, sector_t block) 188 183 { 189 - return generic_block_bmap(mapping,block,hpfs_get_block); 184 + return generic_block_bmap(mapping, block, hpfs_get_block); 190 185 } 191 186 192 187 const struct address_space_operations hpfs_aops = {
+7
fs/hpfs/hpfs_fn.h
··· 88 88 unsigned sb_max_fwd_alloc; /* max forwad allocation */ 89 89 int sb_timeshift; 90 90 struct rcu_head rcu; 91 + 92 + unsigned n_hotfixes; 93 + secno hotfix_from[256]; 94 + secno hotfix_to[256]; 91 95 }; 92 96 93 97 /* Four 512-byte buffers and the 2k block obtained by concatenating them */ ··· 221 217 222 218 /* buffer.c */ 223 219 220 + secno hpfs_search_hotfix_map(struct super_block *s, secno sec); 221 + unsigned hpfs_search_hotfix_map_for_range(struct super_block *s, secno sec, unsigned n); 224 222 void hpfs_prefetch_sectors(struct super_block *, unsigned, int); 225 223 void *hpfs_map_sector(struct super_block *, unsigned, struct buffer_head **, int); 226 224 void *hpfs_get_sector(struct super_block *, unsigned, struct buffer_head **); ··· 291 285 void hpfs_prefetch_bitmap(struct super_block *, unsigned); 292 286 unsigned char *hpfs_load_code_page(struct super_block *, secno); 293 287 __le32 *hpfs_load_bitmap_directory(struct super_block *, secno bmp); 288 + void hpfs_load_hotfix_map(struct super_block *s, struct hpfs_spare_block *spareblock); 294 289 struct fnode *hpfs_map_fnode(struct super_block *s, ino_t, struct buffer_head **); 295 290 struct anode *hpfs_map_anode(struct super_block *s, anode_secno, struct buffer_head **); 296 291 struct dnode *hpfs_map_dnode(struct super_block *s, dnode_secno, struct quad_buffer_head *);
+26
fs/hpfs/map.c
··· 130 130 return b; 131 131 } 132 132 133 + void hpfs_load_hotfix_map(struct super_block *s, struct hpfs_spare_block *spareblock) 134 + { 135 + struct quad_buffer_head qbh; 136 + u32 *directory; 137 + u32 n_hotfixes, n_used_hotfixes; 138 + unsigned i; 139 + 140 + n_hotfixes = le32_to_cpu(spareblock->n_spares); 141 + n_used_hotfixes = le32_to_cpu(spareblock->n_spares_used); 142 + 143 + if (n_hotfixes > 256 || n_used_hotfixes > n_hotfixes) { 144 + hpfs_error(s, "invalid number of hotfixes: %u, used: %u", n_hotfixes, n_used_hotfixes); 145 + return; 146 + } 147 + if (!(directory = hpfs_map_4sectors(s, le32_to_cpu(spareblock->hotfix_map), &qbh, 0))) { 148 + hpfs_error(s, "can't load hotfix map"); 149 + return; 150 + } 151 + for (i = 0; i < n_used_hotfixes; i++) { 152 + hpfs_sb(s)->hotfix_from[i] = le32_to_cpu(directory[i]); 153 + hpfs_sb(s)->hotfix_to[i] = le32_to_cpu(directory[n_hotfixes + i]); 154 + } 155 + hpfs_sb(s)->n_hotfixes = n_used_hotfixes; 156 + hpfs_brelse4(&qbh); 157 + } 158 + 133 159 /* 134 160 * Load fnode to memory 135 161 */
+24 -1
fs/hpfs/namei.c
··· 8 8 #include <linux/sched.h> 9 9 #include "hpfs_fn.h" 10 10 11 + static void hpfs_update_directory_times(struct inode *dir) 12 + { 13 + time_t t = get_seconds(); 14 + if (t == dir->i_mtime.tv_sec && 15 + t == dir->i_ctime.tv_sec) 16 + return; 17 + dir->i_mtime.tv_sec = dir->i_ctime.tv_sec = t; 18 + dir->i_mtime.tv_nsec = dir->i_ctime.tv_nsec = 0; 19 + hpfs_write_inode_nolock(dir); 20 + } 21 + 11 22 static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) 12 23 { 13 24 const unsigned char *name = dentry->d_name.name; ··· 110 99 result->i_mode = mode | S_IFDIR; 111 100 hpfs_write_inode_nolock(result); 112 101 } 102 + hpfs_update_directory_times(dir); 113 103 d_instantiate(dentry, result); 114 104 hpfs_unlock(dir->i_sb); 115 105 return 0; ··· 199 187 result->i_mode = mode | S_IFREG; 200 188 hpfs_write_inode_nolock(result); 201 189 } 190 + hpfs_update_directory_times(dir); 202 191 d_instantiate(dentry, result); 203 192 hpfs_unlock(dir->i_sb); 204 193 return 0; ··· 275 262 insert_inode_hash(result); 276 263 277 264 hpfs_write_inode_nolock(result); 265 + hpfs_update_directory_times(dir); 278 266 d_instantiate(dentry, result); 279 267 brelse(bh); 280 268 hpfs_unlock(dir->i_sb); ··· 354 340 insert_inode_hash(result); 355 341 356 342 hpfs_write_inode_nolock(result); 343 + hpfs_update_directory_times(dir); 357 344 d_instantiate(dentry, result); 358 345 hpfs_unlock(dir->i_sb); 359 346 return 0; ··· 438 423 out1: 439 424 hpfs_brelse4(&qbh); 440 425 out: 426 + if (!err) 427 + hpfs_update_directory_times(dir); 441 428 hpfs_unlock(dir->i_sb); 442 429 return err; 443 430 } ··· 494 477 out1: 495 478 hpfs_brelse4(&qbh); 496 479 out: 480 + if (!err) 481 + hpfs_update_directory_times(dir); 497 482 hpfs_unlock(dir->i_sb); 498 483 return err; 499 484 } ··· 614 595 goto end1; 615 596 } 616 597 617 - end: 598 + end: 618 599 hpfs_i(i)->i_parent_dir = new_dir->i_ino; 619 600 if (S_ISDIR(i->i_mode)) { 620 601 inc_nlink(new_dir); ··· 629 610 brelse(bh); 630 611 } 631 612 end1: 613 + if (!err) { 614 + hpfs_update_directory_times(old_dir); 615 + hpfs_update_directory_times(new_dir); 616 + } 632 617 hpfs_unlock(i->i_sb); 633 618 return err; 634 619 }
+3 -12
fs/hpfs/super.c
··· 628 628 goto bail4; 629 629 } 630 630 631 + if (spareblock->n_spares_used) 632 + hpfs_load_hotfix_map(s, spareblock); 633 + 631 634 /* Load bitmap directory */ 632 635 if (!(sbi->sb_bmp_dir = hpfs_load_bitmap_directory(s, le32_to_cpu(superblock->bitmaps)))) 633 636 goto bail4; ··· 650 647 mark_buffer_dirty(bh2); 651 648 } 652 649 653 - if (spareblock->hotfixes_used || spareblock->n_spares_used) { 654 - if (errs >= 2) { 655 - pr_err("Hotfixes not supported here, try chkdsk\n"); 656 - mark_dirty(s, 0); 657 - goto bail4; 658 - } 659 - hpfs_error(s, "hotfixes not supported here, try chkdsk"); 660 - if (errs == 0) 661 - pr_err("Proceeding, but your filesystem will be probably corrupted by this driver...\n"); 662 - else 663 - pr_err("This driver may read bad files or crash when operating on disk with hotfixes.\n"); 664 - } 665 650 if (le32_to_cpu(spareblock->n_dnode_spares) != le32_to_cpu(spareblock->n_dnode_spares_free)) { 666 651 if (errs >= 2) { 667 652 pr_err("Spare dnodes used, try chkdsk\n");