@@ -105,8 +105,8 @@ static inline MFT_RECORD *map_mft_record_page(ntfs_inode *ni)
105105 * map_mft_record - map, pin and lock an mft record
106106 * @ni: ntfs inode whose MFT record to map
107107 *
108- * First, take the mrec_lock semaphore. We might now be sleeping, while waiting
109- * for the semaphore if it was already locked by someone else.
108+ * First, take the mrec_lock mutex. We might now be sleeping, while waiting
109+ * for the mutex if it was already locked by someone else.
110110 *
111111 * The page of the record is mapped using map_mft_record_page() before being
112112 * returned to the caller.
@@ -136,9 +136,9 @@ static inline MFT_RECORD *map_mft_record_page(ntfs_inode *ni)
136136 * So that code will end up having to own the mrec_lock of all mft
137137 * records/inodes present in the page before I/O can proceed. In that case we
138138 * 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
140- * to use them because of the read_cache_page() invocation and the code becomes
141- * so much simpler this way that it is well worth it.
139+ * accessing anything without owning the mrec_lock mutex. But we do need to
140+ * use them because of the read_cache_page() invocation and the code becomes so
141+ * much simpler this way that it is well worth it.
142142 *
143143 * The mft record is now ours and we return a pointer to it. You need to check
144144 * 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)
161161 atomic_inc (& ni -> count );
162162
163163 /* Serialize access to this mft record. */
164- down (& ni -> mrec_lock );
164+ mutex_lock (& ni -> mrec_lock );
165165
166166 m = map_mft_record_page (ni );
167167 if (likely (!IS_ERR (m )))
168168 return m ;
169169
170- up (& ni -> mrec_lock );
170+ mutex_unlock (& ni -> mrec_lock );
171171 atomic_dec (& ni -> count );
172172 ntfs_error (ni -> vol -> sb , "Failed with error code %lu." , - PTR_ERR (m ));
173173 return m ;
@@ -218,7 +218,7 @@ void unmap_mft_record(ntfs_inode *ni)
218218 ntfs_debug ("Entering for mft_no 0x%lx." , ni -> mft_no );
219219
220220 unmap_mft_record_page (ni );
221- up (& ni -> mrec_lock );
221+ mutex_unlock (& ni -> mrec_lock );
222222 atomic_dec (& ni -> count );
223223 /*
224224 * 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,
262262 * in which case just return it. If not found, add it to the base
263263 * inode before returning it.
264264 */
265- down (& base_ni -> extent_lock );
265+ mutex_lock (& base_ni -> extent_lock );
266266 if (base_ni -> nr_extents > 0 ) {
267267 extent_nis = base_ni -> ext .extent_ntfs_inos ;
268268 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,
275275 }
276276 }
277277 if (likely (ni != NULL )) {
278- up (& base_ni -> extent_lock );
278+ mutex_unlock (& base_ni -> extent_lock );
279279 atomic_dec (& base_ni -> count );
280280 /* We found the record; just have to map and return it. */
281281 m = map_mft_record (ni );
@@ -302,7 +302,7 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref,
302302 /* Record wasn't there. Get a new ntfs inode and initialize it. */
303303 ni = ntfs_new_extent_inode (base_ni -> vol -> sb , mft_no );
304304 if (unlikely (!ni )) {
305- up (& base_ni -> extent_lock );
305+ mutex_unlock (& base_ni -> extent_lock );
306306 atomic_dec (& base_ni -> count );
307307 return ERR_PTR (- ENOMEM );
308308 }
@@ -313,7 +313,7 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref,
313313 /* Now map the record. */
314314 m = map_mft_record (ni );
315315 if (IS_ERR (m )) {
316- up (& base_ni -> extent_lock );
316+ mutex_unlock (& base_ni -> extent_lock );
317317 atomic_dec (& base_ni -> count );
318318 ntfs_clear_extent_inode (ni );
319319 goto map_err_out ;
@@ -348,14 +348,14 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref,
348348 base_ni -> ext .extent_ntfs_inos = tmp ;
349349 }
350350 base_ni -> ext .extent_ntfs_inos [base_ni -> nr_extents ++ ] = ni ;
351- up (& base_ni -> extent_lock );
351+ mutex_unlock (& base_ni -> extent_lock );
352352 atomic_dec (& base_ni -> count );
353353 ntfs_debug ("Done 2." );
354354 * ntfs_ino = ni ;
355355 return m ;
356356unm_err_out :
357357 unmap_mft_record (ni );
358- up (& base_ni -> extent_lock );
358+ mutex_unlock (& base_ni -> extent_lock );
359359 atomic_dec (& base_ni -> count );
360360 /*
361361 * 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)
400400 BUG_ON (NInoAttr (ni ));
401401 mark_ntfs_record_dirty (ni -> page , ni -> page_ofs );
402402 /* Determine the base vfs inode and mark it dirty, too. */
403- down (& ni -> extent_lock );
403+ mutex_lock (& ni -> extent_lock );
404404 if (likely (ni -> nr_extents >= 0 ))
405405 base_ni = ni ;
406406 else
407407 base_ni = ni -> ext .base_ntfs_ino ;
408- up (& ni -> extent_lock );
408+ mutex_unlock (& ni -> extent_lock );
409409 __mark_inode_dirty (VFS_I (base_ni ), I_DIRTY_SYNC | I_DIRTY_DATASYNC );
410410}
411411
@@ -981,7 +981,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
981981 }
982982 ntfs_debug ("Inode 0x%lx is not dirty." , mft_no );
983983 /* 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 ))) {
985985 ntfs_debug ("Mft record 0x%lx is already locked, do "
986986 "not write it." , mft_no );
987987 atomic_dec (& ni -> count );
@@ -1041,13 +1041,13 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
10411041 * corresponding to this extent mft record attached.
10421042 */
10431043 ni = NTFS_I (vi );
1044- down (& ni -> extent_lock );
1044+ mutex_lock (& ni -> extent_lock );
10451045 if (ni -> nr_extents <= 0 ) {
10461046 /*
10471047 * The base inode has no attached extent inodes, write this
10481048 * extent mft record.
10491049 */
1050- up (& ni -> extent_lock );
1050+ mutex_unlock (& ni -> extent_lock );
10511051 iput (vi );
10521052 ntfs_debug ("Base inode 0x%lx has no attached extent inodes, "
10531053 "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,
10701070 * extent mft record.
10711071 */
10721072 if (!eni ) {
1073- up (& ni -> extent_lock );
1073+ mutex_unlock (& ni -> extent_lock );
10741074 iput (vi );
10751075 ntfs_debug ("Extent inode 0x%lx is not attached to its base "
10761076 "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,
10811081 mft_no , na .mft_no );
10821082 /* Take a reference to the extent ntfs inode. */
10831083 atomic_inc (& eni -> count );
1084- up (& ni -> extent_lock );
1084+ mutex_unlock (& ni -> extent_lock );
10851085 /*
10861086 * Found the extent inode coresponding to this extent mft record.
10871087 * Try to take the mft record lock.
10881088 */
1089- if (unlikely (down_trylock (& eni -> mrec_lock ))) {
1089+ if (unlikely (! mutex_trylock (& eni -> mrec_lock ))) {
10901090 atomic_dec (& eni -> count );
10911091 iput (vi );
10921092 ntfs_debug ("Extent mft record 0x%lx is already locked, do "
@@ -2709,7 +2709,7 @@ ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, const int mode,
27092709 * have its page mapped and it is very easy to do.
27102710 */
27112711 atomic_inc (& ni -> count );
2712- down (& ni -> mrec_lock );
2712+ mutex_lock (& ni -> mrec_lock );
27132713 ni -> page = page ;
27142714 ni -> page_ofs = ofs ;
27152715 /*
@@ -2796,22 +2796,22 @@ int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m)
27962796 BUG_ON (NInoAttr (ni ));
27972797 BUG_ON (ni -> nr_extents != -1 );
27982798
2799- down (& ni -> extent_lock );
2799+ mutex_lock (& ni -> extent_lock );
28002800 base_ni = ni -> ext .base_ntfs_ino ;
2801- up (& ni -> extent_lock );
2801+ mutex_unlock (& ni -> extent_lock );
28022802
28032803 BUG_ON (base_ni -> nr_extents <= 0 );
28042804
28052805 ntfs_debug ("Entering for extent inode 0x%lx, base inode 0x%lx.\n" ,
28062806 mft_no , base_ni -> mft_no );
28072807
2808- down (& base_ni -> extent_lock );
2808+ mutex_lock (& base_ni -> extent_lock );
28092809
28102810 /* Make sure we are holding the only reference to the extent inode. */
28112811 if (atomic_read (& ni -> count ) > 2 ) {
28122812 ntfs_error (vol -> sb , "Tried to free busy extent inode 0x%lx, "
28132813 "not freeing." , base_ni -> mft_no );
2814- up (& base_ni -> extent_lock );
2814+ mutex_unlock (& base_ni -> extent_lock );
28152815 return - EBUSY ;
28162816 }
28172817
@@ -2829,7 +2829,7 @@ int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m)
28292829 break ;
28302830 }
28312831
2832- up (& base_ni -> extent_lock );
2832+ mutex_unlock (& base_ni -> extent_lock );
28332833
28342834 if (unlikely (err )) {
28352835 ntfs_error (vol -> sb , "Extent inode 0x%lx is not attached to "
@@ -2888,7 +2888,7 @@ int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m)
28882888 return 0 ;
28892889rollback :
28902890 /* Rollback what we did... */
2891- down (& base_ni -> extent_lock );
2891+ mutex_lock (& base_ni -> extent_lock );
28922892 extent_nis = base_ni -> ext .extent_ntfs_inos ;
28932893 if (!(base_ni -> nr_extents & 3 )) {
28942894 int new_size = (base_ni -> nr_extents + 4 ) * sizeof (ntfs_inode * );
@@ -2897,7 +2897,7 @@ int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m)
28972897 if (unlikely (!extent_nis )) {
28982898 ntfs_error (vol -> sb , "Failed to allocate internal "
28992899 "buffer during rollback.%s" , es );
2900- up (& base_ni -> extent_lock );
2900+ mutex_unlock (& base_ni -> extent_lock );
29012901 NVolSetErrors (vol );
29022902 goto rollback_error ;
29032903 }
@@ -2912,7 +2912,7 @@ int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m)
29122912 m -> flags |= MFT_RECORD_IN_USE ;
29132913 m -> sequence_number = old_seq_no ;
29142914 extent_nis [base_ni -> nr_extents ++ ] = ni ;
2915- up (& base_ni -> extent_lock );
2915+ mutex_unlock (& base_ni -> extent_lock );
29162916 mark_mft_record_dirty (ni );
29172917 return err ;
29182918}
0 commit comments