From owner-svn-src-all@FreeBSD.ORG Fri Feb 1 18:25:53 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CC2F5526; Fri, 1 Feb 2013 18:25:53 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BE9547D1; Fri, 1 Feb 2013 18:25:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r11IPrX8016554; Fri, 1 Feb 2013 18:25:53 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r11IPrAX016553; Fri, 1 Feb 2013 18:25:53 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201302011825.r11IPrAX016553@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Feb 2013 18:25:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r246218 - head/sys/fs/msdosfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2013 18:25:53 -0000 Author: kib Date: Fri Feb 1 18:25:53 2013 New Revision: 246218 URL: http://svnweb.freebsd.org/changeset/base/246218 Log: Backup FATs were sometimes marked dirty by copying their first block from the primary FAT, and then they were not marked clean on unmount. Force marking them clean when appropriate. Submitted by: bde MFC after: 1 week Modified: head/sys/fs/msdosfs/msdosfs_fat.c Modified: head/sys/fs/msdosfs/msdosfs_fat.c ============================================================================== --- head/sys/fs/msdosfs/msdosfs_fat.c Fri Feb 1 18:06:06 2013 (r246217) +++ head/sys/fs/msdosfs/msdosfs_fat.c Fri Feb 1 18:25:53 2013 (r246218) @@ -321,8 +321,8 @@ updatefats(pmp, bp, fatbn) struct buf *bp; u_long fatbn; { - int i; struct buf *bpn; + int cleanfat, i; #ifdef MSDOSFS_DEBUG printf("updatefats(pmp %p, bp %p, fatbn %lu)\n", pmp, bp, fatbn); @@ -362,12 +362,23 @@ updatefats(pmp, bp, fatbn) * filesystem was mounted. If synch is asked for then use * bwrite()'s and really slow things down. */ + if (fatbn != pmp->pm_fatblk || FAT12(pmp)) + cleanfat = 0; + else if (FAT16(pmp)) + cleanfat = 16; + else + cleanfat = 32; for (i = 1; i < pmp->pm_FATs; i++) { fatbn += pmp->pm_FATsecs; /* getblk() never fails */ bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount, 0, 0, 0); bcopy(bp->b_data, bpn->b_data, bp->b_bcount); + /* Force the clean bit on in the other copies. */ + if (cleanfat == 16) + ((u_int8_t *)bpn->b_data)[3] |= 0x80; + else if (cleanfat == 32) + ((u_int8_t *)bpn->b_data)[7] |= 0x08; if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT) bwrite(bpn); else