diff options
Diffstat (limited to 'fs/xfs/xfs_filestream.c')
-rw-r--r-- | fs/xfs/xfs_filestream.c | 57 |
1 files changed, 15 insertions, 42 deletions
diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c index 7b9403690013..c8a8840e5027 100644 --- a/fs/xfs/xfs_filestream.c +++ b/fs/xfs/xfs_filestream.c | |||
@@ -318,17 +318,18 @@ out: | |||
318 | } | 318 | } |
319 | 319 | ||
320 | /* | 320 | /* |
321 | * Return the AG of the filestream the file or directory belongs to, or | 321 | * Find the right allocation group for a file, either by finding an |
322 | * NULLAGNUMBER otherwise. | 322 | * existing file stream or creating a new one. |
323 | * | ||
324 | * Returns NULLAGNUMBER in case of an error. | ||
323 | */ | 325 | */ |
324 | xfs_agnumber_t | 326 | xfs_agnumber_t |
325 | xfs_filestream_lookup_ag( | 327 | xfs_filestream_lookup_ag( |
326 | struct xfs_inode *ip) | 328 | struct xfs_inode *ip) |
327 | { | 329 | { |
328 | struct xfs_mount *mp = ip->i_mount; | 330 | struct xfs_mount *mp = ip->i_mount; |
329 | struct xfs_fstrm_item *item; | ||
330 | struct xfs_inode *pip = NULL; | 331 | struct xfs_inode *pip = NULL; |
331 | xfs_agnumber_t ag = NULLAGNUMBER; | 332 | xfs_agnumber_t startag, ag = NULLAGNUMBER; |
332 | int ref = 0; | 333 | int ref = 0; |
333 | struct xfs_mru_cache_elem *mru; | 334 | struct xfs_mru_cache_elem *mru; |
334 | 335 | ||
@@ -339,45 +340,13 @@ xfs_filestream_lookup_ag( | |||
339 | goto out; | 340 | goto out; |
340 | 341 | ||
341 | mru = xfs_mru_cache_lookup(mp->m_filestream, pip->i_ino); | 342 | mru = xfs_mru_cache_lookup(mp->m_filestream, pip->i_ino); |
342 | if (!mru) | ||
343 | goto out; | ||
344 | |||
345 | item = container_of(mru, struct xfs_fstrm_item, mru); | ||
346 | |||
347 | ag = item->ag; | ||
348 | xfs_mru_cache_done(mp->m_filestream); | ||
349 | |||
350 | ref = xfs_filestream_peek_ag(ip->i_mount, ag); | ||
351 | out: | ||
352 | TRACE_LOOKUP(mp, ip, pip, ag, ref); | ||
353 | IRELE(pip); | ||
354 | return ag; | ||
355 | } | ||
356 | |||
357 | /* | ||
358 | * Make sure a directory has a filestream associated with it. | ||
359 | * | ||
360 | * This is called when creating regular files in an directory that has | ||
361 | * filestreams enabled, so that a stream is ready by the time we need it | ||
362 | * in the allocator for the files inside the directory. | ||
363 | */ | ||
364 | int | ||
365 | xfs_filestream_associate( | ||
366 | struct xfs_inode *pip) | ||
367 | { | ||
368 | struct xfs_mount *mp = pip->i_mount; | ||
369 | struct xfs_mru_cache_elem *mru; | ||
370 | xfs_agnumber_t startag, ag; | ||
371 | |||
372 | ASSERT(S_ISDIR(pip->i_d.di_mode)); | ||
373 | |||
374 | /* | ||
375 | * If the directory already has a file stream associated we're done. | ||
376 | */ | ||
377 | mru = xfs_mru_cache_lookup(mp->m_filestream, pip->i_ino); | ||
378 | if (mru) { | 343 | if (mru) { |
344 | ag = container_of(mru, struct xfs_fstrm_item, mru)->ag; | ||
379 | xfs_mru_cache_done(mp->m_filestream); | 345 | xfs_mru_cache_done(mp->m_filestream); |
380 | return 0; | 346 | |
347 | ref = xfs_filestream_peek_ag(ip->i_mount, ag); | ||
348 | TRACE_LOOKUP(mp, ip, pip, ag, ref); | ||
349 | goto out; | ||
381 | } | 350 | } |
382 | 351 | ||
383 | /* | 352 | /* |
@@ -392,7 +361,11 @@ xfs_filestream_associate( | |||
392 | } else | 361 | } else |
393 | startag = XFS_INO_TO_AGNO(mp, pip->i_ino); | 362 | startag = XFS_INO_TO_AGNO(mp, pip->i_ino); |
394 | 363 | ||
395 | return xfs_filestream_pick_ag(pip, startag, &ag, 0, 0); | 364 | if (xfs_filestream_pick_ag(pip, startag, &ag, 0, 0)) |
365 | ag = NULLAGNUMBER; | ||
366 | out: | ||
367 | IRELE(pip); | ||
368 | return ag; | ||
396 | } | 369 | } |
397 | 370 | ||
398 | /* | 371 | /* |