From patchwork Mon Jun 20 20:15:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 898412 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5KKOIBh013544 for ; Mon, 20 Jun 2011 20:24:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754534Ab1FTUUn (ORCPT ); Mon, 20 Jun 2011 16:20:43 -0400 Received: from 173-166-109-252-newengland.hfc.comcastbusiness.net ([173.166.109.252]:52957 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752344Ab1FTUUg (ORCPT ); Mon, 20 Jun 2011 16:20:36 -0400 Received: from hch by bombadil.infradead.org with local (Exim 4.76 #1 (Red Hat Linux)) id 1QYkxT-0007LD-0Q; Mon, 20 Jun 2011 20:20:31 +0000 Message-Id: <20110620202030.966337660@bombadil.infradead.org> User-Agent: quilt/0.48-1 Date: Mon, 20 Jun 2011 16:15:36 -0400 From: Christoph Hellwig To: viro@zeniv.linux.org.uk, tglx@linutronix.de Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, hirofumi@mail.parknet.co.jp, mfasheh@suse.com, jlbec@evilplan.org Subject: [PATCH 3/8] fs: simpler handling of zero sized reads in __blockdev_direct_IO References: <20110620201533.847236272@bombadil.infradead.org> Content-Disposition: inline; filename=fs-cleanup-zero-size-dio-reads X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 20 Jun 2011 20:24:19 +0000 (UTC) Reject zero sized reads as soon as we know our I/O length, and don't borther with locks or allocations that might have to be cleaned up otherwise. Signed-off-by: Christoph Hellwig --- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/fs/direct-io.c =================================================================== --- linux-2.6.orig/fs/direct-io.c 2011-06-11 12:10:10.205165161 +0200 +++ linux-2.6/fs/direct-io.c 2011-06-11 12:12:49.161823781 +0200 @@ -1200,6 +1200,10 @@ __blockdev_direct_IO(int rw, struct kioc } } + /* watch out for a 0 len io from a tricksy fs */ + if (rw == READ && end == offset) + return 0; + dio = kmalloc(sizeof(*dio), GFP_KERNEL); retval = -ENOMEM; if (!dio) @@ -1213,8 +1217,7 @@ __blockdev_direct_IO(int rw, struct kioc dio->flags = flags; if (dio->flags & DIO_LOCKING) { - /* watch out for a 0 len io from a tricksy fs */ - if (rw == READ && end > offset) { + if (rw == READ) { struct address_space *mapping = iocb->ki_filp->f_mapping;