From owner-freebsd-fs@FreeBSD.ORG Sat Feb 7 04:09:32 2004 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E69E116A4CE for ; Sat, 7 Feb 2004 04:09:32 -0800 (PST) Received: from lxmail.xebeo.com (gwnj8.utstar.com [65.200.123.8]) by mx1.FreeBSD.org (Postfix) with SMTP id 7EB7E43D1D for ; Sat, 7 Feb 2004 04:09:32 -0800 (PST) (envelope-from amit.khivesara@utstar.com) Received: (qmail 10182 invoked by uid 404); 4 Feb 2004 20:09:30 -0000 Received: from amit.khivesara@utstar.com by lxmail by uid 401 with qmail-scanner-1.20rc1 (clamscan: 0.60. spamassassin: 2.55. Clear:RC:1:. Processed in 0.023876 secs); 04 Feb 2004 20:09:30 -0000 Received: from mojo.nj.us.utstar.com (HELO utstar.com) (172.16.36.18) by lxmail.nj.us.utstar.com with SMTP; 4 Feb 2004 20:09:30 -0000 Message-ID: <40215112.2030701@utstar.com> Date: Wed, 04 Feb 2004 15:07:46 -0500 From: Amit Khivesara User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-fs@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Msdos fsync X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Feb 2004 12:09:33 -0000 Hi, The fsync for msdos does not seem to sync the FAT entries. Hence the file can be corrupted if the syncer has not come in and synced the entries. If anyone is interested I have added a function fat_sync to do this. This will allow the msdos fsync really "sync" the file. The diffs are given below for kernel 4.1.1. I am new to this mailing list. If this is a unappropriate post, then let me know. khivi diff msdosfs/fat.h msdosfs.new/fat.h 106a107 >> void fat_sync __P((struct vnode * , struct denode *dep)); diff msdosfs/msdosfs_fat.c msdosfs.new/msdosfs_fat.c 325a326,398 >> * Sync the fat cache in denode dep of all entries relating to file >> */ >> void >> fat_sync(vnode,dep) >> struct vnode *vnode; >> struct denode *dep; >> { >> u_long cn; >> u_long prevcn; >> >> u_long byteoffset; >> u_long bsize; >> u_long bo; >> u_long bn; >> u_long bp_bn = -1; >> int error; >> struct buf *bp = NULL; >> struct msdosfsmount *pmp = dep->de_pmp; >> >> u_int pm_flags=pmp->pm_flags; >> pmp->pm_flags |= MSDOSFSMNT_WAITONFAT; >> >> cn=dep->de_StartCluster; >> while (1){ >> /* >> * Stop with all reserved clusters, not just with EOF. >> */ >> if ((cn | ~pmp->pm_fatmask) >= CLUST_RSRVD) >> goto hiteof; >> byteoffset = FATOFS(pmp, cn); >> fatblock(pmp, byteoffset, &bn, &bsize, &bo); >> if (bn != bp_bn) { >> if (bp) { >> updatefats(pmp, bp, bp_bn); >> } >> error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp); >> if (error) { >> brelse(bp); >> goto func_ret; >> } >> bp_bn = bn; >> } >> >> prevcn = cn; >> if (FAT32(pmp)) >> cn = getulong(&bp->b_data[bo]); >> else >> cn = getushort(&bp->b_data[bo]); >> if (FAT12(pmp) && (prevcn & 1)) >> cn >>= 4; >> cn &= pmp->pm_fatmask; >> >> /* >> * Force the special cluster numbers >> * to be the same for all cluster sizes >> * to let the rest of msdosfs handle >> * all cases the same. >> */ >> if ((cn | ~pmp->pm_fatmask) >= CLUST_RSRVD) >> cn |= ~pmp->pm_fatmask; >> } >> >> >> hiteof: >> if (bp) { >> updatefats(pmp, bp, bp_bn); >> } >> func_ret: >> pmp->pm_flags=pm_flags; >> return; >> } >> >> /* diff msdosfs/msdosfs_vnops.c msdosfs.new/msdosfs_vnops.c 869a870,872 >> fat_sync(vp,VTODE(vp));