int jfs_umount_rw(struct super_block *sb) { struct jfs_sb_info *sbi = JFS_SBI(sb); struct jfs_log *log = sbi->log; if (!log) return 0; /* * close log: * * remove file system from log active file system list. */ jfs_flush_journal(log, 1); /* * Make sure all metadata makes it to disk */ dbSync(sbi->ipbmap); diSync(sbi->ipimap); /* * Note that we have to do this even if sync_blockdev() will * do exactly the same a few instructions later: We can't * mark the superblock clean before everything is flushed to * disk. */ filemap_write_and_wait(sbi->direct_inode->i_mapping); updateSuper(sb, FM_CLEAN); return lmLogClose(sb); }
int jfs_umount_rw(struct super_block *sb) { struct jfs_sb_info *sbi = JFS_SBI(sb); struct jfs_log *log = sbi->log; if (!log) return 0; /* * close log: * * remove file system from log active file system list. */ jfs_flush_journal(log, 2); /* * Make sure all metadata makes it to disk */ dbSync(sbi->ipbmap); diSync(sbi->ipimap); fsync_inode_data_buffers(sb->s_bdev->bd_inode); updateSuper(sb, FM_CLEAN); sbi->log = NULL; return lmLogClose(sb, log); }
int jfs_umount_rw(struct super_block *sb) { struct jfs_sb_info *sbi = JFS_SBI(sb); struct jfs_log *log = sbi->log; if (!log) return 0; jfs_flush_journal(log, 2); dbSync(sbi->ipbmap); diSync(sbi->ipimap); filemap_write_and_wait(sbi->direct_inode->i_mapping); updateSuper(sb, FM_CLEAN); return lmLogClose(sb); }
/* * NAME: jfs_defragfs() * * FUNCTION: relocate specified extent for defragfs() * optionally commiting the operation. */ int32 jfs_defragfs( char *pData, /* pointer to buffer containing plist */ uint32 lenData, /* length of buffer */ uint16 *pbufsize) /* pointer of buffer length */ { int32 rc = 0; defragfs_t pList, *p = &pList; uint32 xtype; int64 offset, xoff, oxaddr, nxaddr; int32 xlen; inode_t *ipmnt, *ipimap, *ipbmap; inode_t *ip = NULL; xad_t oxad; pxd_t opxd; mode_t imode; int32 tid; inode_t *iplist[1]; struct vfs *vfsp; if (rc = KernCopyIn(&pList, pData, lenData)) return rc; /* get the 'mount' inode */ for (vfsp = vfs_anchor; vfsp != NULL; vfsp = vfsp->vfs_next) if (vfsp->vfs_vpfsi->vpi_drive == pList.dev) break; if (vfsp == NULL) return EINVAL; xtype = pList.flag; /* sync at start of defragfs ? */ if (xtype & DEFRAGFS_SYNC) { jEVENT(0,("jfs_defragfs: DEFRAGFS_SYNC\n")); if ((vfsp->vfs_flag & VFS_READONLY) || (vfsp->vfs_flag & VFS_ACCEPT)) return 0; ipimap = (inode_t *)vfsp->vfs_data; ipmnt = ipimap->i_ipmnt; ipbmap = ipmnt->i_ipbmap; /* sync the file system */ iSyncFS(vfsp); /* write dirty pages of imap */ diSync(ipimap); /* write dirty pages of bmap */ dbSync(ipbmap); return 0; } else if (!(xtype & DEFRAGFS_RELOCATE)) return EINVAL; if (vfsp->vfs_flag & VFS_READONLY) return EROFS; if (vfsp->vfs_flag & VFS_ACCEPT) return EINVAL; /* get the relocation parameter */ xoff = pList.xoff; oxaddr = pList.old_xaddr; nxaddr = pList.new_xaddr; xlen = pList.xlen; jEVENT(0,("jfs_defragfs: i:%d xtype:0x%08x xoff:%lld xlen:%d xaddr:%lld:%lld\n", pList.ino, xtype, xoff, xlen, oxaddr, nxaddr)); /* get the object inode if it exist */ ICACHE_LOCK(); rc = iget(vfsp, pList.ino, &ip, 0); ICACHE_UNLOCK(); if(rc) { jEVENT(0,("jfs_defragfs: stale target object.\n")); rc = ESTALE; /* stale object ENOENT */ goto out1; } IWRITE_LOCK(ip); /* validate inode */ if (ip->i_nlink == 0 || ip->i_gen != pList.gen || ip->i_fileset != pList.fileset || ip->i_inostamp != pList.inostamp) { jEVENT(0,("jfs_defragfs: stale target object.\n")); rc = ESTALE; /* stale object ENOENT */ goto out1; } /* validate object type: regular file or directory */ imode = ip->i_mode & IFMT; switch(imode) { case IFREG: case IFDIR: break; default: rc = ESTALE; /* invalid object type ENOENT */ goto out1; } /* * try to allocate new destination extent */ if (rc = dbAllocExact(ip, nxaddr, xlen)) { jEVENT(0,("jfs_defragfs: stale destination extent.\n")); rc = ENOSPC; goto out1; } iBindCache(ip); /* * regular file: */ if (imode == IFREG) { /* * automatic commit before and after each relocation * may be skipped after more experience; */ /* * commit any update before relocation */ if (ip->i_flag & IUPD) { ip->i_flag |= IFSYNC; txBegin(ip->i_ipmnt, &tid, 0); iplist[0] = ip; rc = txCommit(tid, 1, &iplist[0], 0); if (rc) goto out2; txEnd(tid); } /* * relocate either xtpage or data extent */ txBegin(ip->i_ipmnt, &tid, 0); /* source extent xad */ XADoffset(&oxad, xoff); XADaddress(&oxad, oxaddr); XADlength(&oxad, xlen); rc = xtRelocate(tid, ip, &oxad, nxaddr, xtype); if (rc) goto out2; iplist[0] = ip; rc = txCommit(tid, 1, &iplist[0], 0); if (rc) goto out2; txEnd(tid); goto out1; } /* * directory: */ else /* IFDIR */ { /* * relocate dtpage */ txBegin(ip->i_ipmnt, &tid, 0); /* source extent pxd */ PXDaddress(&opxd, oxaddr); PXDlength(&opxd, xlen); rc = dtRelocate(tid, ip, xoff, &opxd, nxaddr); if (rc) goto out2; iplist[0] = ip; rc = txCommit(tid, 1, &iplist[0], 0); if (rc) goto out2; txEnd(tid); goto out1; } out2: dbFree(ip, nxaddr, xlen) ; out1: if (ip) { IWRITE_UNLOCK(ip); ICACHE_LOCK(); iput(ip, NULL); ICACHE_UNLOCK(); } jEVENT(0,("jfs_defragfs: rc=%d\n", rc)); return (rc); }