Patchwork [05/11] ext4: remove ext4_end_io()

login
register
mail settings
Submitter Dmitri Monakho
Date Sept. 28, 2012, 3:44 p.m.
Message ID <1348847051-6746-6-git-send-email-dmonakhov@openvz.org>
Download mbox | patch
Permalink /patch/187814/
State Accepted
Headers show

Comments

Dmitri Monakho - Sept. 28, 2012, 3:44 p.m.
RFC_MESSAGE: It is up to committer whenever pick or drop this patch.
Only one user exist, so it may be resonable move it inside
caller's body. The only disadvantage is that makes end_do_flush_completed_IO()
less readable.


COMMIT_MESSAGE:
ext4_do_flush_completed_IO() is the only user of this function.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/ext4/page-io.c |   56 ++++++++++++++++++++--------------------------------
 1 files changed, 22 insertions(+), 34 deletions(-)
Anatol Pomozov - Oct. 4, 2012, 10:57 p.m.
Hi

On Fri, Sep 28, 2012 at 8:44 AM, Dmitry Monakhov <dmonakhov@openvz.org> wrote:
> RFC_MESSAGE: It is up to committer whenever pick or drop this patch.
> Only one user exist, so it may be resonable move it inside
> caller's body. The only disadvantage is that makes end_do_flush_completed_IO()
> less readable.
>
>
> COMMIT_MESSAGE:
> ext4_do_flush_completed_IO() is the only user of this function.
>
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> ---
>  fs/ext4/page-io.c |   56 ++++++++++++++++++++--------------------------------
>  1 files changed, 22 insertions(+), 34 deletions(-)
>
> diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
> index 5b24c40..0435688 100644
> --- a/fs/ext4/page-io.c
> +++ b/fs/ext4/page-io.c
> @@ -84,37 +84,6 @@ void ext4_free_io_end(ext4_io_end_t *io)
>         kmem_cache_free(io_end_cachep, io);
>  }
>
> -/* check a range of space and convert unwritten extents to written. */
> -static int ext4_end_io(ext4_io_end_t *io)
> -{
> -       struct inode *inode = io->inode;
> -       loff_t offset = io->offset;
> -       ssize_t size = io->size;
> -       int ret = 0;
> -
> -       ext4_debug("ext4_end_io_nolock: io 0x%p from inode %lu,list->next 0x%p,"
> -                  "list->prev 0x%p\n",
> -                  io, inode->i_ino, io->list.next, io->list.prev);
> -
> -       ret = ext4_convert_unwritten_extents(inode, offset, size);
> -       if (ret < 0) {
> -               ext4_msg(inode->i_sb, KERN_EMERG,
> -                        "failed to convert unwritten extents to written "
> -                        "extents -- potential data loss!  "
> -                        "(inode %lu, offset %llu, size %zd, error %d)",
> -                        inode->i_ino, offset, size, ret);
> -       }
> -       if (io->iocb)
> -               aio_complete(io->iocb, io->result, 0);
> -
> -       if (io->flag & EXT4_IO_END_DIRECT)
> -               inode_dio_done(inode);
> -       /* Wake up anyone waiting on unwritten extent conversion */
> -       if (atomic_dec_and_test(&EXT4_I(inode)->i_unwritten))
> -               wake_up_all(ext4_ioend_wq(io->inode));
> -       return ret;
> -}
> -
>  static void dump_completed_IO(struct inode *inode)
>  {
>  #ifdef EXT4FS_DEBUG
> @@ -183,9 +152,28 @@ static int ext4_do_flush_completed_IO(struct inode *inode,
>                 BUG_ON(!(io->flag & EXT4_IO_END_UNWRITTEN));
>                 list_del_init(&io->list);
>
> -               err = ext4_end_io(io);
> -               if (unlikely(!ret && err))
> -                       ret = err;
> +               ext4_debug("ext4_do_flush_completed_IO: io 0x%p, inode %lu\n",
> +                          io, inode->i_ino);
> +
> +               err = ext4_convert_unwritten_extents(inode, io->offset,
> +                                                    io->size);
> +               if (err < 0) {
> +                       ext4_msg(inode->i_sb, KERN_EMERG,
> +                                "failed to convert unwritten extents to written"
> +                                " extents -- potential data loss!  "
> +                                "(inode %lu, offset %llu, size %zd, error %d)",
> +                                inode->i_ino, io->offset, io->size, err);
> +                       if (!ret)
> +                               ret = err;
> +               }
> +               if (io->iocb)
> +                       aio_complete(io->iocb, io->result, 0);
> +
> +               if (io->flag & EXT4_IO_END_DIRECT)
> +                       inode_dio_done(inode);
> +               /* Wake up anyone waiting on unwritten extent conversion */
> +               if (atomic_dec_and_test(&EXT4_I(inode)->i_unwritten))
> +                       wake_up_all(ext4_ioend_wq(io->inode));

Should we use "inode" instead of "io->inode"?

>
>                 list_add_tail(&io->list, &complete);
>         }
> --
> 1.7.7.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o - Oct. 5, 2012, 4:28 a.m.
I ended up dropping this patch since it doesn't make any difference to
the generated code (gcc will take a static function which is only used
in one place, and inline it) and it makes a bit more understandable to
have ext4_end_io() as a separate function.

> > +               /* Wake up anyone waiting on unwritten extent conversion */
> > +               if (atomic_dec_and_test(&EXT4_I(inode)->i_unwritten))
> > +                       wake_up_all(ext4_ioend_wq(io->inode));
> 
> Should we use "inode" instead of "io->inode"?

I agree it would be a bit cleaner/more readable, but again it won't
make a difference to the generated assembly, and while we oculd do
this in the original code in ext4_end_io(), I'm trying to put this
patch series to bed so I can push it to Linus, and since we're now not
touching the code, it's not worth it to clean this up now.  We can
take of this later....

						- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 5b24c40..0435688 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -84,37 +84,6 @@  void ext4_free_io_end(ext4_io_end_t *io)
 	kmem_cache_free(io_end_cachep, io);
 }
 
