From patchwork Wed Dec 23 20:31:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Martin K. Petersen" X-Patchwork-Id: 69602 Received: from mx01.util.phx2.redhat.com (mx1-phx2.redhat.com [209.132.183.26]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBNKe2f4023443 for ; Wed, 23 Dec 2009 20:40:03 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx01.util.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBNKWeZL028405; Wed, 23 Dec 2009 15:32:41 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBNKWcNt009232 for ; Wed, 23 Dec 2009 15:32:38 -0500 Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.13]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBNKWX5c002165; Wed, 23 Dec 2009 15:32:33 -0500 Received: from rcsinet11.oracle.com (rcsinet11.oracle.com [148.87.113.123]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBNKWHTB025566; Wed, 23 Dec 2009 15:32:18 -0500 Received: from rgminet13.oracle.com (rcsinet13.oracle.com [148.87.113.125]) by rcsinet11.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id nBNKWBar017085 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 23 Dec 2009 20:32:17 GMT Received: from acsmt354.oracle.com (acsmt354.oracle.com [141.146.40.154]) by rgminet13.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id nBNHrF2i022059; Wed, 23 Dec 2009 20:32:18 GMT Received: from abhmt018.oracle.com by acsmt358.oracle.com with ESMTP id 1205960731261600293; Wed, 23 Dec 2009 14:31:33 -0600 Received: from groovelator.mkp.net (/209.217.122.111) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 23 Dec 2009 12:31:33 -0800 From: "Martin K. Petersen" To: jens.axboe@oracle.com, snitzer@redhat.com, dm-devel@redhat.com Date: Wed, 23 Dec 2009 15:31:29 -0500 Message-Id: <1261600290-29627-2-git-send-email-martin.petersen@oracle.com> In-Reply-To: <20091223171351.GA17896@redhat.com> References: <20091223171351.GA17896@redhat.com> X-Source-IP: acsmt354.oracle.com [141.146.40.154] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090202.4B327E49.01A3:SCFMA4539814,ss=1,fgs=0 X-RedHat-Spam-Score: -103.794 (AWL, RCVD_IN_DNSWL_MED, SUBJECT_FUZZY_TION, UNPARSEABLE_RELAY, USER_IN_WHITELIST) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.13 X-loop: dm-devel@redhat.com Cc: "Martin K. Petersen" Subject: [dm-devel] [PATCH 1/2] block: Fix incorrect reporting of partition alignment X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 784a919..59b832b 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1116,11 +1116,18 @@ static inline int queue_alignment_offset(struct request_queue *q) return q->limits.alignment_offset; } +static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t offset) +{ + unsigned int granularity = max(lim->physical_block_size, lim->io_min); + + offset &= granularity - 1; + return (granularity + lim->alignment_offset - offset) & (granularity - 1); +} + static inline int queue_sector_alignment_offset(struct request_queue *q, sector_t sector) { - return ((sector << 9) - q->limits.alignment_offset) - & (q->limits.io_min - 1); + return queue_limit_alignment_offset(&q->limits, sector << 9); } static inline int bdev_alignment_offset(struct block_device *bdev)