diff options
Diffstat (limited to 'fs/ntfs/inode.c')
| -rw-r--r-- | fs/ntfs/inode.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 4c86b7e1d1eb..933dbd89c2a4 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c | |||
| @@ -137,7 +137,7 @@ static int ntfs_init_locked_inode(struct inode *vi, ntfs_attr *na) | |||
| 137 | 137 | ||
| 138 | BUG_ON(!na->name); | 138 | BUG_ON(!na->name); |
| 139 | i = na->name_len * sizeof(ntfschar); | 139 | i = na->name_len * sizeof(ntfschar); |
| 140 | ni->name = (ntfschar*)kmalloc(i + sizeof(ntfschar), GFP_ATOMIC); | 140 | ni->name = kmalloc(i + sizeof(ntfschar), GFP_ATOMIC); |
| 141 | if (!ni->name) | 141 | if (!ni->name) |
| 142 | return -ENOMEM; | 142 | return -ENOMEM; |
| 143 | memcpy(ni->name, na->name, i); | 143 | memcpy(ni->name, na->name, i); |
| @@ -367,6 +367,12 @@ static void ntfs_destroy_extent_inode(ntfs_inode *ni) | |||
| 367 | kmem_cache_free(ntfs_inode_cache, ni); | 367 | kmem_cache_free(ntfs_inode_cache, ni); |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | /* | ||
| 371 | * The attribute runlist lock has separate locking rules from the | ||
| 372 | * normal runlist lock, so split the two lock-classes: | ||
| 373 | */ | ||
| 374 | static struct lock_class_key attr_list_rl_lock_class; | ||
| 375 | |||
| 370 | /** | 376 | /** |
| 371 | * __ntfs_init_inode - initialize ntfs specific part of an inode | 377 | * __ntfs_init_inode - initialize ntfs specific part of an inode |
| 372 | * @sb: super block of mounted volume | 378 | * @sb: super block of mounted volume |
| @@ -394,6 +400,8 @@ void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni) | |||
| 394 | ni->attr_list_size = 0; | 400 | ni->attr_list_size = 0; |
| 395 | ni->attr_list = NULL; | 401 | ni->attr_list = NULL; |
| 396 | ntfs_init_runlist(&ni->attr_list_rl); | 402 | ntfs_init_runlist(&ni->attr_list_rl); |
| 403 | lockdep_set_class(&ni->attr_list_rl.lock, | ||
| 404 | &attr_list_rl_lock_class); | ||
| 397 | ni->itype.index.bmp_ino = NULL; | 405 | ni->itype.index.bmp_ino = NULL; |
| 398 | ni->itype.index.block_size = 0; | 406 | ni->itype.index.block_size = 0; |
| 399 | ni->itype.index.vcn_size = 0; | 407 | ni->itype.index.vcn_size = 0; |
| @@ -405,6 +413,13 @@ void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni) | |||
| 405 | ni->ext.base_ntfs_ino = NULL; | 413 | ni->ext.base_ntfs_ino = NULL; |
| 406 | } | 414 | } |
| 407 | 415 | ||
| 416 | /* | ||
| 417 | * Extent inodes get MFT-mapped in a nested way, while the base inode | ||
| 418 | * is still mapped. Teach this nesting to the lock validator by creating | ||
| 419 | * a separate class for nested inode's mrec_lock's: | ||
| 420 | */ | ||
| 421 | static struct lock_class_key extent_inode_mrec_lock_key; | ||
| 422 | |||
| 408 | inline ntfs_inode *ntfs_new_extent_inode(struct super_block *sb, | 423 | inline ntfs_inode *ntfs_new_extent_inode(struct super_block *sb, |
| 409 | unsigned long mft_no) | 424 | unsigned long mft_no) |
| 410 | { | 425 | { |
| @@ -413,6 +428,7 @@ inline ntfs_inode *ntfs_new_extent_inode(struct super_block *sb, | |||
| 413 | ntfs_debug("Entering."); | 428 | ntfs_debug("Entering."); |
| 414 | if (likely(ni != NULL)) { | 429 | if (likely(ni != NULL)) { |
| 415 | __ntfs_init_inode(sb, ni); | 430 | __ntfs_init_inode(sb, ni); |
| 431 | lockdep_set_class(&ni->mrec_lock, &extent_inode_mrec_lock_key); | ||
| 416 | ni->mft_no = mft_no; | 432 | ni->mft_no = mft_no; |
| 417 | ni->type = AT_UNUSED; | 433 | ni->type = AT_UNUSED; |
| 418 | ni->name = NULL; | 434 | ni->name = NULL; |
| @@ -540,8 +556,6 @@ static int ntfs_read_locked_inode(struct inode *vi) | |||
| 540 | 556 | ||
| 541 | /* Setup the generic vfs inode parts now. */ | 557 | /* Setup the generic vfs inode parts now. */ |
| 542 | 558 | ||
| 543 | /* This is the optimal IO size (for stat), not the fs block size. */ | ||
| 544 | vi->i_blksize = PAGE_CACHE_SIZE; | ||
| 545 | /* | 559 | /* |
| 546 | * This is for checking whether an inode has changed w.r.t. a file so | 560 | * This is for checking whether an inode has changed w.r.t. a file so |
| 547 | * that the file can be updated if necessary (compare with f_version). | 561 | * that the file can be updated if necessary (compare with f_version). |
| @@ -1218,7 +1232,6 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi) | |||
| 1218 | base_ni = NTFS_I(base_vi); | 1232 | base_ni = NTFS_I(base_vi); |
| 1219 | 1233 | ||
| 1220 | /* Just mirror the values from the base inode. */ | 1234 | /* Just mirror the values from the base inode. */ |
| 1221 | vi->i_blksize = base_vi->i_blksize; | ||
| 1222 | vi->i_version = base_vi->i_version; | 1235 | vi->i_version = base_vi->i_version; |
| 1223 | vi->i_uid = base_vi->i_uid; | 1236 | vi->i_uid = base_vi->i_uid; |
| 1224 | vi->i_gid = base_vi->i_gid; | 1237 | vi->i_gid = base_vi->i_gid; |
| @@ -1488,7 +1501,6 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi) | |||
| 1488 | ni = NTFS_I(vi); | 1501 | ni = NTFS_I(vi); |
| 1489 | base_ni = NTFS_I(base_vi); | 1502 | base_ni = NTFS_I(base_vi); |
| 1490 | /* Just mirror the values from the base inode. */ | 1503 | /* Just mirror the values from the base inode. */ |
| 1491 | vi->i_blksize = base_vi->i_blksize; | ||
| 1492 | vi->i_version = base_vi->i_version; | 1504 | vi->i_version = base_vi->i_version; |
| 1493 | vi->i_uid = base_vi->i_uid; | 1505 | vi->i_uid = base_vi->i_uid; |
| 1494 | vi->i_gid = base_vi->i_gid; | 1506 | vi->i_gid = base_vi->i_gid; |
| @@ -1722,6 +1734,15 @@ err_out: | |||
| 1722 | return err; | 1734 | return err; |
| 1723 | } | 1735 | } |
| 1724 | 1736 | ||
| 1737 | /* | ||
| 1738 | * The MFT inode has special locking, so teach the lock validator | ||
| 1739 | * about this by splitting off the locking rules of the MFT from | ||
| 1740 | * the locking rules of other inodes. The MFT inode can never be | ||
| 1741 | * accessed from the VFS side (or even internally), only by the | ||
| 1742 | * map_mft functions. | ||
| 1743 | */ | ||
| 1744 | static struct lock_class_key mft_ni_runlist_lock_key, mft_ni_mrec_lock_key; | ||
| 1745 | |||
| 1725 | /** | 1746 | /** |
| 1726 | * ntfs_read_inode_mount - special read_inode for mount time use only | 1747 | * ntfs_read_inode_mount - special read_inode for mount time use only |
| 1727 | * @vi: inode to read | 1748 | * @vi: inode to read |
| @@ -2148,6 +2169,14 @@ int ntfs_read_inode_mount(struct inode *vi) | |||
| 2148 | ntfs_attr_put_search_ctx(ctx); | 2169 | ntfs_attr_put_search_ctx(ctx); |
| 2149 | ntfs_debug("Done."); | 2170 | ntfs_debug("Done."); |
| 2150 | ntfs_free(m); | 2171 | ntfs_free(m); |
| 2172 | |||
| 2173 | /* | ||
| 2174 | * Split the locking rules of the MFT inode from the | ||
| 2175 | * locking rules of other inodes: | ||
| 2176 | */ | ||
| 2177 | lockdep_set_class(&ni->runlist.lock, &mft_ni_runlist_lock_key); | ||
| 2178 | lockdep_set_class(&ni->mrec_lock, &mft_ni_mrec_lock_key); | ||
| 2179 | |||
| 2151 | return 0; | 2180 | return 0; |
| 2152 | 2181 | ||
| 2153 | em_put_err_out: | 2182 | em_put_err_out: |
