lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 21 Jun 2023 19:55:29 +0100
From:   Matthew Wilcox <willy@...radead.org>
To:     Jeremy Bongio <bongiojp@...il.com>
Cc:     Ted Tso <tytso@....edu>, "Darrick J . Wong" <djwong@...nel.org>,
        Allison Henderson <allison.henderson@...cle.com>,
        linux-ext4@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        linux-xfs@...r.kernel.org
Subject: Re: [PATCH 1/1] For DIO writes with no mapped pages for inode, skip
 deferring completion.

On Wed, Jun 21, 2023 at 10:29:20AM -0700, Jeremy Bongio wrote:
> +++ b/fs/iomap/direct-io.c
> @@ -168,7 +168,9 @@ void iomap_dio_bio_end_io(struct bio *bio)
>  			struct task_struct *waiter = dio->submit.waiter;
>  			WRITE_ONCE(dio->submit.waiter, NULL);
>  			blk_wake_io_task(waiter);
> -		} else if (dio->flags & IOMAP_DIO_WRITE) {
> +		} else if (dio->flags & IOMAP_DIO_WRITE &&
> +			(!dio->iocb->ki_filp->f_inode ||
> +			    dio->iocb->ki_filp->f_inode->i_mapping->nrpages))) {

I don't think it's possible for file->f_inode to be NULL here, is it?
At any rate, that amount of indirection is just nasty.  How about this?

+++ b/fs/iomap/direct-io.c
@@ -161,15 +161,19 @@ void iomap_dio_bio_end_io(struct bio *bio)
                        struct task_struct *waiter = dio->submit.waiter;
                        WRITE_ONCE(dio->submit.waiter, NULL);
                        blk_wake_io_task(waiter);
-               } else if (dio->flags & IOMAP_DIO_WRITE) {
+               } else {
                        struct inode *inode = file_inode(dio->iocb->ki_filp);

                        WRITE_ONCE(dio->iocb->private, NULL);
-                       INIT_WORK(&dio->aio.work, iomap_dio_complete_work);
-                       queue_work(inode->i_sb->s_dio_done_wq, &dio->aio.work);
-               } else {
-                       WRITE_ONCE(dio->iocb->private, NULL);
-                       iomap_dio_complete_work(&dio->aio.work);
+                       if (dio->flags & IOMAP_DIO_WRITE &&
+                           (inode->i_mapping->nrpages > 0) {
+                               INIT_WORK(&dio->aio.work,
+                                               iomap_dio_complete_work);
+                               queue_work(inode->i_sb->s_dio_done_wq,
+                                               &dio->aio.work);
+                       } else {
+                               iomap_dio_complete_work(&dio->aio.work);
+                       }
                }
        }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