From owner-freebsd-arm@FreeBSD.ORG Mon Apr 23 10:00:37 2012 Return-Path: Delivered-To: freebsd-arm@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D56EB1065670 for ; Mon, 23 Apr 2012 10:00:37 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id C021D8FC16 for ; Mon, 23 Apr 2012 10:00:37 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q3NA0bBT078878 for ; Mon, 23 Apr 2012 10:00:37 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q3NA0bTt078877; Mon, 23 Apr 2012 10:00:37 GMT (envelope-from gnats) Date: Mon, 23 Apr 2012 10:00:37 GMT Message-Id: <201204231000.q3NA0bTt078877@freefall.freebsd.org> To: freebsd-arm@FreeBSD.org From: Kristof Provost Cc: Subject: Re: arm/158950: arm/sheevaplug fails fsx when mmap operations are enabled X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Kristof Provost List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Apr 2012 10:00:37 -0000 The following reply was made to PR arm/158950; it has been noted by GNATS. From: Kristof Provost To: bug-followup@FreeBSD.org, kirk@ba23.org Cc: Subject: Re: arm/158950: arm/sheevaplug fails fsx when mmap operations are enabled Date: Mon, 23 Apr 2012 11:58:51 +0200 The problem still occurs in current (r234281). Interestingly it only seems to occur when using a USB stick. It doesn't happen when using NFS, or a loop-mounted file system (over NFS). The following code frequently (but not always!) triggers the problem as well: #include #include #include #include #include #define FILE_NAME "test.img" /* Also occurs with offset = 0, but not as frequently */ #define OFFSET 4096 int main(int argc, char **argv) { int fd, i; char buff[1024]; char *map; (void)argc; (void)argv; /* Make sure the file doesn't exist when we start */ unlink(FILE_NAME); fd = open(FILE_NAME, O_CREAT | O_RDWR); if (fd < 0) { perror("Failed to open " FILE_NAME); return 1; } /* mmap write (beyond what is currently written) */ for (i = 0; i < 1024; i++) { buff[i] = i % 128; } /* Truncate the file up */ ftruncate(fd, OFFSET + 1024); map = mmap(NULL, 1024, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, OFFSET); if (map == (char*)-1) { perror("Failed to mmap "); return 1; } memcpy(map, buff, 1024); msync(map, 1024, MS_SYNC); munmap(map, 1024); /* Now read() and check if all bytes are written correctly */ lseek(fd, OFFSET, SEEK_SET); read(fd, buff, 1024); for (i = 0; i < 1024; i++) { if (buff[i] != (i % 128)) printf("After mmap: offset %d is %d, not %d as expected\n", i, buff[i], i % 128); } close(fd); return 0; }