~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/bad_inode.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/bad_inode.c (Version linux-6.11.5) and /fs/bad_inode.c (Version linux-6.0.19)


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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php