page-writeback.c (ff877ea80efa2015b6263766f78ee42c2a1b32f9) | page-writeback.c (19fd6231279be3c3bdd02ed99f9b0eb195978064) |
---|---|
1/* 2 * mm/page-writeback.c 3 * 4 * Copyright (C) 2002, Linus Torvalds. 5 * Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com> 6 * 7 * Contains functions related to writing back dirty pages at the 8 * address_space level. --- 1074 unchanged lines hidden (view full) --- 1083{ 1084 if (!TestSetPageDirty(page)) { 1085 struct address_space *mapping = page_mapping(page); 1086 struct address_space *mapping2; 1087 1088 if (!mapping) 1089 return 1; 1090 | 1/* 2 * mm/page-writeback.c 3 * 4 * Copyright (C) 2002, Linus Torvalds. 5 * Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com> 6 * 7 * Contains functions related to writing back dirty pages at the 8 * address_space level. --- 1074 unchanged lines hidden (view full) --- 1083{ 1084 if (!TestSetPageDirty(page)) { 1085 struct address_space *mapping = page_mapping(page); 1086 struct address_space *mapping2; 1087 1088 if (!mapping) 1089 return 1; 1090 |
1091 write_lock_irq(&mapping->tree_lock); | 1091 spin_lock_irq(&mapping->tree_lock); |
1092 mapping2 = page_mapping(page); 1093 if (mapping2) { /* Race with truncate? */ 1094 BUG_ON(mapping2 != mapping); 1095 WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page)); 1096 if (mapping_cap_account_dirty(mapping)) { 1097 __inc_zone_page_state(page, NR_FILE_DIRTY); 1098 __inc_bdi_stat(mapping->backing_dev_info, 1099 BDI_RECLAIMABLE); 1100 task_io_account_write(PAGE_CACHE_SIZE); 1101 } 1102 radix_tree_tag_set(&mapping->page_tree, 1103 page_index(page), PAGECACHE_TAG_DIRTY); 1104 } | 1092 mapping2 = page_mapping(page); 1093 if (mapping2) { /* Race with truncate? */ 1094 BUG_ON(mapping2 != mapping); 1095 WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page)); 1096 if (mapping_cap_account_dirty(mapping)) { 1097 __inc_zone_page_state(page, NR_FILE_DIRTY); 1098 __inc_bdi_stat(mapping->backing_dev_info, 1099 BDI_RECLAIMABLE); 1100 task_io_account_write(PAGE_CACHE_SIZE); 1101 } 1102 radix_tree_tag_set(&mapping->page_tree, 1103 page_index(page), PAGECACHE_TAG_DIRTY); 1104 } |
1105 write_unlock_irq(&mapping->tree_lock); | 1105 spin_unlock_irq(&mapping->tree_lock); |
1106 if (mapping->host) { 1107 /* !PageAnon && !swapper_space */ 1108 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); 1109 } 1110 return 1; 1111 } 1112 return 0; 1113} --- 139 unchanged lines hidden (view full) --- 1253{ 1254 struct address_space *mapping = page_mapping(page); 1255 int ret; 1256 1257 if (mapping) { 1258 struct backing_dev_info *bdi = mapping->backing_dev_info; 1259 unsigned long flags; 1260 | 1106 if (mapping->host) { 1107 /* !PageAnon && !swapper_space */ 1108 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); 1109 } 1110 return 1; 1111 } 1112 return 0; 1113} --- 139 unchanged lines hidden (view full) --- 1253{ 1254 struct address_space *mapping = page_mapping(page); 1255 int ret; 1256 1257 if (mapping) { 1258 struct backing_dev_info *bdi = mapping->backing_dev_info; 1259 unsigned long flags; 1260 |
1261 write_lock_irqsave(&mapping->tree_lock, flags); | 1261 spin_lock_irqsave(&mapping->tree_lock, flags); |
1262 ret = TestClearPageWriteback(page); 1263 if (ret) { 1264 radix_tree_tag_clear(&mapping->page_tree, 1265 page_index(page), 1266 PAGECACHE_TAG_WRITEBACK); 1267 if (bdi_cap_account_writeback(bdi)) { 1268 __dec_bdi_stat(bdi, BDI_WRITEBACK); 1269 __bdi_writeout_inc(bdi); 1270 } 1271 } | 1262 ret = TestClearPageWriteback(page); 1263 if (ret) { 1264 radix_tree_tag_clear(&mapping->page_tree, 1265 page_index(page), 1266 PAGECACHE_TAG_WRITEBACK); 1267 if (bdi_cap_account_writeback(bdi)) { 1268 __dec_bdi_stat(bdi, BDI_WRITEBACK); 1269 __bdi_writeout_inc(bdi); 1270 } 1271 } |
1272 write_unlock_irqrestore(&mapping->tree_lock, flags); | 1272 spin_unlock_irqrestore(&mapping->tree_lock, flags); |
1273 } else { 1274 ret = TestClearPageWriteback(page); 1275 } 1276 if (ret) 1277 dec_zone_page_state(page, NR_WRITEBACK); 1278 return ret; 1279} 1280 1281int test_set_page_writeback(struct page *page) 1282{ 1283 struct address_space *mapping = page_mapping(page); 1284 int ret; 1285 1286 if (mapping) { 1287 struct backing_dev_info *bdi = mapping->backing_dev_info; 1288 unsigned long flags; 1289 | 1273 } else { 1274 ret = TestClearPageWriteback(page); 1275 } 1276 if (ret) 1277 dec_zone_page_state(page, NR_WRITEBACK); 1278 return ret; 1279} 1280 1281int test_set_page_writeback(struct page *page) 1282{ 1283 struct address_space *mapping = page_mapping(page); 1284 int ret; 1285 1286 if (mapping) { 1287 struct backing_dev_info *bdi = mapping->backing_dev_info; 1288 unsigned long flags; 1289 |
1290 write_lock_irqsave(&mapping->tree_lock, flags); | 1290 spin_lock_irqsave(&mapping->tree_lock, flags); |
1291 ret = TestSetPageWriteback(page); 1292 if (!ret) { 1293 radix_tree_tag_set(&mapping->page_tree, 1294 page_index(page), 1295 PAGECACHE_TAG_WRITEBACK); 1296 if (bdi_cap_account_writeback(bdi)) 1297 __inc_bdi_stat(bdi, BDI_WRITEBACK); 1298 } 1299 if (!PageDirty(page)) 1300 radix_tree_tag_clear(&mapping->page_tree, 1301 page_index(page), 1302 PAGECACHE_TAG_DIRTY); | 1291 ret = TestSetPageWriteback(page); 1292 if (!ret) { 1293 radix_tree_tag_set(&mapping->page_tree, 1294 page_index(page), 1295 PAGECACHE_TAG_WRITEBACK); 1296 if (bdi_cap_account_writeback(bdi)) 1297 __inc_bdi_stat(bdi, BDI_WRITEBACK); 1298 } 1299 if (!PageDirty(page)) 1300 radix_tree_tag_clear(&mapping->page_tree, 1301 page_index(page), 1302 PAGECACHE_TAG_DIRTY); |
1303 write_unlock_irqrestore(&mapping->tree_lock, flags); | 1303 spin_unlock_irqrestore(&mapping->tree_lock, flags); |
1304 } else { 1305 ret = TestSetPageWriteback(page); 1306 } 1307 if (!ret) 1308 inc_zone_page_state(page, NR_WRITEBACK); 1309 return ret; 1310 1311} --- 15 unchanged lines hidden --- | 1304 } else { 1305 ret = TestSetPageWriteback(page); 1306 } 1307 if (!ret) 1308 inc_zone_page_state(page, NR_WRITEBACK); 1309 return ret; 1310 1311} --- 15 unchanged lines hidden --- |