diff options
Diffstat (limited to 'fs/ntfs')
| -rw-r--r-- | fs/ntfs/aops.c | 4 | ||||
| -rw-r--r-- | fs/ntfs/dir.c | 5 | ||||
| -rw-r--r-- | fs/ntfs/file.c | 26 | ||||
| -rw-r--r-- | fs/ntfs/inode.c | 39 | ||||
| -rw-r--r-- | fs/ntfs/mft.c | 9 | ||||
| -rw-r--r-- | fs/ntfs/ntfs.h | 4 | ||||
| -rw-r--r-- | fs/ntfs/super.c | 59 | ||||
| -rw-r--r-- | fs/ntfs/sysctl.h | 1 | ||||
| -rw-r--r-- | fs/ntfs/unistr.c | 4 |
9 files changed, 94 insertions, 57 deletions
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 580412d330cb..bc579bfdfbd8 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c | |||
| @@ -1544,7 +1544,7 @@ err_out: | |||
| 1544 | /** | 1544 | /** |
| 1545 | * ntfs_aops - general address space operations for inodes and attributes | 1545 | * ntfs_aops - general address space operations for inodes and attributes |
| 1546 | */ | 1546 | */ |
| 1547 | struct address_space_operations ntfs_aops = { | 1547 | const struct address_space_operations ntfs_aops = { |
| 1548 | .readpage = ntfs_readpage, /* Fill page with data. */ | 1548 | .readpage = ntfs_readpage, /* Fill page with data. */ |
| 1549 | .sync_page = block_sync_page, /* Currently, just unplugs the | 1549 | .sync_page = block_sync_page, /* Currently, just unplugs the |
| 1550 | disk request queue. */ | 1550 | disk request queue. */ |
| @@ -1560,7 +1560,7 @@ struct address_space_operations ntfs_aops = { | |||
| 1560 | * ntfs_mst_aops - general address space operations for mst protecteed inodes | 1560 | * ntfs_mst_aops - general address space operations for mst protecteed inodes |
| 1561 | * and attributes | 1561 | * and attributes |
| 1562 | */ | 1562 | */ |
| 1563 | struct address_space_operations ntfs_mst_aops = { | 1563 | const struct address_space_operations ntfs_mst_aops = { |
| 1564 | .readpage = ntfs_readpage, /* Fill page with data. */ | 1564 | .readpage = ntfs_readpage, /* Fill page with data. */ |
| 1565 | .sync_page = block_sync_page, /* Currently, just unplugs the | 1565 | .sync_page = block_sync_page, /* Currently, just unplugs the |
| 1566 | disk request queue. */ | 1566 | disk request queue. */ |
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c index d1e2c6f9f05e..85c36b8ca452 100644 --- a/fs/ntfs/dir.c +++ b/fs/ntfs/dir.c | |||
| @@ -1149,8 +1149,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
| 1149 | * Allocate a buffer to store the current name being processed | 1149 | * Allocate a buffer to store the current name being processed |
| 1150 | * converted to format determined by current NLS. | 1150 | * converted to format determined by current NLS. |
| 1151 | */ | 1151 | */ |
| 1152 | name = (u8*)kmalloc(NTFS_MAX_NAME_LEN * NLS_MAX_CHARSET_SIZE + 1, | 1152 | name = kmalloc(NTFS_MAX_NAME_LEN * NLS_MAX_CHARSET_SIZE + 1, GFP_NOFS); |
| 1153 | GFP_NOFS); | ||
| 1154 | if (unlikely(!name)) { | 1153 | if (unlikely(!name)) { |
| 1155 | err = -ENOMEM; | 1154 | err = -ENOMEM; |
| 1156 | goto err_out; | 1155 | goto err_out; |
| @@ -1191,7 +1190,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
| 1191 | * map the mft record without deadlocking. | 1190 | * map the mft record without deadlocking. |
| 1192 | */ | 1191 | */ |
| 1193 | rc = le32_to_cpu(ctx->attr->data.resident.value_length); | 1192 | rc = le32_to_cpu(ctx->attr->data.resident.value_length); |
| 1194 | ir = (INDEX_ROOT*)kmalloc(rc, GFP_NOFS); | 1193 | ir = kmalloc(rc, GFP_NOFS); |
| 1195 | if (unlikely(!ir)) { | 1194 | if (unlikely(!ir)) { |
| 1196 | err = -ENOMEM; | 1195 | err = -ENOMEM; |
| 1197 | goto err_out; | 1196 | goto err_out; |
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index 88292f9e4b9b..2e42c2dcae12 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c | |||
| @@ -1358,7 +1358,7 @@ err_out: | |||
| 1358 | goto out; | 1358 | goto out; |
| 1359 | } | 1359 | } |
| 1360 | 1360 | ||
| 1361 | static size_t __ntfs_copy_from_user_iovec(char *vaddr, | 1361 | static size_t __ntfs_copy_from_user_iovec_inatomic(char *vaddr, |
| 1362 | const struct iovec *iov, size_t iov_ofs, size_t bytes) | 1362 | const struct iovec *iov, size_t iov_ofs, size_t bytes) |
| 1363 | { | 1363 | { |
| 1364 | size_t total = 0; | 1364 | size_t total = 0; |
| @@ -1376,10 +1376,6 @@ static size_t __ntfs_copy_from_user_iovec(char *vaddr, | |||
| 1376 | bytes -= len; | 1376 | bytes -= len; |
| 1377 | vaddr += len; | 1377 | vaddr += len; |
| 1378 | if (unlikely(left)) { | 1378 | if (unlikely(left)) { |
| 1379 | /* | ||
| 1380 | * Zero the rest of the target like __copy_from_user(). | ||
| 1381 | */ | ||
| 1382 | memset(vaddr, 0, bytes); | ||
| 1383 | total -= left; | 1379 | total -= left; |
| 1384 | break; | 1380 | break; |
| 1385 | } | 1381 | } |
| @@ -1420,11 +1416,13 @@ static inline void ntfs_set_next_iovec(const struct iovec **iovp, | |||
| 1420 | * pages (out to offset + bytes), to emulate ntfs_copy_from_user()'s | 1416 | * pages (out to offset + bytes), to emulate ntfs_copy_from_user()'s |
| 1421 | * single-segment behaviour. | 1417 | * single-segment behaviour. |
| 1422 | * | 1418 | * |
| 1423 | * We call the same helper (__ntfs_copy_from_user_iovec()) both when atomic and | 1419 | * We call the same helper (__ntfs_copy_from_user_iovec_inatomic()) both |
| 1424 | * when not atomic. This is ok because __ntfs_copy_from_user_iovec() calls | 1420 | * when atomic and when not atomic. This is ok because |
| 1425 | * __copy_from_user_inatomic() and it is ok to call this when non-atomic. In | 1421 | * __ntfs_copy_from_user_iovec_inatomic() calls __copy_from_user_inatomic() |
| 1426 | * fact, the only difference between __copy_from_user_inatomic() and | 1422 | * and it is ok to call this when non-atomic. |
| 1427 | * __copy_from_user() is that the latter calls might_sleep(). And on many | 1423 | * Infact, the only difference between __copy_from_user_inatomic() and |
| 1424 | * __copy_from_user() is that the latter calls might_sleep() and the former | ||
| 1425 | * should not zero the tail of the buffer on error. And on many | ||
| 1428 | * architectures __copy_from_user_inatomic() is just defined to | 1426 | * architectures __copy_from_user_inatomic() is just defined to |
| 1429 | * __copy_from_user() so it makes no difference at all on those architectures. | 1427 | * __copy_from_user() so it makes no difference at all on those architectures. |
| 1430 | */ | 1428 | */ |
| @@ -1441,14 +1439,18 @@ static inline size_t ntfs_copy_from_user_iovec(struct page **pages, | |||
| 1441 | if (len > bytes) | 1439 | if (len > bytes) |
| 1442 | len = bytes; | 1440 | len = bytes; |
| 1443 | kaddr = kmap_atomic(*pages, KM_USER0); | 1441 | kaddr = kmap_atomic(*pages, KM_USER0); |
| 1444 | copied = __ntfs_copy_from_user_iovec(kaddr + ofs, | 1442 | copied = __ntfs_copy_from_user_iovec_inatomic(kaddr + ofs, |
| 1445 | *iov, *iov_ofs, len); | 1443 | *iov, *iov_ofs, len); |
| 1446 | kunmap_atomic(kaddr, KM_USER0); | 1444 | kunmap_atomic(kaddr, KM_USER0); |
| 1447 | if (unlikely(copied != len)) { | 1445 | if (unlikely(copied != len)) { |
| 1448 | /* Do it the slow way. */ | 1446 | /* Do it the slow way. */ |
| 1449 | kaddr = kmap(*pages); | 1447 | kaddr = kmap(*pages); |
| 1450 | copied = __ntfs_copy_from_user_iovec(kaddr + ofs, | 1448 | copied = __ntfs_copy_from_user_iovec_inatomic(kaddr + ofs, |
| 1451 | *iov, *iov_ofs, len); | 1449 | *iov, *iov_ofs, len); |
| 1450 | /* | ||
| 1451 | * Zero the rest of the target like __copy_from_user(). | ||
| 1452 | */ | ||
| 1453 | memset(kaddr + ofs + copied, 0, len - copied); | ||
| 1452 | kunmap(*pages); | 1454 | kunmap(*pages); |
| 1453 | if (unlikely(copied != len)) | 1455 | if (unlikely(copied != len)) |
| 1454 | goto err_out; | 1456 | goto err_out; |
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: |
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 2438c00ec0ce..584260fd6848 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c | |||
| @@ -331,7 +331,7 @@ map_err_out: | |||
| 331 | ntfs_inode **tmp; | 331 | ntfs_inode **tmp; |
| 332 | int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode *); | 332 | int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode *); |
| 333 | 333 | ||
| 334 | tmp = (ntfs_inode **)kmalloc(new_size, GFP_NOFS); | 334 | tmp = kmalloc(new_size, GFP_NOFS); |
| 335 | if (unlikely(!tmp)) { | 335 | if (unlikely(!tmp)) { |
| 336 | ntfs_error(base_ni->vol->sb, "Failed to allocate " | 336 | ntfs_error(base_ni->vol->sb, "Failed to allocate " |
| 337 | "internal buffer."); | 337 | "internal buffer."); |
| @@ -2638,11 +2638,6 @@ mft_rec_already_initialized: | |||
| 2638 | } | 2638 | } |
| 2639 | vi->i_ino = bit; | 2639 | vi->i_ino = bit; |
| 2640 | /* | 2640 | /* |
| 2641 | * This is the optimal IO size (for stat), not the fs block | ||
| 2642 | * size. | ||
| 2643 | */ | ||
| 2644 | vi->i_blksize = PAGE_CACHE_SIZE; | ||
| 2645 | /* | ||
| 2646 | * This is for checking whether an inode has changed w.r.t. a | 2641 | * This is for checking whether an inode has changed w.r.t. a |
| 2647 | * file so that the file can be updated if necessary (compare | 2642 | * file so that the file can be updated if necessary (compare |
| 2648 | * with f_version). | 2643 | * with f_version). |
| @@ -2893,7 +2888,7 @@ rollback: | |||
| 2893 | if (!(base_ni->nr_extents & 3)) { | 2888 | if (!(base_ni->nr_extents & 3)) { |
| 2894 | int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode*); | 2889 | int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode*); |
| 2895 | 2890 | ||
| 2896 | extent_nis = (ntfs_inode**)kmalloc(new_size, GFP_NOFS); | 2891 | extent_nis = kmalloc(new_size, GFP_NOFS); |
| 2897 | if (unlikely(!extent_nis)) { | 2892 | if (unlikely(!extent_nis)) { |
| 2898 | ntfs_error(vol->sb, "Failed to allocate internal " | 2893 | ntfs_error(vol->sb, "Failed to allocate internal " |
| 2899 | "buffer during rollback.%s", es); | 2894 | "buffer during rollback.%s", es); |
diff --git a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h index bf7b3d7c0930..ddd3d503097c 100644 --- a/fs/ntfs/ntfs.h +++ b/fs/ntfs/ntfs.h | |||
| @@ -57,8 +57,8 @@ extern struct kmem_cache *ntfs_attr_ctx_cache; | |||
| 57 | extern struct kmem_cache *ntfs_index_ctx_cache; | 57 | extern struct kmem_cache *ntfs_index_ctx_cache; |
| 58 | 58 | ||
| 59 | /* The various operations structs defined throughout the driver files. */ | 59 | /* The various operations structs defined throughout the driver files. */ |
| 60 | extern struct address_space_operations ntfs_aops; | 60 | extern const struct address_space_operations ntfs_aops; |
| 61 | extern struct address_space_operations ntfs_mst_aops; | 61 | extern const struct address_space_operations ntfs_mst_aops; |
| 62 | 62 | ||
| 63 | extern const struct file_operations ntfs_file_ops; | 63 | extern const struct file_operations ntfs_file_ops; |
| 64 | extern struct inode_operations ntfs_file_inode_ops; | 64 | extern struct inode_operations ntfs_file_inode_ops; |
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 0e14acea3f8b..6b2712f10dd2 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c | |||
| @@ -1724,6 +1724,14 @@ upcase_failed: | |||
| 1724 | return FALSE; | 1724 | return FALSE; |
| 1725 | } | 1725 | } |
| 1726 | 1726 | ||
| 1727 | /* | ||
| 1728 | * The lcn and mft bitmap inodes are NTFS-internal inodes with | ||
| 1729 | * their own special locking rules: | ||
| 1730 | */ | ||
| 1731 | static struct lock_class_key | ||
| 1732 | lcnbmp_runlist_lock_key, lcnbmp_mrec_lock_key, | ||
| 1733 | mftbmp_runlist_lock_key, mftbmp_mrec_lock_key; | ||
| 1734 | |||
| 1727 | /** | 1735 | /** |
| 1728 | * load_system_files - open the system files using normal functions | 1736 | * load_system_files - open the system files using normal functions |
| 1729 | * @vol: ntfs super block describing device whose system files to load | 1737 | * @vol: ntfs super block describing device whose system files to load |
| @@ -1780,6 +1788,10 @@ static BOOL load_system_files(ntfs_volume *vol) | |||
| 1780 | ntfs_error(sb, "Failed to load $MFT/$BITMAP attribute."); | 1788 | ntfs_error(sb, "Failed to load $MFT/$BITMAP attribute."); |
| 1781 | goto iput_mirr_err_out; | 1789 | goto iput_mirr_err_out; |
| 1782 | } | 1790 | } |
| 1791 | lockdep_set_class(&NTFS_I(vol->mftbmp_ino)->runlist.lock, | ||
| 1792 | &mftbmp_runlist_lock_key); | ||
| 1793 | lockdep_set_class(&NTFS_I(vol->mftbmp_ino)->mrec_lock, | ||
| 1794 | &mftbmp_mrec_lock_key); | ||
| 1783 | /* Read upcase table and setup @vol->upcase and @vol->upcase_len. */ | 1795 | /* Read upcase table and setup @vol->upcase and @vol->upcase_len. */ |
| 1784 | if (!load_and_init_upcase(vol)) | 1796 | if (!load_and_init_upcase(vol)) |
| 1785 | goto iput_mftbmp_err_out; | 1797 | goto iput_mftbmp_err_out; |
| @@ -1802,6 +1814,11 @@ static BOOL load_system_files(ntfs_volume *vol) | |||
| 1802 | iput(vol->lcnbmp_ino); | 1814 | iput(vol->lcnbmp_ino); |
| 1803 | goto bitmap_failed; | 1815 | goto bitmap_failed; |
| 1804 | } | 1816 | } |
| 1817 | lockdep_set_class(&NTFS_I(vol->lcnbmp_ino)->runlist.lock, | ||
| 1818 | &lcnbmp_runlist_lock_key); | ||
| 1819 | lockdep_set_class(&NTFS_I(vol->lcnbmp_ino)->mrec_lock, | ||
| 1820 | &lcnbmp_mrec_lock_key); | ||
| 1821 | |||
| 1805 | NInoSetSparseDisabled(NTFS_I(vol->lcnbmp_ino)); | 1822 | NInoSetSparseDisabled(NTFS_I(vol->lcnbmp_ino)); |
| 1806 | if ((vol->nr_clusters + 7) >> 3 > i_size_read(vol->lcnbmp_ino)) { | 1823 | if ((vol->nr_clusters + 7) >> 3 > i_size_read(vol->lcnbmp_ino)) { |
| 1807 | iput(vol->lcnbmp_ino); | 1824 | iput(vol->lcnbmp_ino); |
| @@ -2743,6 +2760,17 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
| 2743 | struct inode *tmp_ino; | 2760 | struct inode *tmp_ino; |
| 2744 | int blocksize, result; | 2761 | int blocksize, result; |
| 2745 | 2762 | ||
| 2763 | /* | ||
| 2764 | * We do a pretty difficult piece of bootstrap by reading the | ||
| 2765 | * MFT (and other metadata) from disk into memory. We'll only | ||
| 2766 | * release this metadata during umount, so the locking patterns | ||
| 2767 | * observed during bootstrap do not count. So turn off the | ||
| 2768 | * observation of locking patterns (strictly for this context | ||
| 2769 | * only) while mounting NTFS. [The validator is still active | ||
| 2770 | * otherwise, even for this context: it will for example record | ||
| 2771 | * lock class registrations.] | ||
| 2772 | */ | ||
| 2773 | lockdep_off(); | ||
| 2746 | ntfs_debug("Entering."); | 2774 | ntfs_debug("Entering."); |
| 2747 | #ifndef NTFS_RW | 2775 | #ifndef NTFS_RW |
| 2748 | sb->s_flags |= MS_RDONLY; | 2776 | sb->s_flags |= MS_RDONLY; |
| @@ -2754,6 +2782,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
| 2754 | if (!silent) | 2782 | if (!silent) |
| 2755 | ntfs_error(sb, "Allocation of NTFS volume structure " | 2783 | ntfs_error(sb, "Allocation of NTFS volume structure " |
| 2756 | "failed. Aborting mount..."); | 2784 | "failed. Aborting mount..."); |
| 2785 | lockdep_on(); | ||
| 2757 | return -ENOMEM; | 2786 | return -ENOMEM; |
| 2758 | } | 2787 | } |
| 2759 | /* Initialize ntfs_volume structure. */ | 2788 | /* Initialize ntfs_volume structure. */ |
| @@ -2940,6 +2969,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
| 2940 | mutex_unlock(&ntfs_lock); | 2969 | mutex_unlock(&ntfs_lock); |
| 2941 | sb->s_export_op = &ntfs_export_ops; | 2970 | sb->s_export_op = &ntfs_export_ops; |
| 2942 | lock_kernel(); | 2971 | lock_kernel(); |
| 2972 | lockdep_on(); | ||
| 2943 | return 0; | 2973 | return 0; |
| 2944 | } | 2974 | } |
| 2945 | ntfs_error(sb, "Failed to allocate root directory."); | 2975 | ntfs_error(sb, "Failed to allocate root directory."); |
| @@ -3059,6 +3089,7 @@ err_out_now: | |||
| 3059 | sb->s_fs_info = NULL; | 3089 | sb->s_fs_info = NULL; |
| 3060 | kfree(vol); | 3090 | kfree(vol); |
| 3061 | ntfs_debug("Failed, returning -EINVAL."); | 3091 | ntfs_debug("Failed, returning -EINVAL."); |
| 3092 | lockdep_on(); | ||
| 3062 | return -EINVAL; | 3093 | return -EINVAL; |
| 3063 | } | 3094 | } |
| 3064 | 3095 | ||
| @@ -3217,32 +3248,14 @@ ictx_err_out: | |||
| 3217 | 3248 | ||
| 3218 | static void __exit exit_ntfs_fs(void) | 3249 | static void __exit exit_ntfs_fs(void) |
| 3219 | { | 3250 | { |
| 3220 | int err = 0; | ||
| 3221 | |||
| 3222 | ntfs_debug("Unregistering NTFS driver."); | 3251 | ntfs_debug("Unregistering NTFS driver."); |
| 3223 | 3252 | ||
| 3224 | unregister_filesystem(&ntfs_fs_type); | 3253 | unregister_filesystem(&ntfs_fs_type); |
| 3225 | 3254 | kmem_cache_destroy(ntfs_big_inode_cache); | |
| 3226 | if (kmem_cache_destroy(ntfs_big_inode_cache) && (err = 1)) | 3255 | kmem_cache_destroy(ntfs_inode_cache); |
| 3227 | printk(KERN_CRIT "NTFS: Failed to destory %s.\n", | 3256 | kmem_cache_destroy(ntfs_name_cache); |
| 3228 | ntfs_big_inode_cache_name); | 3257 | kmem_cache_destroy(ntfs_attr_ctx_cache); |
| 3229 | if (kmem_cache_destroy(ntfs_inode_cache) && (err = 1)) | 3258 | kmem_cache_destroy(ntfs_index_ctx_cache); |
| 3230 | printk(KERN_CRIT "NTFS: Failed to destory %s.\n", | ||
| 3231 | ntfs_inode_cache_name); | ||
| 3232 | if (kmem_cache_destroy(ntfs_name_cache) && (err = 1)) | ||
| 3233 | printk(KERN_CRIT "NTFS: Failed to destory %s.\n", | ||
| 3234 | ntfs_name_cache_name); | ||
| 3235 | if (kmem_cache_destroy(ntfs_attr_ctx_cache) && (err = 1)) | ||
| 3236 | printk(KERN_CRIT "NTFS: Failed to destory %s.\n", | ||
| 3237 | ntfs_attr_ctx_cache_name); | ||
| 3238 | if (kmem_cache_destroy(ntfs_index_ctx_cache) && (err = 1)) | ||
| 3239 | printk(KERN_CRIT "NTFS: Failed to destory %s.\n", | ||
| 3240 | ntfs_index_ctx_cache_name); | ||
| 3241 | if (err) | ||
| 3242 | printk(KERN_CRIT "NTFS: This causes memory to leak! There is " | ||
| 3243 | "probably a BUG in the driver! Please report " | ||
| 3244 | "you saw this message to " | ||
| 3245 | "linux-ntfs-dev@lists.sourceforge.net\n"); | ||
| 3246 | /* Unregister the ntfs sysctls. */ | 3259 | /* Unregister the ntfs sysctls. */ |
| 3247 | ntfs_sysctl(0); | 3260 | ntfs_sysctl(0); |
| 3248 | } | 3261 | } |
diff --git a/fs/ntfs/sysctl.h b/fs/ntfs/sysctl.h index c8064cae8f17..beda5bf96405 100644 --- a/fs/ntfs/sysctl.h +++ b/fs/ntfs/sysctl.h | |||
| @@ -24,7 +24,6 @@ | |||
| 24 | #ifndef _LINUX_NTFS_SYSCTL_H | 24 | #ifndef _LINUX_NTFS_SYSCTL_H |
| 25 | #define _LINUX_NTFS_SYSCTL_H | 25 | #define _LINUX_NTFS_SYSCTL_H |
| 26 | 26 | ||
| 27 | #include <linux/config.h> | ||
| 28 | 27 | ||
| 29 | #if defined(DEBUG) && defined(CONFIG_SYSCTL) | 28 | #if defined(DEBUG) && defined(CONFIG_SYSCTL) |
| 30 | 29 | ||
diff --git a/fs/ntfs/unistr.c b/fs/ntfs/unistr.c index b123c0fa6bf6..a1b572196fe4 100644 --- a/fs/ntfs/unistr.c +++ b/fs/ntfs/unistr.c | |||
| @@ -350,7 +350,7 @@ int ntfs_ucstonls(const ntfs_volume *vol, const ntfschar *ins, | |||
| 350 | } | 350 | } |
| 351 | if (!ns) { | 351 | if (!ns) { |
| 352 | ns_len = ins_len * NLS_MAX_CHARSET_SIZE; | 352 | ns_len = ins_len * NLS_MAX_CHARSET_SIZE; |
| 353 | ns = (unsigned char*)kmalloc(ns_len + 1, GFP_NOFS); | 353 | ns = kmalloc(ns_len + 1, GFP_NOFS); |
| 354 | if (!ns) | 354 | if (!ns) |
| 355 | goto mem_err_out; | 355 | goto mem_err_out; |
| 356 | } | 356 | } |
| @@ -365,7 +365,7 @@ retry: wc = nls->uni2char(le16_to_cpu(ins[i]), ns + o, | |||
| 365 | else if (wc == -ENAMETOOLONG && ns != *outs) { | 365 | else if (wc == -ENAMETOOLONG && ns != *outs) { |
| 366 | unsigned char *tc; | 366 | unsigned char *tc; |
| 367 | /* Grow in multiples of 64 bytes. */ | 367 | /* Grow in multiples of 64 bytes. */ |
| 368 | tc = (unsigned char*)kmalloc((ns_len + 64) & | 368 | tc = kmalloc((ns_len + 64) & |
| 369 | ~63, GFP_NOFS); | 369 | ~63, GFP_NOFS); |
| 370 | if (tc) { | 370 | if (tc) { |
| 371 | memcpy(tc, ns, ns_len); | 371 | memcpy(tc, ns, ns_len); |
