2019-05-27 14:55:05 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) International Business Machines Corp., 2000-2004
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* jfs_umount.c
|
|
|
|
*
|
|
|
|
* note: file system in transition to aggregate/fileset:
|
|
|
|
* (ref. jfs_mount.c)
|
|
|
|
*
|
2006-10-02 22:55:27 +08:00
|
|
|
* file system unmount is interpreted as mount of the single/only
|
|
|
|
* fileset in the aggregate and, if unmount of the last fileset,
|
2005-04-17 06:20:36 +08:00
|
|
|
* as unmount of the aggerate;
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include "jfs_incore.h"
|
|
|
|
#include "jfs_filsys.h"
|
|
|
|
#include "jfs_superblock.h"
|
|
|
|
#include "jfs_dmap.h"
|
|
|
|
#include "jfs_imap.h"
|
|
|
|
#include "jfs_metapage.h"
|
|
|
|
#include "jfs_debug.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NAME: jfs_umount(vfsp, flags, crp)
|
|
|
|
*
|
|
|
|
* FUNCTION: vfs_umount()
|
|
|
|
*
|
|
|
|
* PARAMETERS: vfsp - virtual file system pointer
|
|
|
|
* flags - unmount for shutdown
|
|
|
|
* crp - credential
|
|
|
|
*
|
|
|
|
* RETURN : EBUSY - device has open files
|
|
|
|
*/
|
|
|
|
int jfs_umount(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct jfs_sb_info *sbi = JFS_SBI(sb);
|
|
|
|
struct inode *ipbmap = sbi->ipbmap;
|
|
|
|
struct inode *ipimap = sbi->ipimap;
|
|
|
|
struct inode *ipaimap = sbi->ipaimap;
|
|
|
|
struct inode *ipaimap2 = sbi->ipaimap2;
|
|
|
|
struct jfs_log *log;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
jfs_info("UnMount JFS: sb:0x%p", sb);
|
|
|
|
|
|
|
|
/*
|
2007-06-07 04:28:35 +08:00
|
|
|
* update superblock and close log
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* if mounted read-write and log based recovery was enabled
|
|
|
|
*/
|
|
|
|
if ((log = sbi->log))
|
|
|
|
/*
|
2006-10-02 22:55:27 +08:00
|
|
|
* Wait for outstanding transactions to be written to log:
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2011-08-02 01:41:00 +08:00
|
|
|
jfs_flush_journal(log, 2);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* close fileset inode allocation map (aka fileset inode)
|
|
|
|
*/
|
|
|
|
diUnmount(ipimap, 0);
|
|
|
|
|
|
|
|
diFreeSpecial(ipimap);
|
|
|
|
sbi->ipimap = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* close secondary aggregate inode allocation map
|
|
|
|
*/
|
|
|
|
if (ipaimap2) {
|
|
|
|
diUnmount(ipaimap2, 0);
|
|
|
|
diFreeSpecial(ipaimap2);
|
|
|
|
sbi->ipaimap2 = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* close aggregate inode allocation map
|
|
|
|
*/
|
|
|
|
diUnmount(ipaimap, 0);
|
|
|
|
diFreeSpecial(ipaimap);
|
|
|
|
sbi->ipaimap = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* close aggregate block allocation map
|
|
|
|
*/
|
|
|
|
dbUnmount(ipbmap, 0);
|
|
|
|
|
|
|
|
diFreeSpecial(ipbmap);
|
2022-10-28 20:16:39 +08:00
|
|
|
sbi->ipbmap = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure all metadata makes it to disk before we mark
|
|
|
|
* the superblock as clean
|
|
|
|
*/
|
[PATCH] Fix and add EXPORT_SYMBOL(filemap_write_and_wait)
This patch add EXPORT_SYMBOL(filemap_write_and_wait) and use it.
See mm/filemap.c:
And changes the filemap_write_and_wait() and filemap_write_and_wait_range().
Current filemap_write_and_wait() doesn't wait if filemap_fdatawrite()
returns error. However, even if filemap_fdatawrite() returned an
error, it may have submitted the partially data pages to the device.
(e.g. in the case of -ENOSPC)
<quotation>
Andrew Morton writes,
If filemap_fdatawrite() returns an error, this might be due to some
I/O problem: dead disk, unplugged cable, etc. Given the generally
crappy quality of the kernel's handling of such exceptions, there's a
good chance that the filemap_fdatawait() will get stuck in D state
forever.
</quotation>
So, this patch doesn't wait if filemap_fdatawrite() returns the -EIO.
Trond, could you please review the nfs part? Especially I'm not sure,
nfs must use the "filemap_fdatawrite(inode->i_mapping) == 0", or not.
Acked-by: Trond Myklebust <trond.myklebust@fys.uio.no>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-08 17:02:14 +08:00
|
|
|
filemap_write_and_wait(sbi->direct_inode->i_mapping);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ensure all file system file pages are propagated to their
|
2006-10-02 22:55:27 +08:00
|
|
|
* home blocks on disk (and their in-memory buffer pages are
|
2005-04-17 06:20:36 +08:00
|
|
|
* invalidated) BEFORE updating file system superblock state
|
2006-10-02 22:55:27 +08:00
|
|
|
* (to signify file system is unmounted cleanly, and thus in
|
|
|
|
* consistent state) and log superblock active file system
|
2005-04-17 06:20:36 +08:00
|
|
|
* list (to signify skip logredo()).
|
|
|
|
*/
|
|
|
|
if (log) { /* log = NULL if read-only mount */
|
|
|
|
updateSuper(sb, FM_CLEAN);
|
|
|
|
|
|
|
|
/*
|
2006-10-02 22:55:27 +08:00
|
|
|
* close log:
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* remove file system from log active file system list.
|
|
|
|
*/
|
|
|
|
rc = lmLogClose(sb);
|
|
|
|
}
|
|
|
|
jfs_info("UnMount JFS Complete: rc = %d", rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/*
|
2006-10-02 22:55:27 +08:00
|
|
|
* close log:
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* remove file system from log active file system list.
|
|
|
|
*/
|
2011-08-02 01:41:00 +08:00
|
|
|
jfs_flush_journal(log, 2);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
[PATCH] Fix and add EXPORT_SYMBOL(filemap_write_and_wait)
This patch add EXPORT_SYMBOL(filemap_write_and_wait) and use it.
See mm/filemap.c:
And changes the filemap_write_and_wait() and filemap_write_and_wait_range().
Current filemap_write_and_wait() doesn't wait if filemap_fdatawrite()
returns error. However, even if filemap_fdatawrite() returned an
error, it may have submitted the partially data pages to the device.
(e.g. in the case of -ENOSPC)
<quotation>
Andrew Morton writes,
If filemap_fdatawrite() returns an error, this might be due to some
I/O problem: dead disk, unplugged cable, etc. Given the generally
crappy quality of the kernel's handling of such exceptions, there's a
good chance that the filemap_fdatawait() will get stuck in D state
forever.
</quotation>
So, this patch doesn't wait if filemap_fdatawrite() returns the -EIO.
Trond, could you please review the nfs part? Especially I'm not sure,
nfs must use the "filemap_fdatawrite(inode->i_mapping) == 0", or not.
Acked-by: Trond Myklebust <trond.myklebust@fys.uio.no>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-08 17:02:14 +08:00
|
|
|
filemap_write_and_wait(sbi->direct_inode->i_mapping);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
updateSuper(sb, FM_CLEAN);
|
|
|
|
|
|
|
|
return lmLogClose(sb);
|
|
|
|
}
|