diff options
-rw-r--r-- | fs/ntfs/ChangeLog | 1 | ||||
-rw-r--r-- | fs/ntfs/aops.c | 6 | ||||
-rw-r--r-- | fs/ntfs/compress.c | 4 | ||||
-rw-r--r-- | fs/ntfs/inode.c | 10 | ||||
-rw-r--r-- | fs/ntfs/inode.h | 13 | ||||
-rw-r--r-- | fs/ntfs/mft.c | 62 | ||||
-rw-r--r-- | fs/ntfs/ntfs.h | 2 | ||||
-rw-r--r-- | fs/ntfs/super.c | 42 |
8 files changed, 71 insertions, 69 deletions
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 9fb08ef3a7f8..35cc4b1d60f7 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog | |||
@@ -43,6 +43,7 @@ ToDo/Notes: | |||
43 | fs/ntfs/inode.c::ntfs_write_inode(). | 43 | fs/ntfs/inode.c::ntfs_write_inode(). |
44 | - Handle the recently introduced -ENAMETOOLONG return value from | 44 | - Handle the recently introduced -ENAMETOOLONG return value from |
45 | fs/ntfs/unistr.c::ntfs_nlstoucs() in fs/ntfs/namei.c::ntfs_lookup(). | 45 | fs/ntfs/unistr.c::ntfs_nlstoucs() in fs/ntfs/namei.c::ntfs_lookup(). |
46 | - Semaphore to mutex conversion. (Ingo Molnar) | ||
46 | 47 | ||
47 | 2.1.26 - Minor bug fixes and updates. | 48 | 2.1.26 - Minor bug fixes and updates. |
48 | 49 | ||
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 1cf105b99202..580412d330cb 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c | |||
@@ -1278,18 +1278,18 @@ unm_done: | |||
1278 | 1278 | ||
1279 | tni = locked_nis[nr_locked_nis]; | 1279 | tni = locked_nis[nr_locked_nis]; |
1280 | /* Get the base inode. */ | 1280 | /* Get the base inode. */ |
1281 | down(&tni->extent_lock); | 1281 | mutex_lock(&tni->extent_lock); |
1282 | if (tni->nr_extents >= 0) | 1282 | if (tni->nr_extents >= 0) |
1283 | base_tni = tni; | 1283 | base_tni = tni; |
1284 | else { | 1284 | else { |
1285 | base_tni = tni->ext.base_ntfs_ino; | 1285 | base_tni = tni->ext.base_ntfs_ino; |
1286 | BUG_ON(!base_tni); | 1286 | BUG_ON(!base_tni); |
1287 | } | 1287 | } |
1288 | up(&tni->extent_lock); | 1288 | mutex_unlock(&tni->extent_lock); |
1289 | ntfs_debug("Unlocking %s inode 0x%lx.", | 1289 | ntfs_debug("Unlocking %s inode 0x%lx.", |
1290 | tni == base_tni ? "base" : "extent", | 1290 | tni == base_tni ? "base" : "extent", |
1291 | tni->mft_no); | 1291 | tni->mft_no); |
1292 | up(&tni->mrec_lock); | 1292 | mutex_unlock(&tni->mrec_lock); |
1293 | atomic_dec(&tni->count); | 1293 | atomic_dec(&tni->count); |
1294 | iput(VFS_I(base_tni)); | 1294 | iput(VFS_I(base_tni)); |
1295 | } | 1295 | } |
diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c index 25d24106f893..68a607ff9fd3 100644 --- a/fs/ntfs/compress.c +++ b/fs/ntfs/compress.c | |||
@@ -67,7 +67,7 @@ static DEFINE_SPINLOCK(ntfs_cb_lock); | |||
67 | /** | 67 | /** |
68 | * allocate_compression_buffers - allocate the decompression buffers | 68 | * allocate_compression_buffers - allocate the decompression buffers |
69 | * | 69 | * |
70 | * Caller has to hold the ntfs_lock semaphore. | 70 | * Caller has to hold the ntfs_lock mutex. |
71 | * | 71 | * |
72 | * Return 0 on success or -ENOMEM if the allocations failed. | 72 | * Return 0 on success or -ENOMEM if the allocations failed. |
73 | */ | 73 | */ |
@@ -84,7 +84,7 @@ int allocate_compression_buffers(void) | |||
84 | /** | 84 | /** |
85 | * free_compression_buffers - free the decompression buffers | 85 | * free_compression_buffers - free the decompression buffers |
86 | * | 86 | * |
87 | * Caller has to hold the ntfs_lock semaphore. | 87 | * Caller has to hold the ntfs_lock mutex. |
88 | */ | 88 | */ |
89 | void free_compression_buffers(void) | 89 | void free_compression_buffers(void) |
90 | { | 90 | { |
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 73791b2d9495..4c86b7e1d1eb 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c | |||
@@ -388,7 +388,7 @@ void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni) | |||
388 | atomic_set(&ni->count, 1); | 388 | atomic_set(&ni->count, 1); |
389 | ni->vol = NTFS_SB(sb); | 389 | ni->vol = NTFS_SB(sb); |
390 | ntfs_init_runlist(&ni->runlist); | 390 | ntfs_init_runlist(&ni->runlist); |
391 | init_MUTEX(&ni->mrec_lock); | 391 | mutex_init(&ni->mrec_lock); |
392 | ni->page = NULL; | 392 | ni->page = NULL; |
393 | ni->page_ofs = 0; | 393 | ni->page_ofs = 0; |
394 | ni->attr_list_size = 0; | 394 | ni->attr_list_size = 0; |
@@ -400,7 +400,7 @@ void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni) | |||
400 | ni->itype.index.collation_rule = 0; | 400 | ni->itype.index.collation_rule = 0; |
401 | ni->itype.index.block_size_bits = 0; | 401 | ni->itype.index.block_size_bits = 0; |
402 | ni->itype.index.vcn_size_bits = 0; | 402 | ni->itype.index.vcn_size_bits = 0; |
403 | init_MUTEX(&ni->extent_lock); | 403 | mutex_init(&ni->extent_lock); |
404 | ni->nr_extents = 0; | 404 | ni->nr_extents = 0; |
405 | ni->ext.base_ntfs_ino = NULL; | 405 | ni->ext.base_ntfs_ino = NULL; |
406 | } | 406 | } |
@@ -3066,7 +3066,7 @@ int ntfs_write_inode(struct inode *vi, int sync) | |||
3066 | */ | 3066 | */ |
3067 | if (modified) { | 3067 | if (modified) { |
3068 | flush_dcache_mft_record_page(ctx->ntfs_ino); | 3068 | flush_dcache_mft_record_page(ctx->ntfs_ino); |
3069 | if (!NInoTestSetDirty(ctx->ntfs_ino)) { | 3069 | if (!NInoTestSetDirty(ctx->ntfs_ino)) |
3070 | mark_ntfs_record_dirty(ctx->ntfs_ino->page, | 3070 | mark_ntfs_record_dirty(ctx->ntfs_ino->page, |
3071 | ctx->ntfs_ino->page_ofs); | 3071 | ctx->ntfs_ino->page_ofs); |
3072 | } | 3072 | } |
@@ -3075,7 +3075,7 @@ int ntfs_write_inode(struct inode *vi, int sync) | |||
3075 | if (NInoDirty(ni)) | 3075 | if (NInoDirty(ni)) |
3076 | err = write_mft_record(ni, m, sync); | 3076 | err = write_mft_record(ni, m, sync); |
3077 | /* Write all attached extent mft records. */ | 3077 | /* Write all attached extent mft records. */ |
3078 | down(&ni->extent_lock); | 3078 | mutex_lock(&ni->extent_lock); |
3079 | if (ni->nr_extents > 0) { | 3079 | if (ni->nr_extents > 0) { |
3080 | ntfs_inode **extent_nis = ni->ext.extent_ntfs_inos; | 3080 | ntfs_inode **extent_nis = ni->ext.extent_ntfs_inos; |
3081 | int i; | 3081 | int i; |
@@ -3102,7 +3102,7 @@ int ntfs_write_inode(struct inode *vi, int sync) | |||
3102 | } | 3102 | } |
3103 | } | 3103 | } |
3104 | } | 3104 | } |
3105 | up(&ni->extent_lock); | 3105 | mutex_unlock(&ni->extent_lock); |
3106 | unmap_mft_record(ni); | 3106 | unmap_mft_record(ni); |
3107 | if (unlikely(err)) | 3107 | if (unlikely(err)) |
3108 | goto err_out; | 3108 | goto err_out; |
diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h index 3de5c0231966..f088291e017c 100644 --- a/fs/ntfs/inode.h +++ b/fs/ntfs/inode.h | |||
@@ -24,12 +24,13 @@ | |||
24 | #ifndef _LINUX_NTFS_INODE_H | 24 | #ifndef _LINUX_NTFS_INODE_H |
25 | #define _LINUX_NTFS_INODE_H | 25 | #define _LINUX_NTFS_INODE_H |
26 | 26 | ||
27 | #include <linux/mm.h> | 27 | #include <asm/atomic.h> |
28 | |||
28 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
29 | #include <linux/seq_file.h> | ||
30 | #include <linux/list.h> | 30 | #include <linux/list.h> |
31 | #include <asm/atomic.h> | 31 | #include <linux/mm.h> |
32 | #include <asm/semaphore.h> | 32 | #include <linux/mutex.h> |
33 | #include <linux/seq_file.h> | ||
33 | 34 | ||
34 | #include "layout.h" | 35 | #include "layout.h" |
35 | #include "volume.h" | 36 | #include "volume.h" |
@@ -81,7 +82,7 @@ struct _ntfs_inode { | |||
81 | * The following fields are only valid for real inodes and extent | 82 | * The following fields are only valid for real inodes and extent |
82 | * inodes. | 83 | * inodes. |
83 | */ | 84 | */ |
84 | struct semaphore mrec_lock; /* Lock for serializing access to the | 85 | struct mutex mrec_lock; /* Lock for serializing access to the |
85 | mft record belonging to this inode. */ | 86 | mft record belonging to this inode. */ |
86 | struct page *page; /* The page containing the mft record of the | 87 | struct page *page; /* The page containing the mft record of the |
87 | inode. This should only be touched by the | 88 | inode. This should only be touched by the |
@@ -119,7 +120,7 @@ struct _ntfs_inode { | |||
119 | u8 block_clusters; /* Number of clusters per cb. */ | 120 | u8 block_clusters; /* Number of clusters per cb. */ |
120 | } compressed; | 121 | } compressed; |
121 | } itype; | 122 | } itype; |
122 | struct semaphore extent_lock; /* Lock for accessing/modifying the | 123 | struct mutex extent_lock; /* Lock for accessing/modifying the |
123 | below . */ | 124 | below . */ |
124 | s32 nr_extents; /* For a base mft record, the number of attached extent | 125 | s32 nr_extents; /* For a base mft record, the number of attached extent |
125 | inodes (0 if none), for extent records and for fake | 126 | inodes (0 if none), for extent records and for fake |
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index eb3eb143a32c..4e72bc7afdf9 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c | |||
@@ -105,8 +105,8 @@ err_out: | |||
105 | * map_mft_record - map, pin and lock an mft record | 105 | * map_mft_record - map, pin and lock an mft record |
106 | * @ni: ntfs inode whose MFT record to map | 106 | * @ni: ntfs inode whose MFT record to map |
107 | * | 107 | * |
108 | * First, take the mrec_lock semaphore. We might now be sleeping, while waiting | 108 | * First, take the mrec_lock mutex. We might now be sleeping, while waiting |
109 | * for the semaphore if it was already locked by someone else. | 109 | * for the mutex if it was already locked by someone else. |
110 | * | 110 | * |
111 | * The page of the record is mapped using map_mft_record_page() before being | 111 | * The page of the record is mapped using map_mft_record_page() before being |
112 | * returned to the caller. | 112 | * returned to the caller. |
@@ -136,9 +136,9 @@ err_out: | |||
136 | * So that code will end up having to own the mrec_lock of all mft | 136 | * So that code will end up having to own the mrec_lock of all mft |
137 | * records/inodes present in the page before I/O can proceed. In that case we | 137 | * records/inodes present in the page before I/O can proceed. In that case we |
138 | * wouldn't need to bother with PG_locked and PG_uptodate as nobody will be | 138 | * wouldn't need to bother with PG_locked and PG_uptodate as nobody will be |
139 | * accessing anything without owning the mrec_lock semaphore. But we do need | 139 | * accessing anything without owning the mrec_lock mutex. But we do need to |
140 | * to use them because of the read_cache_page() invocation and the code becomes | 140 | * use them because of the read_cache_page() invocation and the code becomes so |
141 | * so much simpler this way that it is well worth it. | 141 | * much simpler this way that it is well worth it. |
142 | * | 142 | * |
143 | * The mft record is now ours and we return a pointer to it. You need to check | 143 | * The mft record is now ours and we return a pointer to it. You need to check |
144 | * the returned pointer with IS_ERR() and if that is true, PTR_ERR() will return | 144 | * the returned pointer with IS_ERR() and if that is true, PTR_ERR() will return |
@@ -161,13 +161,13 @@ MFT_RECORD *map_mft_record(ntfs_inode *ni) | |||
161 | atomic_inc(&ni->count); | 161 | atomic_inc(&ni->count); |
162 | 162 | ||
163 | /* Serialize access to this mft record. */ | 163 | /* Serialize access to this mft record. */ |
164 | down(&ni->mrec_lock); | 164 | mutex_lock(&ni->mrec_lock); |
165 | 165 | ||
166 | m = map_mft_record_page(ni); | 166 | m = map_mft_record_page(ni); |
167 | if (likely(!IS_ERR(m))) | 167 | if (likely(!IS_ERR(m))) |
168 | return m; | 168 | return m; |
169 | 169 | ||
170 | up(&ni->mrec_lock); | 170 | mutex_unlock(&ni->mrec_lock); |
171 | atomic_dec(&ni->count); | 171 | atomic_dec(&ni->count); |
172 | ntfs_error(ni->vol->sb, "Failed with error code %lu.", -PTR_ERR(m)); | 172 | ntfs_error(ni->vol->sb, "Failed with error code %lu.", -PTR_ERR(m)); |
173 | return m; | 173 | return m; |
@@ -218,7 +218,7 @@ void unmap_mft_record(ntfs_inode *ni) | |||
218 | ntfs_debug("Entering for mft_no 0x%lx.", ni->mft_no); | 218 | ntfs_debug("Entering for mft_no 0x%lx.", ni->mft_no); |
219 | 219 | ||
220 | unmap_mft_record_page(ni); | 220 | unmap_mft_record_page(ni); |
221 | up(&ni->mrec_lock); | 221 | mutex_unlock(&ni->mrec_lock); |
222 | atomic_dec(&ni->count); | 222 | atomic_dec(&ni->count); |
223 | /* | 223 | /* |
224 | * If pure ntfs_inode, i.e. no vfs inode attached, we leave it to | 224 | * If pure ntfs_inode, i.e. no vfs inode attached, we leave it to |
@@ -262,7 +262,7 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref, | |||
262 | * in which case just return it. If not found, add it to the base | 262 | * in which case just return it. If not found, add it to the base |
263 | * inode before returning it. | 263 | * inode before returning it. |
264 | */ | 264 | */ |
265 | down(&base_ni->extent_lock); | 265 | mutex_lock(&base_ni->extent_lock); |
266 | if (base_ni->nr_extents > 0) { | 266 | if (base_ni->nr_extents > 0) { |
267 | extent_nis = base_ni->ext.extent_ntfs_inos; | 267 | extent_nis = base_ni->ext.extent_ntfs_inos; |
268 | for (i = 0; i < base_ni->nr_extents; i++) { | 268 | for (i = 0; i < base_ni->nr_extents; i++) { |
@@ -275,7 +275,7 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref, | |||
275 | } | 275 | } |
276 | } | 276 | } |
277 | if (likely(ni != NULL)) { | 277 | if (likely(ni != NULL)) { |
278 | up(&base_ni->extent_lock); | 278 | mutex_unlock(&base_ni->extent_lock); |
279 | atomic_dec(&base_ni->count); | 279 | atomic_dec(&base_ni->count); |
280 | /* We found the record; just have to map and return it. */ | 280 | /* We found the record; just have to map and return it. */ |
281 | m = map_mft_record(ni); | 281 | m = map_mft_record(ni); |
@@ -302,7 +302,7 @@ map_err_out: | |||
302 | /* Record wasn't there. Get a new ntfs inode and initialize it. */ | 302 | /* Record wasn't there. Get a new ntfs inode and initialize it. */ |
303 | ni = ntfs_new_extent_inode(base_ni->vol->sb, mft_no); | 303 | ni = ntfs_new_extent_inode(base_ni->vol->sb, mft_no); |
304 | if (unlikely(!ni)) { | 304 | if (unlikely(!ni)) { |
305 | up(&base_ni->extent_lock); | 305 | mutex_unlock(&base_ni->extent_lock); |
306 | atomic_dec(&base_ni->count); | 306 | atomic_dec(&base_ni->count); |
307 | return ERR_PTR(-ENOMEM); | 307 | return ERR_PTR(-ENOMEM); |
308 | } | 308 | } |
@@ -313,7 +313,7 @@ map_err_out: | |||
313 | /* Now map the record. */ | 313 | /* Now map the record. */ |
314 | m = map_mft_record(ni); | 314 | m = map_mft_record(ni); |
315 | if (IS_ERR(m)) { | 315 | if (IS_ERR(m)) { |
316 | up(&base_ni->extent_lock); | 316 | mutex_unlock(&base_ni->extent_lock); |
317 | atomic_dec(&base_ni->count); | 317 | atomic_dec(&base_ni->count); |
318 | ntfs_clear_extent_inode(ni); | 318 | ntfs_clear_extent_inode(ni); |
319 | goto map_err_out; | 319 | goto map_err_out; |
@@ -348,14 +348,14 @@ map_err_out: | |||
348 | base_ni->ext.extent_ntfs_inos = tmp; | 348 | base_ni->ext.extent_ntfs_inos = tmp; |
349 | } | 349 | } |
350 | base_ni->ext.extent_ntfs_inos[base_ni->nr_extents++] = ni; | 350 | base_ni->ext.extent_ntfs_inos[base_ni->nr_extents++] = ni; |
351 | up(&base_ni->extent_lock); | 351 | mutex_unlock(&base_ni->extent_lock); |
352 | atomic_dec(&base_ni->count); | 352 | atomic_dec(&base_ni->count); |
353 | ntfs_debug("Done 2."); | 353 | ntfs_debug("Done 2."); |
354 | *ntfs_ino = ni; | 354 | *ntfs_ino = ni; |
355 | return m; | 355 | return m; |
356 | unm_err_out: | 356 | unm_err_out: |
357 | unmap_mft_record(ni); | 357 | unmap_mft_record(ni); |
358 | up(&base_ni->extent_lock); | 358 | mutex_unlock(&base_ni->extent_lock); |
359 | atomic_dec(&base_ni->count); | 359 | atomic_dec(&base_ni->count); |
360 | /* | 360 | /* |
361 | * If the extent inode was not attached to the base inode we need to | 361 | * If the extent inode was not attached to the base inode we need to |
@@ -400,12 +400,12 @@ void __mark_mft_record_dirty(ntfs_inode *ni) | |||
400 | BUG_ON(NInoAttr(ni)); | 400 | BUG_ON(NInoAttr(ni)); |
401 | mark_ntfs_record_dirty(ni->page, ni->page_ofs); | 401 | mark_ntfs_record_dirty(ni->page, ni->page_ofs); |
402 | /* Determine the base vfs inode and mark it dirty, too. */ | 402 | /* Determine the base vfs inode and mark it dirty, too. */ |
403 | down(&ni->extent_lock); | 403 | mutex_lock(&ni->extent_lock); |
404 | if (likely(ni->nr_extents >= 0)) | 404 | if (likely(ni->nr_extents >= 0)) |
405 | base_ni = ni; | 405 | base_ni = ni; |
406 | else | 406 | else |
407 | base_ni = ni->ext.base_ntfs_ino; | 407 | base_ni = ni->ext.base_ntfs_ino; |
408 | up(&ni->extent_lock); | 408 | mutex_unlock(&ni->extent_lock); |
409 | __mark_inode_dirty(VFS_I(base_ni), I_DIRTY_SYNC | I_DIRTY_DATASYNC); | 409 | __mark_inode_dirty(VFS_I(base_ni), I_DIRTY_SYNC | I_DIRTY_DATASYNC); |
410 | } | 410 | } |
411 | 411 | ||
@@ -981,7 +981,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
981 | } | 981 | } |
982 | ntfs_debug("Inode 0x%lx is not dirty.", mft_no); | 982 | ntfs_debug("Inode 0x%lx is not dirty.", mft_no); |
983 | /* The inode is not dirty, try to take the mft record lock. */ | 983 | /* The inode is not dirty, try to take the mft record lock. */ |
984 | if (unlikely(down_trylock(&ni->mrec_lock))) { | 984 | if (unlikely(!mutex_trylock(&ni->mrec_lock))) { |
985 | ntfs_debug("Mft record 0x%lx is already locked, do " | 985 | ntfs_debug("Mft record 0x%lx is already locked, do " |
986 | "not write it.", mft_no); | 986 | "not write it.", mft_no); |
987 | atomic_dec(&ni->count); | 987 | atomic_dec(&ni->count); |
@@ -1041,13 +1041,13 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
1041 | * corresponding to this extent mft record attached. | 1041 | * corresponding to this extent mft record attached. |
1042 | */ | 1042 | */ |
1043 | ni = NTFS_I(vi); | 1043 | ni = NTFS_I(vi); |
1044 | down(&ni->extent_lock); | 1044 | mutex_lock(&ni->extent_lock); |
1045 | if (ni->nr_extents <= 0) { | 1045 | if (ni->nr_extents <= 0) { |
1046 | /* | 1046 | /* |
1047 | * The base inode has no attached extent inodes, write this | 1047 | * The base inode has no attached extent inodes, write this |
1048 | * extent mft record. | 1048 | * extent mft record. |
1049 | */ | 1049 | */ |
1050 | up(&ni->extent_lock); | 1050 | mutex_unlock(&ni->extent_lock); |
1051 | iput(vi); | 1051 | iput(vi); |
1052 | ntfs_debug("Base inode 0x%lx has no attached extent inodes, " | 1052 | ntfs_debug("Base inode 0x%lx has no attached extent inodes, " |
1053 | "write the extent record.", na.mft_no); | 1053 | "write the extent record.", na.mft_no); |
@@ -1070,7 +1070,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
1070 | * extent mft record. | 1070 | * extent mft record. |
1071 | */ | 1071 | */ |
1072 | if (!eni) { | 1072 | if (!eni) { |
1073 | up(&ni->extent_lock); | 1073 | mutex_unlock(&ni->extent_lock); |
1074 | iput(vi); | 1074 | iput(vi); |
1075 | ntfs_debug("Extent inode 0x%lx is not attached to its base " | 1075 | ntfs_debug("Extent inode 0x%lx is not attached to its base " |
1076 | "inode 0x%lx, write the extent record.", | 1076 | "inode 0x%lx, write the extent record.", |
@@ -1081,12 +1081,12 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no, | |||
1081 | mft_no, na.mft_no); | 1081 | mft_no, na.mft_no); |
1082 | /* Take a reference to the extent ntfs inode. */ | 1082 | /* Take a reference to the extent ntfs inode. */ |
1083 | atomic_inc(&eni->count); | 1083 | atomic_inc(&eni->count); |
1084 | up(&ni->extent_lock); | 1084 | mutex_unlock(&ni->extent_lock); |
1085 | /* | 1085 | /* |
1086 | * Found the extent inode coresponding to this extent mft record. | 1086 | * Found the extent inode coresponding to this extent mft record. |
1087 | * Try to take the mft record lock. | 1087 | * Try to take the mft record lock. |
1088 | */ | 1088 | */ |
1089 | if (unlikely(down_trylock(&eni->mrec_lock))) { | 1089 | if (unlikely(!mutex_trylock(&eni->mrec_lock))) { |
1090 | atomic_dec(&eni->count); | 1090 | atomic_dec(&eni->count); |
1091 | iput(vi); | 1091 | iput(vi); |
1092 | ntfs_debug("Extent mft record 0x%lx is already locked, do " | 1092 | ntfs_debug("Extent mft record 0x%lx is already locked, do " |
@@ -2709,7 +2709,7 @@ mft_rec_already_initialized: | |||
2709 | * have its page mapped and it is very easy to do. | 2709 | * have its page mapped and it is very easy to do. |
2710 | */ | 2710 | */ |
2711 | atomic_inc(&ni->count); | 2711 | atomic_inc(&ni->count); |
2712 | down(&ni->mrec_lock); | 2712 | mutex_lock(&ni->mrec_lock); |
2713 | ni->page = page; | 2713 | ni->page = page; |
2714 | ni->page_ofs = ofs; | 2714 | ni->page_ofs = ofs; |
2715 | /* | 2715 | /* |
@@ -2796,22 +2796,22 @@ int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m) | |||
2796 | BUG_ON(NInoAttr(ni)); | 2796 | BUG_ON(NInoAttr(ni)); |
2797 | BUG_ON(ni->nr_extents != -1); | 2797 | BUG_ON(ni->nr_extents != -1); |
2798 | 2798 | ||
2799 | down(&ni->extent_lock); | 2799 | mutex_lock(&ni->extent_lock); |
2800 | base_ni = ni->ext.base_ntfs_ino; | 2800 | base_ni = ni->ext.base_ntfs_ino; |
2801 | up(&ni->extent_lock); | 2801 | mutex_unlock(&ni->extent_lock); |
2802 | 2802 | ||
2803 | BUG_ON(base_ni->nr_extents <= 0); | 2803 | BUG_ON(base_ni->nr_extents <= 0); |
2804 | 2804 | ||
2805 | ntfs_debug("Entering for extent inode 0x%lx, base inode 0x%lx.\n", | 2805 | ntfs_debug("Entering for extent inode 0x%lx, base inode 0x%lx.\n", |
2806 | mft_no, base_ni->mft_no); | 2806 | mft_no, base_ni->mft_no); |
2807 | 2807 | ||
2808 | down(&base_ni->extent_lock); | 2808 | mutex_lock(&base_ni->extent_lock); |
2809 | 2809 | ||
2810 | /* Make sure we are holding the only reference to the extent inode. */ | 2810 | /* Make sure we are holding the only reference to the extent inode. */ |
2811 | if (atomic_read(&ni->count) > 2) { | 2811 | if (atomic_read(&ni->count) > 2) { |
2812 | ntfs_error(vol->sb, "Tried to free busy extent inode 0x%lx, " | 2812 | ntfs_error(vol->sb, "Tried to free busy extent inode 0x%lx, " |
2813 | "not freeing.", base_ni->mft_no); | 2813 | "not freeing.", base_ni->mft_no); |
2814 | up(&base_ni->extent_lock); | 2814 | mutex_unlock(&base_ni->extent_lock); |
2815 | return -EBUSY; | 2815 | return -EBUSY; |
2816 | } | 2816 | } |
2817 | 2817 | ||
@@ -2829,7 +2829,7 @@ int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m) | |||
2829 | break; | 2829 | break; |
2830 | } | 2830 | } |
2831 | 2831 | ||
2832 | up(&base_ni->extent_lock); | 2832 | mutex_unlock(&base_ni->extent_lock); |
2833 | 2833 | ||
2834 | if (unlikely(err)) { | 2834 | if (unlikely(err)) { |
2835 | ntfs_error(vol->sb, "Extent inode 0x%lx is not attached to " | 2835 | ntfs_error(vol->sb, "Extent inode 0x%lx is not attached to " |
@@ -2888,7 +2888,7 @@ rollback_error: | |||
2888 | return 0; | 2888 | return 0; |
2889 | rollback: | 2889 | rollback: |
2890 | /* Rollback what we did... */ | 2890 | /* Rollback what we did... */ |
2891 | down(&base_ni->extent_lock); | 2891 | mutex_lock(&base_ni->extent_lock); |
2892 | extent_nis = base_ni->ext.extent_ntfs_inos; | 2892 | extent_nis = base_ni->ext.extent_ntfs_inos; |
2893 | if (!(base_ni->nr_extents & 3)) { | 2893 | if (!(base_ni->nr_extents & 3)) { |
2894 | int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode*); | 2894 | int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode*); |
@@ -2897,7 +2897,7 @@ rollback: | |||
2897 | if (unlikely(!extent_nis)) { | 2897 | if (unlikely(!extent_nis)) { |
2898 | ntfs_error(vol->sb, "Failed to allocate internal " | 2898 | ntfs_error(vol->sb, "Failed to allocate internal " |
2899 | "buffer during rollback.%s", es); | 2899 | "buffer during rollback.%s", es); |
2900 | up(&base_ni->extent_lock); | 2900 | mutex_unlock(&base_ni->extent_lock); |
2901 | NVolSetErrors(vol); | 2901 | NVolSetErrors(vol); |
2902 | goto rollback_error; | 2902 | goto rollback_error; |
2903 | } | 2903 | } |
@@ -2912,7 +2912,7 @@ rollback: | |||
2912 | m->flags |= MFT_RECORD_IN_USE; | 2912 | m->flags |= MFT_RECORD_IN_USE; |
2913 | m->sequence_number = old_seq_no; | 2913 | m->sequence_number = old_seq_no; |
2914 | extent_nis[base_ni->nr_extents++] = ni; | 2914 | extent_nis[base_ni->nr_extents++] = ni; |
2915 | up(&base_ni->extent_lock); | 2915 | mutex_unlock(&base_ni->extent_lock); |
2916 | mark_mft_record_dirty(ni); | 2916 | mark_mft_record_dirty(ni); |
2917 | return err; | 2917 | return err; |
2918 | } | 2918 | } |
diff --git a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h index 653d2a5c4899..0624c8ef4d9c 100644 --- a/fs/ntfs/ntfs.h +++ b/fs/ntfs/ntfs.h | |||
@@ -91,7 +91,7 @@ extern void free_compression_buffers(void); | |||
91 | 91 | ||
92 | /* From fs/ntfs/super.c */ | 92 | /* From fs/ntfs/super.c */ |
93 | #define default_upcase_len 0x10000 | 93 | #define default_upcase_len 0x10000 |
94 | extern struct semaphore ntfs_lock; | 94 | extern struct mutex ntfs_lock; |
95 | 95 | ||
96 | typedef struct { | 96 | typedef struct { |
97 | int val; | 97 | int val; |
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index fd4aecc5548e..6816edafe4dd 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c | |||
@@ -1677,11 +1677,11 @@ read_partial_upcase_page: | |||
1677 | ntfs_debug("Read %llu bytes from $UpCase (expected %zu bytes).", | 1677 | ntfs_debug("Read %llu bytes from $UpCase (expected %zu bytes).", |
1678 | i_size, 64 * 1024 * sizeof(ntfschar)); | 1678 | i_size, 64 * 1024 * sizeof(ntfschar)); |
1679 | iput(ino); | 1679 | iput(ino); |
1680 | down(&ntfs_lock); | 1680 | mutex_lock(&ntfs_lock); |
1681 | if (!default_upcase) { | 1681 | if (!default_upcase) { |
1682 | ntfs_debug("Using volume specified $UpCase since default is " | 1682 | ntfs_debug("Using volume specified $UpCase since default is " |
1683 | "not present."); | 1683 | "not present."); |
1684 | up(&ntfs_lock); | 1684 | mutex_unlock(&ntfs_lock); |
1685 | return TRUE; | 1685 | return TRUE; |
1686 | } | 1686 | } |
1687 | max = default_upcase_len; | 1687 | max = default_upcase_len; |
@@ -1695,12 +1695,12 @@ read_partial_upcase_page: | |||
1695 | vol->upcase = default_upcase; | 1695 | vol->upcase = default_upcase; |
1696 | vol->upcase_len = max; | 1696 | vol->upcase_len = max; |
1697 | ntfs_nr_upcase_users++; | 1697 | ntfs_nr_upcase_users++; |
1698 | up(&ntfs_lock); | 1698 | mutex_unlock(&ntfs_lock); |
1699 | ntfs_debug("Volume specified $UpCase matches default. Using " | 1699 | ntfs_debug("Volume specified $UpCase matches default. Using " |
1700 | "default."); | 1700 | "default."); |
1701 | return TRUE; | 1701 | return TRUE; |
1702 | } | 1702 | } |
1703 | up(&ntfs_lock); | 1703 | mutex_unlock(&ntfs_lock); |
1704 | ntfs_debug("Using volume specified $UpCase since it does not match " | 1704 | ntfs_debug("Using volume specified $UpCase since it does not match " |
1705 | "the default."); | 1705 | "the default."); |
1706 | return TRUE; | 1706 | return TRUE; |
@@ -1709,17 +1709,17 @@ iput_upcase_failed: | |||
1709 | ntfs_free(vol->upcase); | 1709 | ntfs_free(vol->upcase); |
1710 | vol->upcase = NULL; | 1710 | vol->upcase = NULL; |
1711 | upcase_failed: | 1711 | upcase_failed: |
1712 | down(&ntfs_lock); | 1712 | mutex_lock(&ntfs_lock); |
1713 | if (default_upcase) { | 1713 | if (default_upcase) { |
1714 | vol->upcase = default_upcase; | 1714 | vol->upcase = default_upcase; |
1715 | vol->upcase_len = default_upcase_len; | 1715 | vol->upcase_len = default_upcase_len; |
1716 | ntfs_nr_upcase_users++; | 1716 | ntfs_nr_upcase_users++; |
1717 | up(&ntfs_lock); | 1717 | mutex_unlock(&ntfs_lock); |
1718 | ntfs_error(sb, "Failed to load $UpCase from the volume. Using " | 1718 | ntfs_error(sb, "Failed to load $UpCase from the volume. Using " |
1719 | "default."); | 1719 | "default."); |
1720 | return TRUE; | 1720 | return TRUE; |
1721 | } | 1721 | } |
1722 | up(&ntfs_lock); | 1722 | mutex_unlock(&ntfs_lock); |
1723 | ntfs_error(sb, "Failed to initialize upcase table."); | 1723 | ntfs_error(sb, "Failed to initialize upcase table."); |
1724 | return FALSE; | 1724 | return FALSE; |
1725 | } | 1725 | } |
@@ -2195,12 +2195,12 @@ iput_attrdef_err_out: | |||
2195 | iput_upcase_err_out: | 2195 | iput_upcase_err_out: |
2196 | #endif /* NTFS_RW */ | 2196 | #endif /* NTFS_RW */ |
2197 | vol->upcase_len = 0; | 2197 | vol->upcase_len = 0; |
2198 | down(&ntfs_lock); | 2198 | mutex_lock(&ntfs_lock); |
2199 | if (vol->upcase == default_upcase) { | 2199 | if (vol->upcase == default_upcase) { |
2200 | ntfs_nr_upcase_users--; | 2200 | ntfs_nr_upcase_users--; |
2201 | vol->upcase = NULL; | 2201 | vol->upcase = NULL; |
2202 | } | 2202 | } |
2203 | up(&ntfs_lock); | 2203 | mutex_unlock(&ntfs_lock); |
2204 | if (vol->upcase) { | 2204 | if (vol->upcase) { |
2205 | ntfs_free(vol->upcase); | 2205 | ntfs_free(vol->upcase); |
2206 | vol->upcase = NULL; | 2206 | vol->upcase = NULL; |
@@ -2405,7 +2405,7 @@ static void ntfs_put_super(struct super_block *sb) | |||
2405 | * Destroy the global default upcase table if necessary. Also decrease | 2405 | * Destroy the global default upcase table if necessary. Also decrease |
2406 | * the number of upcase users if we are a user. | 2406 | * the number of upcase users if we are a user. |
2407 | */ | 2407 | */ |
2408 | down(&ntfs_lock); | 2408 | mutex_lock(&ntfs_lock); |
2409 | if (vol->upcase == default_upcase) { | 2409 | if (vol->upcase == default_upcase) { |
2410 | ntfs_nr_upcase_users--; | 2410 | ntfs_nr_upcase_users--; |
2411 | vol->upcase = NULL; | 2411 | vol->upcase = NULL; |
@@ -2416,7 +2416,7 @@ static void ntfs_put_super(struct super_block *sb) | |||
2416 | } | 2416 | } |
2417 | if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users) | 2417 | if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users) |
2418 | free_compression_buffers(); | 2418 | free_compression_buffers(); |
2419 | up(&ntfs_lock); | 2419 | mutex_unlock(&ntfs_lock); |
2420 | if (vol->upcase) { | 2420 | if (vol->upcase) { |
2421 | ntfs_free(vol->upcase); | 2421 | ntfs_free(vol->upcase); |
2422 | vol->upcase = NULL; | 2422 | vol->upcase = NULL; |
@@ -2890,7 +2890,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
2890 | ntfs_error(sb, "Failed to load essential metadata."); | 2890 | ntfs_error(sb, "Failed to load essential metadata."); |
2891 | goto iput_tmp_ino_err_out_now; | 2891 | goto iput_tmp_ino_err_out_now; |
2892 | } | 2892 | } |
2893 | down(&ntfs_lock); | 2893 | mutex_lock(&ntfs_lock); |
2894 | /* | 2894 | /* |
2895 | * The current mount is a compression user if the cluster size is | 2895 | * The current mount is a compression user if the cluster size is |
2896 | * less than or equal 4kiB. | 2896 | * less than or equal 4kiB. |
@@ -2901,7 +2901,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
2901 | ntfs_error(NULL, "Failed to allocate buffers " | 2901 | ntfs_error(NULL, "Failed to allocate buffers " |
2902 | "for compression engine."); | 2902 | "for compression engine."); |
2903 | ntfs_nr_compression_users--; | 2903 | ntfs_nr_compression_users--; |
2904 | up(&ntfs_lock); | 2904 | mutex_unlock(&ntfs_lock); |
2905 | goto iput_tmp_ino_err_out_now; | 2905 | goto iput_tmp_ino_err_out_now; |
2906 | } | 2906 | } |
2907 | } | 2907 | } |
@@ -2913,7 +2913,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
2913 | if (!default_upcase) | 2913 | if (!default_upcase) |
2914 | default_upcase = generate_default_upcase(); | 2914 | default_upcase = generate_default_upcase(); |
2915 | ntfs_nr_upcase_users++; | 2915 | ntfs_nr_upcase_users++; |
2916 | up(&ntfs_lock); | 2916 | mutex_unlock(&ntfs_lock); |
2917 | /* | 2917 | /* |
2918 | * From now on, ignore @silent parameter. If we fail below this line, | 2918 | * From now on, ignore @silent parameter. If we fail below this line, |
2919 | * it will be due to a corrupt fs or a system error, so we report it. | 2919 | * it will be due to a corrupt fs or a system error, so we report it. |
@@ -2931,12 +2931,12 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
2931 | atomic_inc(&vol->root_ino->i_count); | 2931 | atomic_inc(&vol->root_ino->i_count); |
2932 | ntfs_debug("Exiting, status successful."); | 2932 | ntfs_debug("Exiting, status successful."); |
2933 | /* Release the default upcase if it has no users. */ | 2933 | /* Release the default upcase if it has no users. */ |
2934 | down(&ntfs_lock); | 2934 | mutex_lock(&ntfs_lock); |
2935 | if (!--ntfs_nr_upcase_users && default_upcase) { | 2935 | if (!--ntfs_nr_upcase_users && default_upcase) { |
2936 | ntfs_free(default_upcase); | 2936 | ntfs_free(default_upcase); |
2937 | default_upcase = NULL; | 2937 | default_upcase = NULL; |
2938 | } | 2938 | } |
2939 | up(&ntfs_lock); | 2939 | mutex_unlock(&ntfs_lock); |
2940 | sb->s_export_op = &ntfs_export_ops; | 2940 | sb->s_export_op = &ntfs_export_ops; |
2941 | lock_kernel(); | 2941 | lock_kernel(); |
2942 | return 0; | 2942 | return 0; |
@@ -3004,12 +3004,12 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
3004 | vol->attrdef = NULL; | 3004 | vol->attrdef = NULL; |
3005 | } | 3005 | } |
3006 | vol->upcase_len = 0; | 3006 | vol->upcase_len = 0; |
3007 | down(&ntfs_lock); | 3007 | mutex_lock(&ntfs_lock); |
3008 | if (vol->upcase == default_upcase) { | 3008 | if (vol->upcase == default_upcase) { |
3009 | ntfs_nr_upcase_users--; | 3009 | ntfs_nr_upcase_users--; |
3010 | vol->upcase = NULL; | 3010 | vol->upcase = NULL; |
3011 | } | 3011 | } |
3012 | up(&ntfs_lock); | 3012 | mutex_unlock(&ntfs_lock); |
3013 | if (vol->upcase) { | 3013 | if (vol->upcase) { |
3014 | ntfs_free(vol->upcase); | 3014 | ntfs_free(vol->upcase); |
3015 | vol->upcase = NULL; | 3015 | vol->upcase = NULL; |
@@ -3024,14 +3024,14 @@ unl_upcase_iput_tmp_ino_err_out_now: | |||
3024 | * Decrease the number of upcase users and destroy the global default | 3024 | * Decrease the number of upcase users and destroy the global default |
3025 | * upcase table if necessary. | 3025 | * upcase table if necessary. |
3026 | */ | 3026 | */ |
3027 | down(&ntfs_lock); | 3027 | mutex_lock(&ntfs_lock); |
3028 | if (!--ntfs_nr_upcase_users && default_upcase) { | 3028 | if (!--ntfs_nr_upcase_users && default_upcase) { |
3029 | ntfs_free(default_upcase); | 3029 | ntfs_free(default_upcase); |
3030 | default_upcase = NULL; | 3030 | default_upcase = NULL; |
3031 | } | 3031 | } |
3032 | if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users) | 3032 | if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users) |
3033 | free_compression_buffers(); | 3033 | free_compression_buffers(); |
3034 | up(&ntfs_lock); | 3034 | mutex_unlock(&ntfs_lock); |
3035 | iput_tmp_ino_err_out_now: | 3035 | iput_tmp_ino_err_out_now: |
3036 | iput(tmp_ino); | 3036 | iput(tmp_ino); |
3037 | if (vol->mft_ino && vol->mft_ino != tmp_ino) | 3037 | if (vol->mft_ino && vol->mft_ino != tmp_ino) |
@@ -3091,7 +3091,7 @@ struct kmem_cache *ntfs_attr_ctx_cache; | |||
3091 | struct kmem_cache *ntfs_index_ctx_cache; | 3091 | struct kmem_cache *ntfs_index_ctx_cache; |
3092 | 3092 | ||
3093 | /* Driver wide semaphore. */ | 3093 | /* Driver wide semaphore. */ |
3094 | DECLARE_MUTEX(ntfs_lock); | 3094 | DEFINE_MUTEX(ntfs_lock); |
3095 | 3095 | ||
3096 | static struct super_block *ntfs_get_sb(struct file_system_type *fs_type, | 3096 | static struct super_block *ntfs_get_sb(struct file_system_type *fs_type, |
3097 | int flags, const char *dev_name, void *data) | 3097 | int flags, const char *dev_name, void *data) |