File tree Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -304,26 +304,19 @@ xfs_filestream_create_association(
304
304
* for us, so all we need to do here is take another active reference to
305
305
* the perag for the cached association.
306
306
*
307
- * If we fail to store the association, we need to drop the fstrms
308
- * counter as well as drop the perag reference we take here for the
309
- * item. We do not need to return an error for this failure - as long as
310
- * we return a referenced AG, the allocation can still go ahead just
311
- * fine.
307
+ * If we fail to store the association, we do not need to return an
308
+ * error for this failure - as long as we return a referenced AG, the
309
+ * allocation can still go ahead just fine.
312
310
*/
313
311
item = kmalloc (sizeof (* item ), GFP_KERNEL | __GFP_RETRY_MAYFAIL );
314
312
if (!item )
315
313
goto out_put_fstrms ;
316
314
317
315
atomic_inc (& pag_group (args -> pag )-> xg_active_ref );
318
316
item -> pag = args -> pag ;
319
- error = xfs_mru_cache_insert (mp -> m_filestream , pino , & item -> mru );
320
- if (error )
321
- goto out_free_item ;
317
+ xfs_mru_cache_insert (mp -> m_filestream , pino , & item -> mru );
322
318
return 0 ;
323
319
324
- out_free_item :
325
- xfs_perag_rele (item -> pag );
326
- kfree (item );
327
320
out_put_fstrms :
328
321
atomic_dec (& args -> pag -> pagf_fstrms );
329
322
return 0 ;
Original file line number Diff line number Diff line change @@ -414,21 +414,24 @@ xfs_mru_cache_destroy(
414
414
* To insert an element, call xfs_mru_cache_insert() with the data store, the
415
415
* element's key and the client data pointer. This function returns 0 on
416
416
* success or ENOMEM if memory for the data element couldn't be allocated.
417
+ *
418
+ * The passed in elem is freed through the per-cache free_func on failure.
417
419
*/
418
420
int
419
421
xfs_mru_cache_insert (
420
422
struct xfs_mru_cache * mru ,
421
423
unsigned long key ,
422
424
struct xfs_mru_cache_elem * elem )
423
425
{
424
- int error ;
426
+ int error = - EINVAL ;
425
427
426
428
ASSERT (mru && mru -> lists );
427
429
if (!mru || !mru -> lists )
428
- return - EINVAL ;
430
+ goto out_free ;
429
431
432
+ error = - ENOMEM ;
430
433
if (radix_tree_preload (GFP_KERNEL ))
431
- return - ENOMEM ;
434
+ goto out_free ;
432
435
433
436
INIT_LIST_HEAD (& elem -> list_node );
434
437
elem -> key = key ;
@@ -440,6 +443,12 @@ xfs_mru_cache_insert(
440
443
_xfs_mru_cache_list_insert (mru , elem );
441
444
spin_unlock (& mru -> lock );
442
445
446
+ if (error )
447
+ goto out_free ;
448
+ return 0 ;
449
+
450
+ out_free :
451
+ mru -> free_func (mru -> data , elem );
443
452
return error ;
444
453
}
445
454
You can’t perform that action at this time.
0 commit comments