diff options
author | Tejun Heo <tj@kernel.org> | 2009-04-22 22:05:18 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-04-28 01:37:34 -0400 |
commit | 5efccd17ceb0fc43837a331297c2c407969d7201 (patch) | |
tree | 6678ebea73ffc9f2ad35029eaaf49e68073e4e88 /block | |
parent | 2eef33e439ba9ae387cdc3f1abcef2f3f6c4e7a8 (diff) |
block: reorder request completion functions
Reorder request completion functions such that
* All request completion functions are located together.
* Functions which are used by only one caller is put right above the
caller.
* end_request() is put after other completion functions but before
blk_update_request().
This change is for completion function cleanup which will follow.
[ Impact: cleanup, code reorganization ]
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-core.c | 144 |
1 files changed, 72 insertions, 72 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index cf10dfcda99d..406a93e526b6 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -1684,6 +1684,35 @@ static void blk_account_io_done(struct request *req) | |||
1684 | } | 1684 | } |
1685 | 1685 | ||
1686 | /** | 1686 | /** |
1687 | * blk_rq_bytes - Returns bytes left to complete in the entire request | ||
1688 | * @rq: the request being processed | ||
1689 | **/ | ||
1690 | unsigned int blk_rq_bytes(struct request *rq) | ||
1691 | { | ||
1692 | if (blk_fs_request(rq)) | ||
1693 | return rq->hard_nr_sectors << 9; | ||
1694 | |||
1695 | return rq->data_len; | ||
1696 | } | ||
1697 | EXPORT_SYMBOL_GPL(blk_rq_bytes); | ||
1698 | |||
1699 | /** | ||
1700 | * blk_rq_cur_bytes - Returns bytes left to complete in the current segment | ||
1701 | * @rq: the request being processed | ||
1702 | **/ | ||
1703 | unsigned int blk_rq_cur_bytes(struct request *rq) | ||
1704 | { | ||
1705 | if (blk_fs_request(rq)) | ||
1706 | return rq->current_nr_sectors << 9; | ||
1707 | |||
1708 | if (rq->bio) | ||
1709 | return rq->bio->bi_size; | ||
1710 | |||
1711 | return rq->data_len; | ||
1712 | } | ||
1713 | EXPORT_SYMBOL_GPL(blk_rq_cur_bytes); | ||
1714 | |||
1715 | /** | ||
1687 | * __end_that_request_first - end I/O on a request | 1716 | * __end_that_request_first - end I/O on a request |
1688 | * @req: the request being processed | 1717 | * @req: the request being processed |
1689 | * @error: %0 for success, < %0 for error | 1718 | * @error: %0 for success, < %0 for error |
@@ -1797,6 +1826,22 @@ static int __end_that_request_first(struct request *req, int error, | |||
1797 | return 1; | 1826 | return 1; |
1798 | } | 1827 | } |
1799 | 1828 | ||
1829 | static int end_that_request_data(struct request *rq, int error, | ||
1830 | unsigned int nr_bytes, unsigned int bidi_bytes) | ||
1831 | { | ||
1832 | if (rq->bio) { | ||
1833 | if (__end_that_request_first(rq, error, nr_bytes)) | ||
1834 | return 1; | ||
1835 | |||
1836 | /* Bidi request must be completed as a whole */ | ||
1837 | if (blk_bidi_rq(rq) && | ||
1838 | __end_that_request_first(rq->next_rq, error, bidi_bytes)) | ||
1839 | return 1; | ||
1840 | } | ||
1841 | |||
1842 | return 0; | ||
1843 | } | ||
1844 | |||
1800 | /* | 1845 | /* |
1801 | * queue lock must be held | 1846 | * queue lock must be held |
1802 | */ | 1847 | */ |
@@ -1826,78 +1871,6 @@ static void end_that_request_last(struct request *req, int error) | |||
1826 | } | 1871 | } |
1827 | 1872 | ||
1828 | /** | 1873 | /** |
1829 | * blk_rq_bytes - Returns bytes left to complete in the entire request | ||
1830 | * @rq: the request being processed | ||
1831 | **/ | ||
1832 | unsigned int blk_rq_bytes(struct request *rq) | ||
1833 | { | ||
1834 | if (blk_fs_request(rq)) | ||
1835 | return rq->hard_nr_sectors << 9; | ||
1836 | |||
1837 | return rq->data_len; | ||
1838 | } | ||
1839 | EXPORT_SYMBOL_GPL(blk_rq_bytes); | ||
1840 | |||
1841 | /** | ||
1842 | * blk_rq_cur_bytes - Returns bytes left to complete in the current segment | ||
1843 | * @rq: the request being processed | ||
1844 | **/ | ||
1845 | unsigned int blk_rq_cur_bytes(struct request *rq) | ||
1846 | { | ||
1847 | if (blk_fs_request(rq)) | ||
1848 | return rq->current_nr_sectors << 9; | ||
1849 | |||
1850 | if (rq->bio) | ||
1851 | return rq->bio->bi_size; | ||
1852 | |||
1853 | return rq->data_len; | ||
1854 | } | ||
1855 | EXPORT_SYMBOL_GPL(blk_rq_cur_bytes); | ||
1856 | |||
1857 | /** | ||
1858 | * end_request - end I/O on the current segment of the request | ||
1859 | * @req: the request being processed | ||
1860 | * @uptodate: error value or %0/%1 uptodate flag | ||
1861 | * | ||
1862 | * Description: | ||
1863 | * Ends I/O on the current segment of a request. If that is the only | ||
1864 | * remaining segment, the request is also completed and freed. | ||
1865 | * | ||
1866 | * This is a remnant of how older block drivers handled I/O completions. | ||
1867 | * Modern drivers typically end I/O on the full request in one go, unless | ||
1868 | * they have a residual value to account for. For that case this function | ||
1869 | * isn't really useful, unless the residual just happens to be the | ||
1870 | * full current segment. In other words, don't use this function in new | ||
1871 | * code. Use blk_end_request() or __blk_end_request() to end a request. | ||
1872 | **/ | ||
1873 | void end_request(struct request *req, int uptodate) | ||
1874 | { | ||
1875 | int error = 0; | ||
1876 | |||
1877 | if (uptodate <= 0) | ||
1878 | error = uptodate ? uptodate : -EIO; | ||
1879 | |||
1880 | __blk_end_request(req, error, req->hard_cur_sectors << 9); | ||
1881 | } | ||
1882 | EXPORT_SYMBOL(end_request); | ||
1883 | |||
1884 | static int end_that_request_data(struct request *rq, int error, | ||
1885 | unsigned int nr_bytes, unsigned int bidi_bytes) | ||
1886 | { | ||
1887 | if (rq->bio) { | ||
1888 | if (__end_that_request_first(rq, error, nr_bytes)) | ||
1889 | return 1; | ||
1890 | |||
1891 | /* Bidi request must be completed as a whole */ | ||
1892 | if (blk_bidi_rq(rq) && | ||
1893 | __end_that_request_first(rq->next_rq, error, bidi_bytes)) | ||
1894 | return 1; | ||
1895 | } | ||
1896 | |||
1897 | return 0; | ||
1898 | } | ||
1899 | |||
1900 | /** | ||
1901 | * blk_end_io - Generic end_io function to complete a request. | 1874 | * blk_end_io - Generic end_io function to complete a request. |
1902 | * @rq: the request being processed | 1875 | * @rq: the request being processed |
1903 | * @error: %0 for success, < %0 for error | 1876 | * @error: %0 for success, < %0 for error |
@@ -2007,6 +1980,33 @@ int blk_end_bidi_request(struct request *rq, int error, unsigned int nr_bytes, | |||
2007 | EXPORT_SYMBOL_GPL(blk_end_bidi_request); | 1980 | EXPORT_SYMBOL_GPL(blk_end_bidi_request); |
2008 | 1981 | ||
2009 | /** | 1982 | /** |
1983 | * end_request - end I/O on the current segment of the request | ||
1984 | * @req: the request being processed | ||
1985 | * @uptodate: error value or %0/%1 uptodate flag | ||
1986 | * | ||
1987 | * Description: | ||
1988 | * Ends I/O on the current segment of a request. If that is the only | ||
1989 | * remaining segment, the request is also completed and freed. | ||
1990 | * | ||
1991 | * This is a remnant of how older block drivers handled I/O completions. | ||
1992 | * Modern drivers typically end I/O on the full request in one go, unless | ||
1993 | * they have a residual value to account for. For that case this function | ||
1994 | * isn't really useful, unless the residual just happens to be the | ||
1995 | * full current segment. In other words, don't use this function in new | ||
1996 | * code. Use blk_end_request() or __blk_end_request() to end a request. | ||
1997 | **/ | ||
1998 | void end_request(struct request *req, int uptodate) | ||
1999 | { | ||
2000 | int error = 0; | ||
2001 | |||
2002 | if (uptodate <= 0) | ||
2003 | error = uptodate ? uptodate : -EIO; | ||
2004 | |||
2005 | __blk_end_request(req, error, req->hard_cur_sectors << 9); | ||
2006 | } | ||
2007 | EXPORT_SYMBOL(end_request); | ||
2008 | |||
2009 | /** | ||
2010 | * blk_update_request - Special helper function for request stacking drivers | 2010 | * blk_update_request - Special helper function for request stacking drivers |
2011 | * @rq: the request being processed | 2011 | * @rq: the request being processed |
2012 | * @error: %0 for success, < %0 for error | 2012 | * @error: %0 for success, < %0 for error |