Skip to content

Commit 7ba167c

Browse files
committed
netfs: Switch to using unsigned long long rather than loff_t
Switch to using unsigned long long rather than loff_t in netfslib to avoid problems with the sign flipping in the maths when we're dealing with the byte at position 0x7fffffffffffffff. Signed-off-by: David Howells <[email protected]> Reviewed-by: Jeff Layton <[email protected]> cc: Ilya Dryomov <[email protected]> cc: Xiubo Li <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected]
1 parent 5a550a0 commit 7ba167c

File tree

9 files changed

+24
-20
lines changed

9 files changed

+24
-20
lines changed

fs/cachefiles/io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ cachefiles_do_prepare_read(struct netfs_cache_resources *cres,
493493
* boundary as appropriate.
494494
*/
495495
static enum netfs_io_source cachefiles_prepare_read(struct netfs_io_subrequest *subreq,
496-
loff_t i_size)
496+
unsigned long long i_size)
497497
{
498498
return cachefiles_do_prepare_read(&subreq->rreq->cache_resources,
499499
subreq->start, &subreq->len, i_size,

fs/ceph/addr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static void ceph_netfs_expand_readahead(struct netfs_io_request *rreq)
193193
* block, but do not exceed the file size, unless the original
194194
* request already exceeds it.
195195
*/
196-
new_end = min(round_up(end, lo->stripe_unit), rreq->i_size);
196+
new_end = umin(round_up(end, lo->stripe_unit), rreq->i_size);
197197
if (new_end > end && new_end <= rreq->start + max_len)
198198
rreq->len = new_end - rreq->start;
199199

fs/netfs/buffered_read.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq)
130130
}
131131

