@@ -253,9 +253,12 @@ void v9fs_set_netfs_context(struct inode *inode)
253
253
}
254
254
255
255
int v9fs_init_inode (struct v9fs_session_info * v9ses ,
256
- struct inode * inode , umode_t mode , dev_t rdev )
256
+ struct inode * inode , struct p9_qid * qid , umode_t mode , dev_t rdev )
257
257
{
258
258
int err = 0 ;
259
+ struct v9fs_inode * v9inode = V9FS_I (inode );
260
+
261
+ memcpy (& v9inode -> qid , qid , sizeof (struct p9_qid ));
259
262
260
263
inode_init_owner (& nop_mnt_idmap , inode , NULL , mode );
261
264
inode -> i_blocks = 0 ;
@@ -331,36 +334,6 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
331
334
332
335
}
333
336
334
- /**
335
- * v9fs_get_inode - helper function to setup an inode
336
- * @sb: superblock
337
- * @mode: mode to setup inode with
338
- * @rdev: The device numbers to set
339
- */
340
-
341
- struct inode * v9fs_get_inode (struct super_block * sb , umode_t mode , dev_t rdev )
342
- {
343
- int err ;
344
- struct inode * inode ;
345
- struct v9fs_session_info * v9ses = sb -> s_fs_info ;
346
-
347
- p9_debug (P9_DEBUG_VFS , "super block: %p mode: %ho\n" , sb , mode );
348
-
349
- inode = new_inode (sb );
350
- if (!inode ) {
351
- pr_warn ("%s (%d): Problem allocating inode\n" ,
352
- __func__ , task_pid_nr (current ));
353
- return ERR_PTR (- ENOMEM );
354
- }
355
- err = v9fs_init_inode (v9ses , inode , mode , rdev );
356
- if (err ) {
357
- iput (inode );
358
- return ERR_PTR (err );
359
- }
360
- v9fs_set_netfs_context (inode );
361
- return inode ;
362
- }
363
-
364
337
/**
365
338
* v9fs_evict_inode - Remove an inode from the inode cache
366
339
* @inode: inode to release
@@ -384,82 +357,40 @@ void v9fs_evict_inode(struct inode *inode)
384
357
#endif
385
358
}
386
359
387
- static int v9fs_test_inode (struct inode * inode , void * data )
388
- {
389
- int umode ;
390
- dev_t rdev ;
391
- struct v9fs_inode * v9inode = V9FS_I (inode );
392
- struct p9_wstat * st = (struct p9_wstat * )data ;
393
- struct v9fs_session_info * v9ses = v9fs_inode2v9ses (inode );
394
-
395
- umode = p9mode2unixmode (v9ses , st , & rdev );
396
- /* don't match inode of different type */
397
- if (inode_wrong_type (inode , umode ))
398
- return 0 ;
399
-
400
- /* compare qid details */
401
- if (memcmp (& v9inode -> qid .version ,
402
- & st -> qid .version , sizeof (v9inode -> qid .version )))
403
- return 0 ;
404
-
405
- if (v9inode -> qid .type != st -> qid .type )
406
- return 0 ;
407
-
408
- if (v9inode -> qid .path != st -> qid .path )
409
- return 0 ;
410
- return 1 ;
411
- }
412
-
413
- static int v9fs_test_new_inode (struct inode * inode , void * data )
414
- {
415
- return 0 ;
416
- }
417
-
418
- static int v9fs_set_inode (struct inode * inode , void * data )
419
- {
420
- struct v9fs_inode * v9inode = V9FS_I (inode );
421
- struct p9_wstat * st = (struct p9_wstat * )data ;
422
-
423
- memcpy (& v9inode -> qid , & st -> qid , sizeof (st -> qid ));
424
- return 0 ;
425
- }
426
-
427
- static struct inode * v9fs_qid_iget (struct super_block * sb ,
428
- struct p9_qid * qid ,
429
- struct p9_wstat * st ,
430
- int new )
360
+ struct inode * v9fs_fid_iget (struct super_block * sb , struct p9_fid * fid )
431
361
{
432
362
dev_t rdev ;
433
363
int retval ;
434
364
umode_t umode ;
435
- unsigned long i_ino ;
436
365
struct inode * inode ;
366
+ struct p9_wstat * st ;
437
367
struct v9fs_session_info * v9ses = sb -> s_fs_info ;
438
- int (* test )(struct inode * inode , void * data );
439
368
440
- if (new )
441
- test = v9fs_test_new_inode ;
442
- else
443
- test = v9fs_test_inode ;
444
-
445
- i_ino = v9fs_qid2ino (qid );
446
- inode = iget5_locked (sb , i_ino , test , v9fs_set_inode , st );
447
- if (!inode )
369
+ inode = iget_locked (sb , QID2INO (& fid -> qid ));
370
+ if (unlikely (!inode ))
448
371
return ERR_PTR (- ENOMEM );
449
372
if (!(inode -> i_state & I_NEW ))
450
373
return inode ;
374
+
451
375
/*
452
376
* initialize the inode with the stat info
453
377
* FIXME!! we may need support for stale inodes
454
378
* later.
455
379
*/
456
- inode -> i_ino = i_ino ;
380
+ st = p9_client_stat (fid );
381
+ if (IS_ERR (st )) {
382
+ retval = PTR_ERR (st );
383
+ goto error ;
384
+ }
385
+
457
386
umode = p9mode2unixmode (v9ses , st , & rdev );
458
- retval = v9fs_init_inode (v9ses , inode , umode , rdev );
387
+ retval = v9fs_init_inode (v9ses , inode , & fid -> qid , umode , rdev );
388
+ v9fs_stat2inode (st , inode , sb , 0 );
389
+ p9stat_free (st );
390
+ kfree (st );
459
391
if (retval )
460
392
goto error ;
461
393
462
- v9fs_stat2inode (st , inode , sb , 0 );
463
394
v9fs_set_netfs_context (inode );
464
395
v9fs_cache_inode_get_cookie (inode );
465
396
unlock_new_inode (inode );
@@ -470,23 +401,6 @@ static struct inode *v9fs_qid_iget(struct super_block *sb,
470
401
471
402
}
472
403
473
- struct inode *
474
- v9fs_inode_from_fid (struct v9fs_session_info * v9ses , struct p9_fid * fid ,
475
- struct super_block * sb , int new )
476
- {
477
- struct p9_wstat * st ;
478
- struct inode * inode = NULL ;
479
-
480
- st = p9_client_stat (fid );
481
- if (IS_ERR (st ))
482
- return ERR_CAST (st );
483
-
484
- inode = v9fs_qid_iget (sb , & st -> qid , st , new );
485
- p9stat_free (st );
486
- kfree (st );
487
- return inode ;
488
- }
489
-
490
404
/**
491
405
* v9fs_at_to_dotl_flags- convert Linux specific AT flags to
492
406
* plan 9 AT flag.
@@ -633,7 +547,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
633
547
/*
634
548
* instantiate inode and assign the unopened fid to the dentry
635
549
*/
636
- inode = v9fs_get_new_inode_from_fid (v9ses , fid , dir -> i_sb );
550
+ inode = v9fs_get_inode_from_fid (v9ses , fid , dir -> i_sb );
637
551
if (IS_ERR (inode )) {
638
552
err = PTR_ERR (inode );
639
553
p9_debug (P9_DEBUG_VFS ,
@@ -761,10 +675,8 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
761
675
inode = NULL ;
762
676
else if (IS_ERR (fid ))
763
677
inode = ERR_CAST (fid );
764
- else if (v9ses -> cache & (CACHE_META |CACHE_LOOSE ))
765
- inode = v9fs_get_inode_from_fid (v9ses , fid , dir -> i_sb );
766
678
else
767
- inode = v9fs_get_new_inode_from_fid (v9ses , fid , dir -> i_sb );
679
+ inode = v9fs_get_inode_from_fid (v9ses , fid , dir -> i_sb );
768
680
/*
769
681
* If we had a rename on the server and a parallel lookup
770
682
* for the new name, then make sure we instantiate with
@@ -1186,26 +1098,6 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
1186
1098
v9inode -> cache_validity &= ~V9FS_INO_INVALID_ATTR ;
1187
1099
}
1188
1100
1189
- /**
1190
- * v9fs_qid2ino - convert qid into inode number
1191
- * @qid: qid to hash
1192
- *
1193
- * BUG: potential for inode number collisions?
1194
- */
1195
-
1196
- ino_t v9fs_qid2ino (struct p9_qid * qid )
1197
- {
1198
- u64 path = qid -> path + 2 ;
1199
- ino_t i = 0 ;
1200
-
1201
- if (sizeof (ino_t ) == sizeof (path ))
1202
- memcpy (& i , & path , sizeof (ino_t ));
1203
- else
1204
- i = (ino_t ) (path ^ (path >> 32 ));
1205
-
1206
- return i ;
1207
- }
1208
-
1209
1101
/**
1210
1102
* v9fs_vfs_get_link - follow a symlink path
1211
1103
* @dentry: dentry for symlink
0 commit comments