mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-23 01:13:55 +07:00
4f024f3797
Immutable biovecs are going to require an explicit iterator. To implement immutable bvecs, a later patch is going to add a bi_bvec_done member to this struct; for now, this patch effectively just renames things. Signed-off-by: Kent Overstreet <kmo@daterainc.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: "Ed L. Cashin" <ecashin@coraid.com> Cc: Nick Piggin <npiggin@kernel.dk> Cc: Lars Ellenberg <drbd-dev@lists.linbit.com> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Matthew Wilcox <willy@linux.intel.com> Cc: Geoff Levand <geoff@infradead.org> Cc: Yehuda Sadeh <yehuda@inktank.com> Cc: Sage Weil <sage@inktank.com> Cc: Alex Elder <elder@inktank.com> Cc: ceph-devel@vger.kernel.org Cc: Joshua Morris <josh.h.morris@us.ibm.com> Cc: Philip Kelleher <pjk1939@linux.vnet.ibm.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Jeremy Fitzhardinge <jeremy@goop.org> Cc: Neil Brown <neilb@suse.de> Cc: Alasdair Kergon <agk@redhat.com> Cc: Mike Snitzer <snitzer@redhat.com> Cc: dm-devel@redhat.com Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: linux390@de.ibm.com Cc: Boaz Harrosh <bharrosh@panasas.com> Cc: Benny Halevy <bhalevy@tonian.com> Cc: "James E.J. Bottomley" <JBottomley@parallels.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Chris Mason <chris.mason@fusionio.com> Cc: "Theodore Ts'o" <tytso@mit.edu> Cc: Andreas Dilger <adilger.kernel@dilger.ca> Cc: Jaegeuk Kim <jaegeuk.kim@samsung.com> Cc: Steven Whitehouse <swhiteho@redhat.com> Cc: Dave Kleikamp <shaggy@kernel.org> Cc: Joern Engel <joern@logfs.org> Cc: Prasad Joshi <prasadjoshi.linux@gmail.com> Cc: Trond Myklebust <Trond.Myklebust@netapp.com> Cc: KONISHI Ryusuke <konishi.ryusuke@lab.ntt.co.jp> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Ben Myers <bpm@sgi.com> Cc: xfs@oss.sgi.com Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Len Brown <len.brown@intel.com> Cc: Pavel Machek <pavel@ucw.cz> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> Cc: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com> Cc: Ben Hutchings <ben@decadent.org.uk> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Guo Chao <yan@linux.vnet.ibm.com> Cc: Tejun Heo <tj@kernel.org> Cc: Asai Thambi S P <asamymuthupa@micron.com> Cc: Selvan Mani <smani@micron.com> Cc: Sam Bradshaw <sbradshaw@micron.com> Cc: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Cc: "Roger Pau Monné" <roger.pau@citrix.com> Cc: Jan Beulich <jbeulich@suse.com> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Cc: Ian Campbell <Ian.Campbell@citrix.com> Cc: Sebastian Ott <sebott@linux.vnet.ibm.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Jiang Liu <jiang.liu@huawei.com> Cc: Nitin Gupta <ngupta@vflare.org> Cc: Jerome Marchand <jmarchand@redhat.com> Cc: Joe Perches <joe@perches.com> Cc: Peng Tao <tao.peng@emc.com> Cc: Andy Adamson <andros@netapp.com> Cc: fanchaoting <fanchaoting@cn.fujitsu.com> Cc: Jie Liu <jeff.liu@oracle.com> Cc: Sunil Mushran <sunil.mushran@gmail.com> Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Cc: Namjae Jeon <namjae.jeon@samsung.com> Cc: Pankaj Kumar <pankaj.km@samsung.com> Cc: Dan Magenheimer <dan.magenheimer@oracle.com> Cc: Mel Gorman <mgorman@suse.de>6
104 lines
2.4 KiB
C
104 lines
2.4 KiB
C
/*
|
|
* This file provides functions for block I/O operations on swap/file.
|
|
*
|
|
* Copyright (C) 1998,2001-2005 Pavel Machek <pavel@ucw.cz>
|
|
* Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
|
|
*
|
|
* This file is released under the GPLv2.
|
|
*/
|
|
|
|
#include <linux/bio.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/pagemap.h>
|
|
#include <linux/swap.h>
|
|
|
|
#include "power.h"
|
|
|
|
/**
|
|
* submit - submit BIO request.
|
|
* @rw: READ or WRITE.
|
|
* @off physical offset of page.
|
|
* @page: page we're reading or writing.
|
|
* @bio_chain: list of pending biod (for async reading)
|
|
*
|
|
* Straight from the textbook - allocate and initialize the bio.
|
|
* If we're reading, make sure the page is marked as dirty.
|
|
* Then submit it and, if @bio_chain == NULL, wait.
|
|
*/
|
|
static int submit(int rw, struct block_device *bdev, sector_t sector,
|
|
struct page *page, struct bio **bio_chain)
|
|
{
|
|
const int bio_rw = rw | REQ_SYNC;
|
|
struct bio *bio;
|
|
|
|
bio = bio_alloc(__GFP_WAIT | __GFP_HIGH, 1);
|
|
bio->bi_iter.bi_sector = sector;
|
|
bio->bi_bdev = bdev;
|
|
bio->bi_end_io = end_swap_bio_read;
|
|
|
|
if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
|
|
printk(KERN_ERR "PM: Adding page to bio failed at %llu\n",
|
|
(unsigned long long)sector);
|
|
bio_put(bio);
|
|
return -EFAULT;
|
|
}
|
|
|
|
lock_page(page);
|
|
bio_get(bio);
|
|
|
|
if (bio_chain == NULL) {
|
|
submit_bio(bio_rw, bio);
|
|
wait_on_page_locked(page);
|
|
if (rw == READ)
|
|
bio_set_pages_dirty(bio);
|
|
bio_put(bio);
|
|
} else {
|
|
if (rw == READ)
|
|
get_page(page); /* These pages are freed later */
|
|
bio->bi_private = *bio_chain;
|
|
*bio_chain = bio;
|
|
submit_bio(bio_rw, bio);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int hib_bio_read_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
|
|
{
|
|
return submit(READ, hib_resume_bdev, page_off * (PAGE_SIZE >> 9),
|
|
virt_to_page(addr), bio_chain);
|
|
}
|
|
|
|
int hib_bio_write_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
|
|
{
|
|
return submit(WRITE, hib_resume_bdev, page_off * (PAGE_SIZE >> 9),
|
|
virt_to_page(addr), bio_chain);
|
|
}
|
|
|
|
int hib_wait_on_bio_chain(struct bio **bio_chain)
|
|
{
|
|
struct bio *bio;
|
|
struct bio *next_bio;
|
|
int ret = 0;
|
|
|
|
if (bio_chain == NULL)
|
|
return 0;
|
|
|
|
bio = *bio_chain;
|
|
if (bio == NULL)
|
|
return 0;
|
|
while (bio) {
|
|
struct page *page;
|
|
|
|
next_bio = bio->bi_private;
|
|
page = bio->bi_io_vec[0].bv_page;
|
|
wait_on_page_locked(page);
|
|
if (!PageUptodate(page) || PageError(page))
|
|
ret = -EIO;
|
|
put_page(page);
|
|
bio_put(bio);
|
|
bio = next_bio;
|
|
}
|
|
*bio_chain = NULL;
|
|
return ret;
|
|
}
|