|
54 | 54 | (CONGESTION_ON_THRESH(congestion_kb) - \
|
55 | 55 | (CONGESTION_ON_THRESH(congestion_kb) >> 2))
|
56 | 56 |
|
57 |
| - |
| 57 | +static inline struct ceph_snap_context *page_snap_context(struct page *page) |
| 58 | +{ |
| 59 | + if (PagePrivate(page)) |
| 60 | + return (void *)page->private; |
| 61 | + return NULL; |
| 62 | +} |
58 | 63 |
|
59 | 64 | /*
|
60 | 65 | * Dirty a page. Optimistically adjust accounting, on the assumption
|
@@ -142,10 +147,9 @@ static void ceph_invalidatepage(struct page *page, unsigned long offset)
|
142 | 147 | {
|
143 | 148 | struct inode *inode;
|
144 | 149 | struct ceph_inode_info *ci;
|
145 |
| - struct ceph_snap_context *snapc = (void *)page->private; |
| 150 | + struct ceph_snap_context *snapc = page_snap_context(page); |
146 | 151 |
|
147 | 152 | BUG_ON(!PageLocked(page));
|
148 |
| - BUG_ON(!page->private); |
149 | 153 | BUG_ON(!PagePrivate(page));
|
150 | 154 | BUG_ON(!page->mapping);
|
151 | 155 |
|
@@ -182,7 +186,6 @@ static int ceph_releasepage(struct page *page, gfp_t g)
|
182 | 186 | struct inode *inode = page->mapping ? page->mapping->host : NULL;
|
183 | 187 | dout("%p releasepage %p idx %lu\n", inode, page, page->index);
|
184 | 188 | WARN_ON(PageDirty(page));
|
185 |
| - WARN_ON(page->private); |
186 | 189 | WARN_ON(PagePrivate(page));
|
187 | 190 | return 0;
|
188 | 191 | }
|
@@ -443,15 +446,15 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
|
443 | 446 | osdc = &fsc->client->osdc;
|
444 | 447 |
|
445 | 448 | /* verify this is a writeable snap context */
|
446 |
| - snapc = (void *)page->private; |
| 449 | + snapc = page_snap_context(page); |
447 | 450 | if (snapc == NULL) {
|
448 | 451 | dout("writepage %p page %p not dirty?\n", inode, page);
|
449 | 452 | goto out;
|
450 | 453 | }
|
451 | 454 | oldest = get_oldest_context(inode, &snap_size);
|
452 | 455 | if (snapc->seq > oldest->seq) {
|
453 | 456 | dout("writepage %p page %p snapc %p not writeable - noop\n",
|
454 |
| - inode, page, (void *)page->private); |
| 457 | + inode, page, snapc); |
455 | 458 | /* we should only noop if called by kswapd */
|
456 | 459 | WARN_ON((current->flags & PF_MEMALLOC) == 0);
|
457 | 460 | ceph_put_snap_context(oldest);
|
@@ -591,7 +594,7 @@ static void writepages_finish(struct ceph_osd_request *req,
|
591 | 594 | clear_bdi_congested(&fsc->backing_dev_info,
|
592 | 595 | BLK_RW_ASYNC);
|
593 | 596 |
|
594 |
| - ceph_put_snap_context((void *)page->private); |
| 597 | + ceph_put_snap_context(page_snap_context(page)); |
595 | 598 | page->private = 0;
|
596 | 599 | ClearPagePrivate(page);
|
597 | 600 | dout("unlocking %d %p\n", i, page);
|
@@ -795,7 +798,7 @@ static int ceph_writepages_start(struct address_space *mapping,
|
795 | 798 | }
|
796 | 799 |
|
797 | 800 | /* only if matching snap context */
|
798 |
| - pgsnapc = (void *)page->private; |
| 801 | + pgsnapc = page_snap_context(page); |
799 | 802 | if (pgsnapc->seq > snapc->seq) {
|
800 | 803 | dout("page snapc %p %lld > oldest %p %lld\n",
|
801 | 804 | pgsnapc, pgsnapc->seq, snapc, snapc->seq);
|
@@ -984,7 +987,7 @@ static int ceph_update_writeable_page(struct file *file,
|
984 | 987 | BUG_ON(!ci->i_snap_realm);
|
985 | 988 | down_read(&mdsc->snap_rwsem);
|
986 | 989 | BUG_ON(!ci->i_snap_realm->cached_context);
|
987 |
| - snapc = (void *)page->private; |
| 990 | + snapc = page_snap_context(page); |
988 | 991 | if (snapc && snapc != ci->i_head_snapc) {
|
989 | 992 | /*
|
990 | 993 | * this page is already dirty in another (older) snap
|
|
0 commit comments