132132
static void netfs_cache_expand_readahead(struct netfs_io_request *rreq,
133-
loff_t *_start, size_t *_len, loff_t i_size)
133+
unsigned long long *_start,
134+
unsigned long long *_len,
135+
unsigned long long i_size)
134136
{
135137
struct netfs_cache_resources *cres = &rreq->cache_resources;
136138

fs/netfs/buffered_write.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ static void netfs_pages_written_back(struct netfs_io_request *wreq)
664664
last = (wreq->start + wreq->len - 1) / PAGE_SIZE;
665665
xas_for_each(&xas, folio, last) {
666666
WARN(!folio_test_writeback(folio),
667-
"bad %zx @%llx page %lx %lx\n",
667+
"bad %llx @%llx page %lx %lx\n",
668668
wreq->len, wreq->start, folio->index, last);
669669

670670
if ((finfo = netfs_folio_info(folio))) {

fs/netfs/io.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ netfs_rreq_prepare_read(struct netfs_io_request *rreq,
476476

477477
set:
478478
if (subreq->len > rreq->len)
479-
pr_warn("R=%08x[%u] SREQ>RREQ %zx > %zx\n",
479+
pr_warn("R=%08x[%u] SREQ>RREQ %zx > %llx\n",
480480
rreq->debug_id, subreq->debug_index,
481481
subreq->len, rreq->len);
482482

@@ -513,7 +513,7 @@ static bool netfs_rreq_submit_slice(struct netfs_io_request *rreq,
513513
subreq->start = rreq->start + rreq->submitted;
514514
subreq->len = io_iter->count;
515515

516-
_debug("slice %llx,%zx,%zx", subreq->start, subreq->len, rreq->submitted);
516+
_debug("slice %llx,%zx,%llx", subreq->start, subreq->len, rreq->submitted);
517517
list_add_tail(&subreq->rreq_link, &rreq->subrequests);
518518

519519
/* Call out to the cache to find out what it can do with the remaining
@@ -588,7 +588,7 @@ int netfs_begin_read(struct netfs_io_request *rreq, bool sync)
588588
atomic_set(&rreq->nr_outstanding, 1);
589589
io_iter = rreq->io_iter;
590590
do {
591-
_debug("submit %llx + %zx >= %llx",
591+
_debug("submit %llx + %llx >= %llx",
592592
rreq->start, rreq->submitted, rreq->i_size);
593593
if (rreq->origin == NETFS_DIO_READ &&
594594
rreq->start + rreq->submitted >= rreq->i_size)

fs/netfs/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static int netfs_requests_seq_show(struct seq_file *m, void *v)
6262

6363
rreq = list_entry(v, struct netfs_io_request, proc_link);
6464
seq_printf(m,
65-
"%08x %s %3d %2lx %4d %3d @%04llx %zx/%zx",
65+
"%08x %s %3d %2lx %4d %3d @%04llx %llx/%llx",
6666
rreq->debug_id,
6767
netfs_origins[rreq->origin],
6868
refcount_read(&rreq->ref),

fs/netfs/output.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ static void netfs_submit_writethrough(struct netfs_io_request *wreq, bool final)
439439
*/
440440
int netfs_advance_writethrough(struct netfs_io_request *wreq, size_t copied, bool to_page_end)
441441
{
442-
_enter("ic=%zu sb=%zu ws=%u cp=%zu tp=%u",
442+
_enter("ic=%zu sb=%llu ws=%u cp=%zu tp=%u",
443443
wreq->iter.count, wreq->submitted, wreq->wsize, copied, to_page_end);
444444

445445
wreq->iter.count += copied;
@@ -457,7 +457,7 @@ int netfs_end_writethrough(struct netfs_io_request *wreq, struct kiocb *iocb)
457457
{
458458
int ret = -EIOCBQUEUED;
459459

460-
_enter("ic=%zu sb=%zu ws=%u",
460+
_enter("ic=%zu sb=%llu ws=%u",
461461
wreq->iter.count, wreq->submitted, wreq->wsize);
462462

463463
if (wreq->submitted < wreq->io_iter.count)

include/linux/netfs.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ struct netfs_io_subrequest {
149149
struct work_struct work;
150150
struct list_head rreq_link; /* Link in rreq->subrequests */
151151
struct iov_iter io_iter; /* Iterator for this subrequest */
152-
loff_t start; /* Where to start the I/O */
152+
unsigned long long start; /* Where to start the I/O */
153153
size_t len; /* Size of the I/O */
154154
size_t transferred; /* Amount of data transferred */
155155
refcount_t ref;
@@ -205,15 +205,15 @@ struct netfs_io_request {
205205
atomic_t subreq_counter; /* Next subreq->debug_index */
206206
atomic_t nr_outstanding; /* Number of ops in progress */
207207
atomic_t nr_copy_ops; /* Number of copy-to-cache ops in progress */
208-
size_t submitted; /* Amount submitted for I/O so far */
209-
size_t len; /* Length of the request */
210208
size_t upper_len; /* Length can be extended to here */
209+
unsigned long long submitted; /* Amount submitted for I/O so far */
210+
unsigned long long len; /* Length of the request */
211211
size_t transferred; /* Amount to be indicated as transferred */
212212
short error; /* 0 or error that occurred */
213213
enum netfs_io_origin origin; /* Origin of the request */
214214
bool direct_bv_unpin; /* T if direct_bv[] must be unpinned */
215-
loff_t i_size; /* Size of the file */
216-
loff_t start; /* Start position */
215+
unsigned long long i_size; /* Size of the file */
216+
unsigned long long start; /* Start position */
217217
pgoff_t no_unlock_folio; /* Don't unlock this folio after read */
218218
refcount_t ref;
219219
unsigned long flags;
@@ -294,13 +294,15 @@ struct netfs_cache_ops {
294294

295295
/* Expand readahead request */
296296
void (*expand_readahead)(struct netfs_cache_resources *cres,
297-
loff_t *_start, size_t *_len, loff_t i_size);
297+
unsigned long long *_start,
298+
unsigned long long *_len,
299+
unsigned long long i_size);
298300

299301
/* Prepare a read operation, shortening it to a cached/uncached
300302
* boundary as appropriate.
301303
*/
302304
enum netfs_io_source (*prepare_read)(struct netfs_io_subrequest *subreq,
303-
loff_t i_size);
305+
unsigned long long i_size);
304306

305307
/* Prepare a write operation, working out what part of the write we can
306308
* actually do.

include/trace/events/netfs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ TRACE_EVENT(netfs_sreq,
280280
__entry->start = sreq->start;
281281
),
282282

283-
TP_printk("R=%08x[%u] %s %s f=%02x s=%llx %zx/%zx e=%d",
283+
TP_printk("R=%08x[%x] %s %s f=%02x s=%llx %zx/%zx e=%d",
284284
__entry->rreq, __entry->index,
285285
__print_symbolic(__entry->source, netfs_sreq_sources),
286286
__print_symbolic(__entry->what, netfs_sreq_traces),
@@ -320,7 +320,7 @@ TRACE_EVENT(netfs_failure,
320320
__entry->start = sreq ? sreq->start : 0;
321321
),
322322

323-
TP_printk("R=%08x[%d] %s f=%02x s=%llx %zx/%zx %s e=%d",
323+
TP_printk("R=%08x[%x] %s f=%02x s=%llx %zx/%zx %s e=%d",
324324
__entry->rreq, __entry->index,
325325
__print_symbolic(__entry->source, netfs_sreq_sources),
326326
__entry->flags,
@@ -436,7 +436,7 @@ TRACE_EVENT(netfs_write,
436436
__field(unsigned int, cookie )
437437
__field(enum netfs_write_trace, what )
438438
__field(unsigned long long, start )
439-
__field(size_t, len )
439+
__field(unsigned long long, len )
440440
),
441441

442442
TP_fast_assign(

0 commit comments

Comments
 (0)