-/* check a range of space and convert unwritten extents to written. */
-static int ext4_end_io(ext4_io_end_t *io)
-{
-	struct inode *inode = io->inode;
-	loff_t offset = io->offset;
-	ssize_t size = io->size;
-	int ret = 0;
-
-	ext4_debug("ext4_end_io_nolock: io 0x%p from inode %lu,list->next 0x%p,"
-		   "list->prev 0x%p\n",
-		   io, inode->i_ino, io->list.next, io->list.prev);
-
-	ret = ext4_convert_unwritten_extents(inode, offset, size);
-	if (ret < 0) {
-		ext4_msg(inode->i_sb, KERN_EMERG,
-			 "failed to convert unwritten extents to written "
-			 "extents -- potential data loss!  "
-			 "(inode %lu, offset %llu, size %zd, error %d)",
-			 inode->i_ino, offset, size, ret);
-	}
-	if (io->iocb)
-		aio_complete(io->iocb, io->result, 0);
-
-	if (io->flag & EXT4_IO_END_DIRECT)
-		inode_dio_done(inode);
-	/* Wake up anyone waiting on unwritten extent conversion */
-	if (atomic_dec_and_test(&EXT4_I(inode)->i_unwritten))
-		wake_up_all(ext4_ioend_wq(io->inode));
-	return ret;
-}
-
 static void dump_completed_IO(struct inode *inode)
 {
 #ifdef	EXT4FS_DEBUG
@@ -183,9 +152,28 @@  static int ext4_do_flush_completed_IO(struct inode *inode,
 		BUG_ON(!(io->flag & EXT4_IO_END_UNWRITTEN));
 		list_del_init(&io->list);
 
-		err = ext4_end_io(io);
-		if (unlikely(!ret && err))
-			ret = err;
+		ext4_debug("ext4_do_flush_completed_IO: io 0x%p, inode %lu\n",
+			   io, inode->i_ino);
+
+		err = ext4_convert_unwritten_extents(inode, io->offset,
+						     io->size);
+		if (err < 0) {
+			ext4_msg(inode->i_sb, KERN_EMERG,
+				 "failed to convert unwritten extents to written"
+				 " extents -- potential data loss!  "
+				 "(inode %lu, offset %llu, size %zd, error %d)",
+				 inode->i_ino, io->offset, io->size, err);
+			if (!ret)
+				ret = err;
+		}
+		if (io->iocb)
+			aio_complete(io->iocb, io->result, 0);
+
+		if (io->flag & EXT4_IO_END_DIRECT)
+			inode_dio_done(inode);
+		/* Wake up anyone waiting on unwritten extent conversion */
+		if (atomic_dec_and_test(&EXT4_I(inode)->i_unwritten))
+			wake_up_all(ext4_ioend_wq(io->inode));
 
 		list_add_tail(&io->list, &complete);
 	}