| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* Storage object read/write |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. |
|---|
| 4 | 5 | * Written by David Howells (dhowells@redhat.com) |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or |
|---|
| 7 | | - * modify it under the terms of the GNU General Public Licence |
|---|
| 8 | | - * as published by the Free Software Foundation; either version |
|---|
| 9 | | - * 2 of the Licence, or (at your option) any later version. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #include <linux/mount.h> |
|---|
| .. | .. |
|---|
| 28 | 24 | container_of(wait, struct cachefiles_one_read, monitor); |
|---|
| 29 | 25 | struct cachefiles_object *object; |
|---|
| 30 | 26 | struct fscache_retrieval *op = monitor->op; |
|---|
| 31 | | - struct wait_bit_key *key = _key; |
|---|
| 27 | + struct wait_page_key *key = _key; |
|---|
| 32 | 28 | struct page *page = wait->private; |
|---|
| 33 | 29 | |
|---|
| 34 | 30 | ASSERT(key); |
|---|
| 35 | 31 | |
|---|
| 36 | 32 | _enter("{%lu},%u,%d,{%p,%u}", |
|---|
| 37 | 33 | monitor->netfs_page->index, mode, sync, |
|---|
| 38 | | - key->flags, key->bit_nr); |
|---|
| 34 | + key->page, key->bit_nr); |
|---|
| 39 | 35 | |
|---|
| 40 | | - if (key->flags != &page->flags || |
|---|
| 41 | | - key->bit_nr != PG_locked) |
|---|
| 36 | + if (key->page != page || key->bit_nr != PG_locked) |
|---|
| 42 | 37 | return 0; |
|---|
| 43 | 38 | |
|---|
| 44 | 39 | _debug("--- monitor %p %lx ---", page, page->flags); |
|---|
| .. | .. |
|---|
| 401 | 396 | struct cachefiles_object *object; |
|---|
| 402 | 397 | struct cachefiles_cache *cache; |
|---|
| 403 | 398 | struct inode *inode; |
|---|
| 404 | | - sector_t block0, block; |
|---|
| 399 | + sector_t block; |
|---|
| 405 | 400 | unsigned shift; |
|---|
| 406 | | - int ret; |
|---|
| 401 | + int ret, ret2; |
|---|
| 407 | 402 | |
|---|
| 408 | 403 | object = container_of(op->op.object, |
|---|
| 409 | 404 | struct cachefiles_object, fscache); |
|---|
| .. | .. |
|---|
| 417 | 412 | |
|---|
| 418 | 413 | inode = d_backing_inode(object->backer); |
|---|
| 419 | 414 | ASSERT(S_ISREG(inode->i_mode)); |
|---|
| 420 | | - ASSERT(inode->i_mapping->a_ops->bmap); |
|---|
| 421 | | - ASSERT(inode->i_mapping->a_ops->readpages); |
|---|
| 422 | 415 | |
|---|
| 423 | 416 | /* calculate the shift required to use bmap */ |
|---|
| 424 | 417 | shift = PAGE_SHIFT - inode->i_sb->s_blocksize_bits; |
|---|
| .. | .. |
|---|
| 433 | 426 | * enough for this as it doesn't indicate errors, but it's all we've |
|---|
| 434 | 427 | * got for the moment |
|---|
| 435 | 428 | */ |
|---|
| 436 | | - block0 = page->index; |
|---|
| 437 | | - block0 <<= shift; |
|---|
| 429 | + block = page->index; |
|---|
| 430 | + block <<= shift; |
|---|
| 438 | 431 | |
|---|
| 439 | | - block = inode->i_mapping->a_ops->bmap(inode->i_mapping, block0); |
|---|
| 432 | + ret2 = bmap(inode, &block); |
|---|
| 433 | + ASSERT(ret2 == 0); |
|---|
| 434 | + |
|---|
| 440 | 435 | _debug("%llx -> %llx", |
|---|
| 441 | | - (unsigned long long) block0, |
|---|
| 436 | + (unsigned long long) (page->index << shift), |
|---|
| 442 | 437 | (unsigned long long) block); |
|---|
| 443 | 438 | |
|---|
| 444 | 439 | if (block) { |
|---|
| .. | .. |
|---|
| 716 | 711 | |
|---|
| 717 | 712 | inode = d_backing_inode(object->backer); |
|---|
| 718 | 713 | ASSERT(S_ISREG(inode->i_mode)); |
|---|
| 719 | | - ASSERT(inode->i_mapping->a_ops->bmap); |
|---|
| 720 | | - ASSERT(inode->i_mapping->a_ops->readpages); |
|---|
| 721 | 714 | |
|---|
| 722 | 715 | /* calculate the shift required to use bmap */ |
|---|
| 723 | 716 | shift = PAGE_SHIFT - inode->i_sb->s_blocksize_bits; |
|---|
| .. | .. |
|---|
| 733 | 726 | |
|---|
| 734 | 727 | ret = space ? -ENODATA : -ENOBUFS; |
|---|
| 735 | 728 | list_for_each_entry_safe(page, _n, pages, lru) { |
|---|
| 736 | | - sector_t block0, block; |
|---|
| 729 | + sector_t block; |
|---|
| 737 | 730 | |
|---|
| 738 | 731 | /* we assume the absence or presence of the first block is a |
|---|
| 739 | 732 | * good enough indication for the page as a whole |
|---|
| .. | .. |
|---|
| 741 | 734 | * good enough for this as it doesn't indicate errors, but |
|---|
| 742 | 735 | * it's all we've got for the moment |
|---|
| 743 | 736 | */ |
|---|
| 744 | | - block0 = page->index; |
|---|
| 745 | | - block0 <<= shift; |
|---|
| 737 | + block = page->index; |
|---|
| 738 | + block <<= shift; |
|---|
| 746 | 739 | |
|---|
| 747 | | - block = inode->i_mapping->a_ops->bmap(inode->i_mapping, |
|---|
| 748 | | - block0); |
|---|
| 740 | + ret2 = bmap(inode, &block); |
|---|
| 741 | + ASSERT(ret2 == 0); |
|---|
| 742 | + |
|---|
| 749 | 743 | _debug("%llx -> %llx", |
|---|
| 750 | | - (unsigned long long) block0, |
|---|
| 744 | + (unsigned long long) (page->index << shift), |
|---|
| 751 | 745 | (unsigned long long) block); |
|---|
| 752 | 746 | |
|---|
| 753 | 747 | if (block) { |
|---|
| .. | .. |
|---|
| 941 | 935 | } |
|---|
| 942 | 936 | |
|---|
| 943 | 937 | data = kmap(page); |
|---|
| 944 | | - ret = __kernel_write(file, data, len, &pos); |
|---|
| 938 | + ret = kernel_write(file, data, len, &pos); |
|---|
| 945 | 939 | kunmap(page); |
|---|
| 946 | 940 | fput(file); |
|---|
| 947 | 941 | if (ret != len) |
|---|