aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs/attrib.c
diff options
context:
space:
mode:
authorAnton Altaparmakov <aia21@cantab.net>2005-03-07 16:43:38 -0500
committerAnton Altaparmakov <aia21@cantab.net>2005-05-05 06:20:49 -0400
commitc0c1cc0e46b36347f11b566f99087dc5e6fc1b89 (patch)
tree773105bdde7454d10dccc127048a9847f7e01f11 /fs/ntfs/attrib.c
parent271849a98849394ea85fa7caa8a1aaa2b3a849b7 (diff)
NTFS: - Fix bug in fs/ntfs/attrib.c::ntfs_find_vcn_nolock() where after
dropping the read lock and taking the write lock we were not checking whether someone else did not already do the work we wanted to do. - Rename ntfs_find_vcn_nolock() to ntfs_attr_find_vcn_nolock(). - Tidy up some comments in fs/ntfs/runlist.c. - Add LCN_ENOMEM and LCN_EIO definitions to fs/ntfs/runlist.h. Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
Diffstat (limited to 'fs/ntfs/attrib.c')
-rw-r--r--fs/ntfs/attrib.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index 1610f1cd2862..6de5e04e97a2 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -193,19 +193,19 @@ retry_remap:
193} 193}
194 194
195/** 195/**
196 * ntfs_find_vcn_nolock - find a vcn in the runlist described by an ntfs inode 196 * ntfs_attr_find_vcn_nolock - find a vcn in the runlist of an ntfs inode
197 * @ni: ntfs inode describing the runlist to search 197 * @ni: ntfs inode describing the runlist to search
198 * @vcn: vcn to find 198 * @vcn: vcn to find
199 * @write_locked: true if the runlist is locked for writing 199 * @write_locked: true if the runlist is locked for writing
200 * 200 *
201 * Find the virtual cluster number @vcn in the runlist described by the ntfs 201 * Find the virtual cluster number @vcn in the runlist described by the ntfs
202 * inode @ni and return the address of the runlist element containing the @vcn. 202 * inode @ni and return the address of the runlist element containing the @vcn.
203 * The runlist is left locked and the caller has to unlock it. In the error
204 * case, the runlist is left in the same locking state as on entry.
205 * 203 *
206 * Note if @write_locked is FALSE the lock may be dropped inside the function 204 * If the @vcn is not mapped yet, the attempt is made to map the attribute
207 * so you cannot rely on the runlist still being the same when this function 205 * extent containing the @vcn and the vcn to lcn conversion is retried.
208 * returns. 206 *
207 * If @write_locked is true the caller has locked the runlist for writing and
208 * if false for reading.
209 * 209 *
210 * Note you need to distinguish between the lcn of the returned runlist element 210 * Note you need to distinguish between the lcn of the returned runlist element
211 * being >= 0 and LCN_HOLE. In the later case you have to return zeroes on 211 * being >= 0 and LCN_HOLE. In the later case you have to return zeroes on
@@ -221,13 +221,12 @@ retry_remap:
221 * -ENOMEM - Not enough memory to map runlist. 221 * -ENOMEM - Not enough memory to map runlist.
222 * -EIO - Critical error (runlist/file is corrupt, i/o error, etc). 222 * -EIO - Critical error (runlist/file is corrupt, i/o error, etc).
223 * 223 *
224 * Locking: - The runlist must be unlocked on entry. 224 * Locking: - The runlist must be locked on entry and is left locked on return.
225 * - On failing return, the runlist is unlocked. 225 * - If @write_locked is FALSE, i.e. the runlist is locked for reading,
226 * - On successful return, the runlist is locked. If @need_write us 226 * the lock may be dropped inside the function so you cannot rely on
227 * true, it is locked for writing. Otherwise is is locked for 227 * the runlist still being the same when this function returns.
228 * reading.
229 */ 228 */
230runlist_element *ntfs_find_vcn_nolock(ntfs_inode *ni, const VCN vcn, 229runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni, const VCN vcn,
231 const BOOL write_locked) 230 const BOOL write_locked)
232{ 231{
233 runlist_element *rl; 232 runlist_element *rl;
@@ -268,6 +267,12 @@ retry_remap:
268 if (!write_locked) { 267 if (!write_locked) {
269 up_read(&ni->runlist.lock); 268 up_read(&ni->runlist.lock);
270 down_write(&ni->runlist.lock); 269 down_write(&ni->runlist.lock);
270 if (unlikely(ntfs_rl_vcn_to_lcn(ni->runlist.rl, vcn) !=
271 LCN_RL_NOT_MAPPED)) {
272 up_write(&ni->runlist.lock);
273 down_read(&ni->runlist.lock);
274 goto retry_remap;
275 }
271 } 276 }
272 err = ntfs_map_runlist_nolock(ni, vcn); 277 err = ntfs_map_runlist_nolock(ni, vcn);
273 if (!write_locked) { 278 if (!write_locked) {