VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   35 Branches   59 Tags
b24413180f560 (Greg Kroah-Hartman  2017-11-01 15:07:57 +0100   1) // SPDX-License-Identifier: GPL-2.0
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700   2) /*
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700   3)  *  linux/fs/bad_inode.c
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700   4)  *
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700   5)  *  Copyright (C) 1997, Stephen Tweedie
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700   6)  *
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700   7)  *  Provide stub functions for unreadable inodes
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700   8)  *
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700   9)  *  Fabian Frederick : August 2003 - All file operations assigned to EIO
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700  10)  */
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700  11) 
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700  12) #include <linux/fs.h>
630d9c47274aa (Paul Gortmaker      2011-11-16 23:57:37 -0500  13) #include <linux/export.h>
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700  14) #include <linux/stat.h>
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700  15) #include <linux/time.h>
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700  16) #include <linux/namei.h>
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  17) #include <linux/poll.h>
10c5db286452b (Christoph Hellwig   2020-05-23 09:30:11 +0200  18) #include <linux/fiemap.h>
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700  19) 
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  20) static int bad_file_open(struct inode *inode, struct file *filp)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  21) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  22) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  23) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  24) 
4b6f5d20b04dc (Arjan van de Ven    2006-03-28 01:56:42 -0800  25) static const struct file_operations bad_file_ops =
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700  26) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  27) 	.open		= bad_file_open,
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700  28) };
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700  29) 
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  30) static int bad_inode_create(struct user_namespace *mnt_userns,
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  31) 			    struct inode *dir, struct dentry *dentry,
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  32) 			    umode_t mode, bool excl)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  33) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  34) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  35) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  36) 
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  37) static struct dentry *bad_inode_lookup(struct inode *dir,
00cd8dd3bf95f (Al Viro             2012-06-10 17:13:09 -0400  38) 			struct dentry *dentry, unsigned int flags)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  39) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  40) 	return ERR_PTR(-EIO);
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  41) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  42) 
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  43) static int bad_inode_link (struct dentry *old_dentry, struct inode *dir,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  44) 		struct dentry *dentry)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  45) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  46) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  47) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  48) 
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  49) static int bad_inode_unlink(struct inode *dir, struct dentry *dentry)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  50) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  51) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  52) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  53) 
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  54) static int bad_inode_symlink(struct user_namespace *mnt_userns,
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  55) 			     struct inode *dir, struct dentry *dentry,
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  56) 			     const char *symname)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  57) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  58) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  59) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  60) 
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  61) static int bad_inode_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  62) 			   struct dentry *dentry, umode_t mode)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  63) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  64) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  65) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  66) 
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  67) static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  68) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  69) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  70) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  71) 
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  72) static int bad_inode_mknod(struct user_namespace *mnt_userns, struct inode *dir,
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  73) 			   struct dentry *dentry, umode_t mode, dev_t rdev)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  74) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  75) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  76) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  77) 
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  78) static int bad_inode_rename2(struct user_namespace *mnt_userns,
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  79) 			     struct inode *old_dir, struct dentry *old_dentry,
a0dbc56610b3e (Miklos Szeredi      2014-07-23 15:15:31 +0200  80) 			     struct inode *new_dir, struct dentry *new_dentry,
a0dbc56610b3e (Miklos Szeredi      2014-07-23 15:15:31 +0200  81) 			     unsigned int flags)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  82) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  83) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  84) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  85) 
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  86) static int bad_inode_readlink(struct dentry *dentry, char __user *buffer,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  87) 		int buflen)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  88) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  89) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  90) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  91) 
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  92) static int bad_inode_permission(struct user_namespace *mnt_userns,
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  93) 				struct inode *inode, int mask)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  94) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  95) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  96) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800  97) 
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  98) static int bad_inode_getattr(struct user_namespace *mnt_userns,
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100  99) 			     const struct path *path, struct kstat *stat,
a528d35e8bfcc (David Howells       2017-01-31 16:46:22 +0000 100) 			     u32 request_mask, unsigned int query_flags)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 101) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 102) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 103) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 104) 
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100 105) static int bad_inode_setattr(struct user_namespace *mnt_userns,
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100 106) 			     struct dentry *direntry, struct iattr *attrs)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 107) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 108) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 109) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 110) 
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 111) static ssize_t bad_inode_listxattr(struct dentry *dentry, char *buffer,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 112) 			size_t buffer_size)
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 113) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 114) 	return -EIO;
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 115) }
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 116) 
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 117) static const char *bad_inode_get_link(struct dentry *dentry,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 118) 				      struct inode *inode,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 119) 				      struct delayed_call *done)
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 120) {
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 121) 	return ERR_PTR(-EIO);
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 122) }
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 123) 
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 124) static struct posix_acl *bad_inode_get_acl(struct inode *inode, int type)
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 125) {
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 126) 	return ERR_PTR(-EIO);
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 127) }
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 128) 
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 129) static int bad_inode_fiemap(struct inode *inode,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 130) 			    struct fiemap_extent_info *fieinfo, u64 start,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 131) 			    u64 len)
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 132) {
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 133) 	return -EIO;
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 134) }
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 135) 
95582b0083883 (Deepa Dinamani      2018-05-08 19:36:02 -0700 136) static int bad_inode_update_time(struct inode *inode, struct timespec64 *time,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 137) 				 int flags)
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 138) {
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 139) 	return -EIO;
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 140) }
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 141) 
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 142) static int bad_inode_atomic_open(struct inode *inode, struct dentry *dentry,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 143) 				 struct file *file, unsigned int open_flag,
44907d7900246 (Al Viro             2018-06-08 13:32:02 -0400 144) 				 umode_t create_mode)
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 145) {
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 146) 	return -EIO;
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 147) }
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 148) 
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100 149) static int bad_inode_tmpfile(struct user_namespace *mnt_userns,
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100 150) 			     struct inode *inode, struct dentry *dentry,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 151) 			     umode_t mode)
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 152) {
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 153) 	return -EIO;
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 154) }
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 155) 
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100 156) static int bad_inode_set_acl(struct user_namespace *mnt_userns,
549c7297717c3 (Christian Brauner   2021-01-21 14:19:43 +0100 157) 			     struct inode *inode, struct posix_acl *acl,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 158) 			     int type)
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 159) {
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 160) 	return -EIO;
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 161) }
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 162) 
754661f143e70 (Arjan van de Ven    2007-02-12 00:55:38 -0800 163) static const struct inode_operations bad_inode_ops =
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 164) {
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 165) 	.create		= bad_inode_create,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 166) 	.lookup		= bad_inode_lookup,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 167) 	.link		= bad_inode_link,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 168) 	.unlink		= bad_inode_unlink,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 169) 	.symlink	= bad_inode_symlink,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 170) 	.mkdir		= bad_inode_mkdir,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 171) 	.rmdir		= bad_inode_rmdir,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 172) 	.mknod		= bad_inode_mknod,
2773bf00aeb9b (Miklos Szeredi      2016-09-27 11:03:58 +0200 173) 	.rename		= bad_inode_rename2,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 174) 	.readlink	= bad_inode_readlink,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 175) 	.permission	= bad_inode_permission,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 176) 	.getattr	= bad_inode_getattr,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 177) 	.setattr	= bad_inode_setattr,
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 178) 	.listxattr	= bad_inode_listxattr,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 179) 	.get_link	= bad_inode_get_link,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 180) 	.get_acl	= bad_inode_get_acl,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 181) 	.fiemap		= bad_inode_fiemap,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 182) 	.update_time	= bad_inode_update_time,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 183) 	.atomic_open	= bad_inode_atomic_open,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 184) 	.tmpfile	= bad_inode_tmpfile,
3f9ca75516a7e (Miklos Szeredi      2016-12-09 11:57:43 +0100 185) 	.set_acl	= bad_inode_set_acl,
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 186) };
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 187) 
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 188) 
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 189) /*
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 190)  * When a filesystem is unable to read an inode due to an I/O error in
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 191)  * its read_inode() function, it can call make_bad_inode() to return a
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 192)  * set of stubs which will return EIO errors as required. 
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 193)  *
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 194)  * We only need to do limited initialisation: all other fields are
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 195)  * preinitialised to zero automatically.
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 196)  */
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 197)  
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 198) /**
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 199)  *	make_bad_inode - mark an inode bad due to an I/O error
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 200)  *	@inode: Inode to mark bad
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 201)  *
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 202)  *	When an inode cannot be read due to a media or remote network
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 203)  *	failure this function makes the inode "bad" and causes I/O operations
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 204)  *	on it to fail from this point on.
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 205)  */
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 206)  
be6aab0e9fa6d (Eric Sandeen        2007-01-05 16:36:36 -0800 207) void make_bad_inode(struct inode *inode)
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 208) {
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 209) 	remove_inode_hash(inode);
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 210) 
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 211) 	inode->i_mode = S_IFREG;
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 212) 	inode->i_atime = inode->i_mtime = inode->i_ctime =
c2050a454c7f1 (Deepa Dinamani      2016-09-14 07:48:06 -0700 213) 		current_time(inode);
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 214) 	inode->i_op = &bad_inode_ops;	
5f6e59ae8277c (Andreas Gruenbacher 2016-09-29 17:48:40 +0200 215) 	inode->i_opflags &= ~IOP_XATTR;
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 216) 	inode->i_fop = &bad_file_ops;	
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 217) }
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 218) EXPORT_SYMBOL(make_bad_inode);
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 219) 
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 220) /*
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 221)  * This tests whether an inode has been flagged as bad. The test uses
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 222)  * &bad_inode_ops to cover the case of invalidated inodes as well as
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 223)  * those created by make_bad_inode() above.
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 224)  */
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 225)  
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 226) /**
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 227)  *	is_bad_inode - is an inode errored
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 228)  *	@inode: inode to test
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 229)  *
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 230)  *	Returns true if the inode in question has been marked as bad.
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 231)  */
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 232)  
0e3ef1fe453c9 (Yaowei Bai          2015-11-19 21:00:11 +0800 233) bool is_bad_inode(struct inode *inode)
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 234) {
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 235) 	return (inode->i_op == &bad_inode_ops);	
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 236) }
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 237) 
^1da177e4c3f4 (Linus Torvalds      2005-04-16 15:20:36 -0700 238) EXPORT_SYMBOL(is_bad_inode);
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 239) 
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 240) /**
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 241)  * iget_failed - Mark an under-construction inode as dead and release it
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 242)  * @inode: The inode to discard
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 243)  *
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 244)  * Mark an under-construction inode as dead and release it.
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 245)  */
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 246) void iget_failed(struct inode *inode)
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 247) {
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 248) 	make_bad_inode(inode);
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 249) 	unlock_new_inode(inode);
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 250) 	iput(inode);
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 251) }
b46980feed937 (David Howells       2008-02-07 00:15:27 -0800 252) EXPORT_SYMBOL(iget_failed);