Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

exportfs: remove old methods

Now that all filesystems are converted remove support for the old methods.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: Neil Brown <neilb@suse.de>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: <linux-ext4@vger.kernel.org>
Cc: Dave Kleikamp <shaggy@austin.ibm.com>
Cc: Anton Altaparmakov <aia21@cantab.net>
Cc: David Chinner <dgc@sgi.com>
Cc: Timothy Shimmin <tes@sgi.com>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Hugh Dickins <hugh@veritas.com>
Cc: Chris Mason <mason@suse.com>
Cc: Jeff Mahoney <jeffm@suse.com>
Cc: "Vladimir V. Saveliev" <vs@namesys.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Mark Fasheh <mark.fasheh@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Christoph Hellwig and committed by
Linus Torvalds
cfaea787 644f9ab3

+3 -225
-179
fs/exportfs/expfs.c
··· 13 13 struct dentry *child); 14 14 15 15 16 - static struct dentry *exportfs_get_dentry(struct super_block *sb, void *obj) 17 - { 18 - struct dentry *result = ERR_PTR(-ESTALE); 19 - 20 - if (sb->s_export_op->get_dentry) { 21 - result = sb->s_export_op->get_dentry(sb, obj); 22 - if (!result) 23 - result = ERR_PTR(-ESTALE); 24 - } 25 - 26 - return result; 27 - } 28 - 29 16 static int exportfs_get_name(struct dentry *dir, char *name, 30 17 struct dentry *child) 31 18 { ··· 201 214 return 0; 202 215 } 203 216 204 - /** 205 - * find_exported_dentry - helper routine to implement export_operations->decode_fh 206 - * @sb: The &super_block identifying the filesystem 207 - * @obj: An opaque identifier of the object to be found - passed to 208 - * get_inode 209 - * @parent: An optional opqaue identifier of the parent of the object. 210 - * @acceptable: A function used to test possible &dentries to see if they are 211 - * acceptable 212 - * @context: A parameter to @acceptable so that it knows on what basis to 213 - * judge. 214 - * 215 - * find_exported_dentry is the central helper routine to enable file systems 216 - * to provide the decode_fh() export_operation. It's main task is to take 217 - * an &inode, find or create an appropriate &dentry structure, and possibly 218 - * splice this into the dcache in the correct place. 219 - * 220 - * The decode_fh() operation provided by the filesystem should call 221 - * find_exported_dentry() with the same parameters that it received except 222 - * that instead of the file handle fragment, pointers to opaque identifiers 223 - * for the object and optionally its parent are passed. The default decode_fh 224 - * routine passes one pointer to the start of the filehandle fragment, and 225 - * one 8 bytes into the fragment. It is expected that most filesystems will 226 - * take this approach, though the offset to the parent identifier may well be 227 - * different. 228 - * 229 - * find_exported_dentry() will call get_dentry to get an dentry pointer from 230 - * the file system. If any &dentry in the d_alias list is acceptable, it will 231 - * be returned. Otherwise find_exported_dentry() will attempt to splice a new 232 - * &dentry into the dcache using get_name() and get_parent() to find the 233 - * appropriate place. 234 - */ 235 - 236 - struct dentry * 237 - find_exported_dentry(struct super_block *sb, void *obj, void *parent, 238 - int (*acceptable)(void *context, struct dentry *de), 239 - void *context) 240 - { 241 - struct dentry *result, *alias; 242 - int err = -ESTALE; 243 - 244 - /* 245 - * Attempt to find the inode. 246 - */ 247 - result = exportfs_get_dentry(sb, obj); 248 - if (IS_ERR(result)) 249 - return result; 250 - 251 - if (S_ISDIR(result->d_inode->i_mode)) { 252 - if (!(result->d_flags & DCACHE_DISCONNECTED)) { 253 - if (acceptable(context, result)) 254 - return result; 255 - err = -EACCES; 256 - goto err_result; 257 - } 258 - 259 - err = reconnect_path(sb, result); 260 - if (err) 261 - goto err_result; 262 - } else { 263 - struct dentry *target_dir, *nresult; 264 - char nbuf[NAME_MAX+1]; 265 - 266 - alias = find_acceptable_alias(result, acceptable, context); 267 - if (alias) 268 - return alias; 269 - 270 - if (parent == NULL) 271 - goto err_result; 272 - 273 - target_dir = exportfs_get_dentry(sb,parent); 274 - if (IS_ERR(target_dir)) { 275 - err = PTR_ERR(target_dir); 276 - goto err_result; 277 - } 278 - 279 - err = reconnect_path(sb, target_dir); 280 - if (err) { 281 - dput(target_dir); 282 - goto err_result; 283 - } 284 - 285 - /* 286 - * As we weren't after a directory, have one more step to go. 287 - */ 288 - err = exportfs_get_name(target_dir, nbuf, result); 289 - if (!err) { 290 - mutex_lock(&target_dir->d_inode->i_mutex); 291 - nresult = lookup_one_len(nbuf, target_dir, 292 - strlen(nbuf)); 293 - mutex_unlock(&target_dir->d_inode->i_mutex); 294 - if (!IS_ERR(nresult)) { 295 - if (nresult->d_inode) { 296 - dput(result); 297 - result = nresult; 298 - } else 299 - dput(nresult); 300 - } 301 - } 302 - dput(target_dir); 303 - } 304 - 305 - alias = find_acceptable_alias(result, acceptable, context); 306 - if (alias) 307 - return alias; 308 - 309 - /* drat - I just cannot find anything acceptable */ 310 - dput(result); 311 - /* It might be justifiable to return ESTALE here, 312 - * but the filehandle at-least looks reasonable good 313 - * and it may just be a permission problem, so returning 314 - * -EACCESS is safer 315 - */ 316 - return ERR_PTR(-EACCES); 317 - 318 - err_result: 319 - dput(result); 320 - return ERR_PTR(err); 321 - } 322 - 323 217 struct getdents_callback { 324 218 char *name; /* name that was found. It already points to a 325 219 buffer NAME_MAX+1 is size */ ··· 330 462 return type; 331 463 } 332 464 333 - 334 - /** 335 - * export_decode_fh - default export_operations->decode_fh function 336 - * @sb: The superblock 337 - * @fh: pointer to the file handle fragment 338 - * @fh_len: length of file handle fragment 339 - * @acceptable: function for testing acceptability of dentrys 340 - * @context: context for @acceptable 341 - * 342 - * This is the default decode_fh() function. 343 - * a fileid_type of 1 indicates that the filehandlefragment 344 - * just contains an object identifier understood by get_dentry. 345 - * a fileid_type of 2 says that there is also a directory 346 - * identifier 8 bytes in to the filehandlefragement. 347 - */ 348 - static struct dentry *export_decode_fh(struct super_block *sb, __u32 *fh, int fh_len, 349 - int fileid_type, 350 - int (*acceptable)(void *context, struct dentry *de), 351 - void *context) 352 - { 353 - __u32 parent[2]; 354 - parent[0] = parent[1] = 0; 355 - if (fh_len < 2 || fileid_type > 2) 356 - return NULL; 357 - if (fileid_type == 2) { 358 - if (fh_len > 2) parent[0] = fh[2]; 359 - if (fh_len > 3) parent[1] = fh[3]; 360 - } 361 - return find_exported_dentry(sb, fh, parent, 362 - acceptable, context); 363 - } 364 - 365 465 int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len, 366 466 int connectable) 367 467 { ··· 352 516 struct export_operations *nop = mnt->mnt_sb->s_export_op; 353 517 struct dentry *result, *alias; 354 518 int err; 355 - 356 - /* 357 - * Old way of doing things. Will go away soon. 358 - */ 359 - if (!nop->fh_to_dentry) { 360 - if (nop->decode_fh) { 361 - return nop->decode_fh(mnt->mnt_sb, fid->raw, fh_len, 362 - fileid_type, acceptable, context); 363 - } else { 364 - return export_decode_fh(mnt->mnt_sb, fid->raw, fh_len, 365 - fileid_type, acceptable, context); 366 - } 367 - } 368 519 369 520 /* 370 521 * Try to get any dentry for the given file handle from the filesystem. ··· 474 651 return ERR_PTR(err); 475 652 } 476 653 EXPORT_SYMBOL_GPL(exportfs_decode_fh); 477 - 478 - EXPORT_SYMBOL(find_exported_dentry); 479 654 480 655 MODULE_LICENSE("GPL");
+3 -5
fs/nfsd/export.c
··· 386 386 dprintk("exp_export: export of non-dev fs without fsid\n"); 387 387 return -EINVAL; 388 388 } 389 - if (!inode->i_sb->s_export_op) { 389 + 390 + if (!inode->i_sb->s_export_op || 391 + !inode->i_sb->s_export_op->fh_to_dentry) { 390 392 dprintk("exp_export: export of invalid fs type.\n"); 391 393 return -EINVAL; 392 394 } 393 395 394 - /* Ok, we can export it */; 395 - if (!inode->i_sb->s_export_op->find_exported_dentry) 396 - inode->i_sb->s_export_op->find_exported_dentry = 397 - find_exported_dentry; 398 396 return 0; 399 397 400 398 }
-41
include/linux/exportfs.h
··· 54 54 * @get_name: find the name for a given inode in a given directory 55 55 * @get_parent: find the parent of a given directory 56 56 * @get_dentry: find a dentry for the inode given a file handle sub-fragment 57 - * @find_exported_dentry: 58 - * set by the exporting module to a standard helper function. 59 57 * 60 58 * Description: 61 59 * The export_operations structure provides a means for nfsd to communicate ··· 79 81 * given file, the filesystem should check each one for acceptability before 80 82 * looking for the next. As soon as an acceptable one is found, it should 81 83 * be returned. 82 - * 83 - * decode_fh: 84 - * @decode_fh is given a &struct super_block (@sb), a file handle fragment 85 - * (@fh, @fh_len) and an acceptability testing function (@acceptable, 86 - * @context). It should return a &struct dentry which refers to the same 87 - * file that the file handle fragment refers to, and which passes the 88 - * acceptability test. If it cannot, it should return a %NULL pointer if 89 - * the file was found but no acceptable &dentries were available, or a 90 - * %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or 91 - * %ENOMEM). 92 84 * 93 85 * encode_fh: 94 86 * @encode_fh should store in the file handle fragment @fh (using at most ··· 117 129 * is also a directory. In the event that it cannot be found, or storage 118 130 * space cannot be allocated, a %ERR_PTR should be returned. 119 131 * 120 - * get_dentry: 121 - * Given a &super_block (@sb) and a pointer to a file-system specific inode 122 - * identifier, possibly an inode number, (@inump) get_dentry() should find 123 - * the identified inode and return a dentry for that inode. Any suitable 124 - * dentry can be returned including, if necessary, a new dentry created with 125 - * d_alloc_root. The caller can then find any other extant dentrys by 126 - * following the d_alias links. If a new dentry was created using 127 - * d_alloc_root, DCACHE_NFSD_DISCONNECTED should be set, and the dentry 128 - * should be d_rehash()ed. 129 - * 130 - * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code 131 - * can be returned. The @inump will be whatever was passed to 132 - * nfsd_find_fh_dentry() in either the @obj or @parent parameters. 133 - * 134 132 * Locking rules: 135 133 * get_parent is called with child->d_inode->i_mutex down 136 134 * get_name is not (which is possibly inconsistent) 137 135 */ 138 136 139 137 struct export_operations { 140 - struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, 141 - int fh_len, int fh_type, 142 - int (*acceptable)(void *context, struct dentry *de), 143 - void *context); 144 138 int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len, 145 139 int connectable); 146 140 struct dentry * (*fh_to_dentry)(struct super_block *sb, struct fid *fid, ··· 132 162 int (*get_name)(struct dentry *parent, char *name, 133 163 struct dentry *child); 134 164 struct dentry * (*get_parent)(struct dentry *child); 135 - struct dentry * (*get_dentry)(struct super_block *sb, void *inump); 136 - 137 - /* This is set by the exporting module to a standard helper */ 138 - struct dentry * (*find_exported_dentry)( 139 - struct super_block *sb, void *obj, void *parent, 140 - int (*acceptable)(void *context, struct dentry *de), 141 - void *context); 142 165 }; 143 - 144 - extern struct dentry *find_exported_dentry(struct super_block *sb, void *obj, 145 - void *parent, int (*acceptable)(void *context, struct dentry *de), 146 - void *context); 147 166 148 167 extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, 149 168 int *max_len, int connectable);