lkml.org 
[lkml]   [2023]   [Jan]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v5 8/9] iov_iter, block: Make bio structs pin pages rather than ref'ing if appropriate
Date
Christoph Hellwig <hch@infradead.org> wrote:

> if (cleanup_mode & FOLL_GET) {
> WARN_ON_ONCE(bio_test_flag(bio, BIO_PAGE_PINNED));
> bio_set_flag(bio, BIO_PAGE_REFFED);
> }
> if (cleanup_mode & FOLL_PIN) {
> WARN_ON_ONCE(bio_test_flag(bio, BIO_PAGE_REFFED));
> bio_set_flag(bio, BIO_PAGE_PINNED);
> }

That won't necessarily work as you might get back cleanup_mode == 0, in which
case both flags are cleared - and neither warning will trip on the next
addition.

I could change it so that rather than using a pair of flags, it uses a
four-state variable (which can be stored in bi_flags): BIO_PAGE_DEFAULT,
BIO_PAGE_REFFED, BIO_PAGE_PINNED, BIO_PAGE_NO_CLEANUP, say.

Or I could add an extra flag to say that the setting is locked. Or we could
just live with the scenario I outlined possibly happening.

David

\
 
 \ /
  Last update: 2023-03-26 23:37    [W:0.336 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site