@@ -1434,7 +1434,6 @@ static int zswap_writeback_entry(struct zswap_entry *entry,
1434
1434
struct page * page ;
1435
1435
struct mempolicy * mpol ;
1436
1436
bool page_was_allocated ;
1437
- int ret ;
1438
1437
struct writeback_control wbc = {
1439
1438
.sync_mode = WB_SYNC_NONE ,
1440
1439
};
@@ -1443,16 +1442,17 @@ static int zswap_writeback_entry(struct zswap_entry *entry,
1443
1442
mpol = get_task_policy (current );
1444
1443
page = __read_swap_cache_async (swpentry , GFP_KERNEL , mpol ,
1445
1444
NO_INTERLEAVE_INDEX , & page_was_allocated , true);
1446
- if (!page ) {
1447
- ret = - ENOMEM ;
1448
- goto fail ;
1449
- }
1445
+ if (!page )
1446
+ return - ENOMEM ;
1450
1447
1451
- /* Found an existing page, we raced with load/swapin */
1448
+ /*
1449
+ * Found an existing page, we raced with load/swapin. We generally
1450
+ * writeback cold pages from zswap, and swapin means the page just
1451
+ * became hot. Skip this page and let the caller find another one.
1452
+ */
1452
1453
if (!page_was_allocated ) {
1453
1454
put_page (page );
1454
- ret = - EEXIST ;
1455
- goto fail ;
1455
+ return - EEXIST ;
1456
1456
}
1457
1457
1458
1458
/*
@@ -1466,8 +1466,7 @@ static int zswap_writeback_entry(struct zswap_entry *entry,
1466
1466
if (zswap_rb_search (& tree -> rbroot , swp_offset (entry -> swpentry )) != entry ) {
1467
1467
spin_unlock (& tree -> lock );
1468
1468
delete_from_swap_cache (page_folio (page ));
1469
- ret = - ENOMEM ;
1470
- goto fail ;
1469
+ return - ENOMEM ;
1471
1470
}
1472
1471
spin_unlock (& tree -> lock );
1473
1472
@@ -1483,15 +1482,7 @@ static int zswap_writeback_entry(struct zswap_entry *entry,
1483
1482
__swap_writepage (page , & wbc );
1484
1483
put_page (page );
1485
1484
1486
- return ret ;
1487
-
1488
- fail :
1489
- /*
1490
- * If we get here because the page is already in swapcache, a
1491
- * load may be happening concurrently. It is safe and okay to
1492
- * not free the entry. It is also okay to return !0.
1493
- */
1494
- return ret ;
1485
+ return 0 ;
1495
1486
}
1496
1487
1497
1488
static int zswap_is_page_same_filled (void * ptr , unsigned long * value )
0 commit comments