From patchwork Wed Jun 17 18:37:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 6627641 Return-Path: X-Original-To: patchwork-fstests@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7CE2E9F1C1 for ; Wed, 17 Jun 2015 18:38:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9DE32206A4 for ; Wed, 17 Jun 2015 18:38:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2D8F20634 for ; Wed, 17 Jun 2015 18:38:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755544AbbFQSiL (ORCPT ); Wed, 17 Jun 2015 14:38:11 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:34072 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752442AbbFQSiK (ORCPT ); Wed, 17 Jun 2015 14:38:10 -0400 Received: from pps.filterd (m0044008 [127.0.0.1]) by mx0a-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id t5HIaefP007384 for ; Wed, 17 Jun 2015 11:38:09 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : mime-version : content-type; s=facebook; bh=6y4uayKRi7JYSfbPXdvcHwjCbKZU+lY7f/ft7YmigYg=; b=RRZdaoJU/ray0jEDjyX5FC0+ARoyxiYsFvftlfe44Fc2YXNhknjI1noq4Okt8hKTRW0Z IIb8XPZFJUP+DWWJkZ3XE6i5nw5a5x6lEB3PbP9F2ul6G0J92g0RAIeDAWCtWj8WEAUh /lS7KHzi4ycgmZtqMzMpRN+xR1pp6M+tWl4= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 1v380vgy2j-2 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Wed, 17 Jun 2015 11:38:09 -0700 Received: from localhost (192.168.52.123) by mail.thefacebook.com (192.168.16.20) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 17 Jun 2015 11:37:58 -0700 From: Josef Bacik To: Subject: [PATCH] fstests: convert fiemap-tester to use O_DIRECT Date: Wed, 17 Jun 2015 11:37:57 -0700 Message-ID: <1434566277-28967-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151, 1.0.33, 0.0.0000 definitions=2015-06-17_07:2015-06-16, 2015-06-17, 1970-01-01 signatures=0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We want to test fiemap, so we want to lay out a file exactly a certain way. XFS tries to be smart and will allocate data in a hole if the write pattern is [data][hole][data] where the hole is small enough. This screws with fiemap-tester sometimes, so make it easy and just do O_DIRECT so that we get the layout we want and can get back to testing fiemap. Thanks, Signed-off-by: Josef Bacik --- src/fiemap-tester.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/fiemap-tester.c b/src/fiemap-tester.c index 8e633ab..5cb58fc 100644 --- a/src/fiemap-tester.c +++ b/src/fiemap-tester.c @@ -92,8 +92,7 @@ create_file_from_mapping(int fd, char *map, int blocks, int blocksize) int i = 0; bufsize = sizeof(char) * blocksize; - buf = malloc(bufsize); - if (!buf) + if (posix_memalign((void **)&buf, 4096, bufsize)) return -1; memset(buf, 'a', bufsize); @@ -562,7 +561,7 @@ main(int argc, char **argv) if (!fname) usage(); - fd = open(fname, O_RDWR|O_CREAT|O_TRUNC, 0644); + fd = open(fname, O_RDWR|O_CREAT|O_TRUNC|O_DIRECT, 0644); if (fd < 0) { perror("Can't open file"); exit(1);