@@ -755,6 +755,29 @@ void fuse_update_ctime(struct inode *inode)
755
755
}
756
756
}
757
757
758
+ static void fuse_entry_unlinked (struct dentry * entry )
759
+ {
760
+ struct inode * inode = d_inode (entry );
761
+ struct fuse_conn * fc = get_fuse_conn (inode );
762
+ struct fuse_inode * fi = get_fuse_inode (inode );
763
+
764
+ spin_lock (& fi -> lock );
765
+ fi -> attr_version = atomic64_inc_return (& fc -> attr_version );
766
+ /*
767
+ * If i_nlink == 0 then unlink doesn't make sense, yet this can
768
+ * happen if userspace filesystem is careless. It would be
769
+ * difficult to enforce correct nlink usage so just ignore this
770
+ * condition here
771
+ */
772
+ if (S_ISDIR (inode -> i_mode ))
773
+ clear_nlink (inode );
774
+ else if (inode -> i_nlink > 0 )
775
+ drop_nlink (inode );
776
+ spin_unlock (& fi -> lock );
777
+ fuse_invalidate_entry_cache (entry );
778
+ fuse_update_ctime (inode );
779
+ }
780
+
758
781
static int fuse_unlink (struct inode * dir , struct dentry * entry )
759
782
{
760
783
int err ;
@@ -771,23 +794,8 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry)
771
794
args .in_args [0 ].value = entry -> d_name .name ;
772
795
err = fuse_simple_request (fm , & args );
773
796
if (!err ) {
774
- struct inode * inode = d_inode (entry );
775
- struct fuse_inode * fi = get_fuse_inode (inode );
776
-
777
- spin_lock (& fi -> lock );
778
- fi -> attr_version = atomic64_inc_return (& fm -> fc -> attr_version );
779
- /*
780
- * If i_nlink == 0 then unlink doesn't make sense, yet this can
781
- * happen if userspace filesystem is careless. It would be
782
- * difficult to enforce correct nlink usage so just ignore this
783
- * condition here
784
- */
785
- if (inode -> i_nlink > 0 )
786
- drop_nlink (inode );
787
- spin_unlock (& fi -> lock );
788
797
fuse_dir_changed (dir );
789
- fuse_invalidate_entry_cache (entry );
790
- fuse_update_ctime (inode );
798
+ fuse_entry_unlinked (entry );
791
799
} else if (err == - EINTR )
792
800
fuse_invalidate_entry (entry );
793
801
return err ;
@@ -809,9 +817,8 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry)
809
817
args .in_args [0 ].value = entry -> d_name .name ;
810
818
err = fuse_simple_request (fm , & args );
811
819
if (!err ) {
812
- clear_nlink (d_inode (entry ));
813
820
fuse_dir_changed (dir );
814
- fuse_invalidate_entry_cache (entry );
821
+ fuse_entry_unlinked (entry );
815
822
} else if (err == - EINTR )
816
823
fuse_invalidate_entry (entry );
817
824
return err ;
@@ -851,10 +858,8 @@ static int fuse_rename_common(struct inode *olddir, struct dentry *oldent,
851
858
fuse_dir_changed (newdir );
852
859
853
860
/* newent will end up negative */
854
- if (!(flags & RENAME_EXCHANGE ) && d_really_is_positive (newent )) {
855
- fuse_invalidate_entry_cache (newent );
856
- fuse_update_ctime (d_inode (newent ));
857
- }
861
+ if (!(flags & RENAME_EXCHANGE ) && d_really_is_positive (newent ))
862
+ fuse_entry_unlinked (newent );
858
863
} else if (err == - EINTR ) {
859
864
/* If request was interrupted, DEITY only knows if the
860
865
rename actually took place. If the invalidation
0 commit comments