blk-merge.c (aa261f20589d894eb08b9a2b11c9672c548387cd) blk-merge.c (95465318849f7525f4dce1b720e4627f48963327)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Functions related to segment and merge handling
4 */
5#include <linux/kernel.h>
6#include <linux/module.h>
7#include <linux/bio.h>
8#include <linux/blkdev.h>

--- 172 unchanged lines hidden (view full) ---

181
182 start = bio->bi_iter.bi_sector & (pbs - 1);
183 end = (start + max_sectors) & ~(pbs - 1);
184 if (end > start)
185 return end - start;
186 return max_sectors & ~(lbs - 1);
187}
188
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Functions related to segment and merge handling
4 */
5#include <linux/kernel.h>
6#include <linux/module.h>
7#include <linux/bio.h>
8#include <linux/blkdev.h>

--- 172 unchanged lines hidden (view full) ---

181
182 start = bio->bi_iter.bi_sector & (pbs - 1);
183 end = (start + max_sectors) & ~(pbs - 1);
184 if (end > start)
185 return end - start;
186 return max_sectors & ~(lbs - 1);
187}
188
189/**
190 * get_max_segment_size() - maximum number of bytes to add as a single segment
191 * @lim: Request queue limits.
192 * @start_page: See below.
193 * @offset: Offset from @start_page where to add a segment.
194 *
195 * Returns the maximum number of bytes that can be added as a single segment.
196 */
189static inline unsigned get_max_segment_size(const struct queue_limits *lim,
190 struct page *start_page, unsigned long offset)
191{
192 unsigned long mask = lim->seg_boundary_mask;
193
194 offset = mask & (page_to_phys(start_page) + offset);
195
196 /*
197static inline unsigned get_max_segment_size(const struct queue_limits *lim,
198 struct page *start_page, unsigned long offset)
199{
200 unsigned long mask = lim->seg_boundary_mask;
201
202 offset = mask & (page_to_phys(start_page) + offset);
203
204 /*
197 * overflow may be triggered in case of zero page physical address
198 * on 32bit arch, use queue's max segment size when that happens.
205 * Prevent an overflow if mask = ULONG_MAX and offset = 0 by adding 1
206 * after having calculated the minimum.
199 */
207 */
200 return min_not_zero(mask - offset + 1,
201 (unsigned long)lim->max_segment_size);
208 return min(mask - offset, (unsigned long)lim->max_segment_size - 1) + 1;
202}
203
204/**
205 * bvec_split_segs - verify whether or not a bvec should be split in the middle
206 * @lim: [in] queue limits to split based on
207 * @bv: [in] bvec to examine
208 * @nsegs: [in,out] Number of segments in the bio being built. Incremented
209 * by the number of segments from @bv that may be appended to that

--- 935 unchanged lines hidden ---
209}
210
211/**
212 * bvec_split_segs - verify whether or not a bvec should be split in the middle
213 * @lim: [in] queue limits to split based on
214 * @bv: [in] bvec to examine
215 * @nsegs: [in,out] Number of segments in the bio being built. Incremented
216 * by the number of segments from @bv that may be appended to that

--- 935 unchanged lines hidden ---