From patchwork Tue Apr 12 01:32:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reuben Dowle X-Patchwork-Id: 90687 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2EB9CB6F14 for ; Tue, 12 Apr 2011 11:34:46 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1Q9STe-00041s-Bg; Tue, 12 Apr 2011 01:33:10 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1Q9STc-00041F-HK; Tue, 12 Apr 2011 01:33:08 +0000 Received: from vw-hfger.navico.com ([81.89.228.210]) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1Q9STX-00040x-7S for linux-mtd@lists.infradead.org; Tue, 12 Apr 2011 01:33:04 +0000 Received: from EXCH02-HFGER.MARINE.NET.INT ([84.201.69.20]) by EXCH01-HFGER.MARINE.NET.INT with Microsoft SMTPSVC(6.0.3790.4675); Tue, 12 Apr 2011 03:32:10 +0200 Received: from exch01-aklnz.MARINE.NET.INT ([172.28.28.103]) by EXCH02-HFGER.MARINE.NET.INT with Microsoft SMTPSVC(6.0.3790.4675); Tue, 12 Apr 2011 03:32:44 +0200 Message-ID: <70F6AAAFDC054F41B9994A9BCD3DF64E1284E165@exch01-aklnz.MARINE.NET.INT> Date: Tue, 12 Apr 2011 13:32:50 +1200 From: "Reuben Dowle" Subject: Oops when calling fsync on read-only file-system To: X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Oops when calling fsync on read-only file-system Thread-Index: Acv4sYlQxlE/uRn6QbS4bqeKmcs4cA== X-OriginalArrivalTime: 12 Apr 2011 01:32:44.0796 (UTC) FILETIME=[85CDFBC0:01CBF8B1] MIME-Version: 1.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110411_213303_422774_7CD5D771 X-CRM114-Status: UNSURE ( 8.47 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On my system, calling the fsync system call on any file in a UBI file-system that is mounted read-only leads to a kernel oops. Our system is running a customise version of 2.6.31, but as far as I can see (without testing which is not possible due to extensive vendor customisation of .31 kernel version), the current git branch also contains this bug. I have created a patch against 2.6.31 that fixes the problem in my system. Perhaps someone could test on latest kernel version. Signed-off-by: Reuben Dowle --- --- --- linux-2.6.31.orig/fs/ubifs/io.c 2009-09-10 10:13:59.000000000 +1200 +++ linux-2.6.31/fs/ubifs/io.c 2011-04-11 15:43:50.026527002 +1200 @@ -916,6 +916,14 @@ { int i, err = 0; + /* If this is a read-only mount, write buffers will be null + * Skip the sync, returning success (even though this is an invalid operation + * on a read-only file-system, return success because all data on flash + * is up to date) + */ + if(!c->jheads) + return 0; + for (i = 0; i < c->jhead_cnt; i++) { struct ubifs_wbuf *wbuf = &c->jheads[i].wbuf;