diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/blkdev.h | 94 |
1 files changed, 82 insertions, 12 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1fa9dcf9aa6a..501f6845cc73 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
| @@ -840,27 +840,97 @@ extern unsigned int blk_rq_bytes(struct request *rq); | |||
| 840 | extern unsigned int blk_rq_cur_bytes(struct request *rq); | 840 | extern unsigned int blk_rq_cur_bytes(struct request *rq); |
| 841 | 841 | ||
| 842 | /* | 842 | /* |
| 843 | * blk_end_request() and friends. | 843 | * Request completion related functions. |
| 844 | * __blk_end_request() and end_request() must be called with | 844 | * |
| 845 | * the request queue spinlock acquired. | 845 | * blk_update_request() completes given number of bytes and updates |
| 846 | * the request without completing it. | ||
| 847 | * | ||
| 848 | * blk_end_request() and friends. __blk_end_request() and | ||
| 849 | * end_request() must be called with the request queue spinlock | ||
| 850 | * acquired. | ||
| 846 | * | 851 | * |
| 847 | * Several drivers define their own end_request and call | 852 | * Several drivers define their own end_request and call |
| 848 | * blk_end_request() for parts of the original function. | 853 | * blk_end_request() for parts of the original function. |
| 849 | * This prevents code duplication in drivers. | 854 | * This prevents code duplication in drivers. |
| 850 | */ | 855 | */ |
| 851 | extern int blk_end_request(struct request *rq, int error, | 856 | extern bool blk_update_request(struct request *rq, int error, |
| 852 | unsigned int nr_bytes); | 857 | unsigned int nr_bytes); |
| 853 | extern int __blk_end_request(struct request *rq, int error, | 858 | extern bool blk_end_bidi_request(struct request *rq, int error, |
| 854 | unsigned int nr_bytes); | 859 | unsigned int nr_bytes, |
| 855 | extern int blk_end_bidi_request(struct request *rq, int error, | 860 | unsigned int bidi_bytes); |
| 856 | unsigned int nr_bytes, unsigned int bidi_bytes); | 861 | extern bool __blk_end_bidi_request(struct request *rq, int error, |
| 857 | extern void end_request(struct request *, int); | 862 | unsigned int nr_bytes, |
| 863 | unsigned int bidi_bytes); | ||
| 864 | |||
| 865 | /** | ||
| 866 | * blk_end_request - Helper function for drivers to complete the request. | ||
| 867 | * @rq: the request being processed | ||
| 868 | * @error: %0 for success, < %0 for error | ||
| 869 | * @nr_bytes: number of bytes to complete | ||
| 870 | * | ||
| 871 | * Description: | ||
| 872 | * Ends I/O on a number of bytes attached to @rq. | ||
| 873 | * If @rq has leftover, sets it up for the next range of segments. | ||
| 874 | * | ||
| 875 | * Return: | ||
| 876 | * %false - we are done with this request | ||
| 877 | * %true - still buffers pending for this request | ||
| 878 | **/ | ||
| 879 | static inline bool blk_end_request(struct request *rq, int error, | ||
| 880 | unsigned int nr_bytes) | ||
| 881 | { | ||
| 882 | return blk_end_bidi_request(rq, error, nr_bytes, 0); | ||
| 883 | } | ||
| 884 | |||
| 885 | /** | ||
| 886 | * __blk_end_request - Helper function for drivers to complete the request. | ||
| 887 | * @rq: the request being processed | ||
| 888 | * @error: %0 for success, < %0 for error | ||
| 889 | * @nr_bytes: number of bytes to complete | ||
| 890 | * | ||
| 891 | * Description: | ||
| 892 | * Must be called with queue lock held unlike blk_end_request(). | ||
| 893 | * | ||
| 894 | * Return: | ||
| 895 | * %false - we are done with this request | ||
| 896 | * %true - still buffers pending for this request | ||
| 897 | **/ | ||
| 898 | static inline bool __blk_end_request(struct request *rq, int error, | ||
| 899 | unsigned int nr_bytes) | ||
| 900 | { | ||
| 901 | return __blk_end_bidi_request(rq, error, nr_bytes, 0); | ||
| 902 | } | ||
| 903 | |||
| 904 | /** | ||
| 905 | * end_request - end I/O on the current segment of the request | ||
| 906 | * @rq: the request being processed | ||
| 907 | * @uptodate: error value or %0/%1 uptodate flag | ||
| 908 | * | ||
| 909 | * Description: | ||
| 910 | * Ends I/O on the current segment of a request. If that is the only | ||
| 911 | * remaining segment, the request is also completed and freed. | ||
| 912 | * | ||
| 913 | * This is a remnant of how older block drivers handled I/O completions. | ||
| 914 | * Modern drivers typically end I/O on the full request in one go, unless | ||
| 915 | * they have a residual value to account for. For that case this function | ||
| 916 | * isn't really useful, unless the residual just happens to be the | ||
| 917 | * full current segment. In other words, don't use this function in new | ||
| 918 | * code. Use blk_end_request() or __blk_end_request() to end a request. | ||
| 919 | **/ | ||
| 920 | static inline void end_request(struct request *rq, int uptodate) | ||
| 921 | { | ||
| 922 | int error = 0; | ||
| 923 | |||
| 924 | if (uptodate <= 0) | ||
| 925 | error = uptodate ? uptodate : -EIO; | ||
| 926 | |||
| 927 | __blk_end_bidi_request(rq, error, rq->hard_cur_sectors << 9, 0); | ||
| 928 | } | ||
| 929 | |||
| 858 | extern void blk_complete_request(struct request *); | 930 | extern void blk_complete_request(struct request *); |
| 859 | extern void __blk_complete_request(struct request *); | 931 | extern void __blk_complete_request(struct request *); |
| 860 | extern void blk_abort_request(struct request *); | 932 | extern void blk_abort_request(struct request *); |
| 861 | extern void blk_abort_queue(struct request_queue *); | 933 | extern void blk_abort_queue(struct request_queue *); |
| 862 | extern void blk_update_request(struct request *rq, int error, | ||
| 863 | unsigned int nr_bytes); | ||
| 864 | 934 | ||
| 865 | /* | 935 | /* |
| 866 | * Access functions for manipulating queue properties | 936 | * Access functions for manipulating queue properties |
