Commit 5efccd17ceb0fc43837a331297c2c407969d7201
Committed by
Jens Axboe
1 parent
2eef33e439
Exists in
master
and in
7 other branches
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>
Showing 2 changed files with 80 additions and 80 deletions Side-by-side Diff
block/blk-core.c
... | ... | @@ -1684,6 +1684,35 @@ |
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 | 1716 | * __end_that_request_first - end I/O on a request |
1688 | 1717 | * @req: the request being processed |
1689 | 1718 | * @error: %0 for success, < %0 for error |
... | ... | @@ -1797,6 +1826,22 @@ |
1797 | 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 | 1846 | * queue lock must be held |
1802 | 1847 | */ |
... | ... | @@ -1826,78 +1871,6 @@ |
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 | 1874 | * blk_end_io - Generic end_io function to complete a request. |
1902 | 1875 | * @rq: the request being processed |
1903 | 1876 | * @error: %0 for success, < %0 for error |
... | ... | @@ -2005,6 +1978,33 @@ |
2005 | 1978 | return blk_end_io(rq, error, nr_bytes, bidi_bytes, NULL); |
2006 | 1979 | } |
2007 | 1980 | EXPORT_SYMBOL_GPL(blk_end_bidi_request); |
1981 | + | |
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 | 2008 | |
2009 | 2009 | /** |
2010 | 2010 | * blk_update_request - Special helper function for request stacking drivers |
include/linux/blkdev.h
... | ... | @@ -832,6 +832,14 @@ |
832 | 832 | extern void blkdev_dequeue_request(struct request *req); |
833 | 833 | |
834 | 834 | /* |
835 | + * blk_end_request() takes bytes instead of sectors as a complete size. | |
836 | + * blk_rq_bytes() returns bytes left to complete in the entire request. | |
837 | + * blk_rq_cur_bytes() returns bytes left to complete in the current segment. | |
838 | + */ | |
839 | +extern unsigned int blk_rq_bytes(struct request *rq); | |
840 | +extern unsigned int blk_rq_cur_bytes(struct request *rq); | |
841 | + | |
842 | +/* | |
835 | 843 | * blk_end_request() and friends. |
836 | 844 | * __blk_end_request() and end_request() must be called with |
837 | 845 | * the request queue spinlock acquired. |
... | ... | @@ -856,14 +864,6 @@ |
856 | 864 | extern void blk_abort_queue(struct request_queue *); |
857 | 865 | extern void blk_update_request(struct request *rq, int error, |
858 | 866 | unsigned int nr_bytes); |
859 | - | |
860 | -/* | |
861 | - * blk_end_request() takes bytes instead of sectors as a complete size. | |
862 | - * blk_rq_bytes() returns bytes left to complete in the entire request. | |
863 | - * blk_rq_cur_bytes() returns bytes left to complete in the current segment. | |
864 | - */ | |
865 | -extern unsigned int blk_rq_bytes(struct request *rq); | |
866 | -extern unsigned int blk_rq_cur_bytes(struct request *rq); | |
867 | 867 | |
868 | 868 | /* |
869 | 869 | * Access functions for manipulating queue properties |