dir.c (6b16f5d12202a23d875915349cc031c07fe1b3ec) | dir.c (d9854c87f0ed1a5f32fec24bb5b5fb426ad79c26) |
---|---|
1/* 2 * 3 * Copyright (C) 2011 Novell Inc. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 as published by 7 * the Free Software Foundation. 8 */ --- 228 unchanged lines hidden (view full) --- 237static int ovl_instantiate(struct dentry *dentry, struct inode *inode, 238 struct dentry *newdentry, bool hardlink) 239{ 240 struct ovl_inode_params oip = { 241 .upperdentry = newdentry, 242 .newinode = inode, 243 }; 244 | 1/* 2 * 3 * Copyright (C) 2011 Novell Inc. 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 as published by 7 * the Free Software Foundation. 8 */ --- 228 unchanged lines hidden (view full) --- 237static int ovl_instantiate(struct dentry *dentry, struct inode *inode, 238 struct dentry *newdentry, bool hardlink) 239{ 240 struct ovl_inode_params oip = { 241 .upperdentry = newdentry, 242 .newinode = inode, 243 }; 244 |
245 ovl_dentry_version_inc(dentry->d_parent, false); | 245 ovl_dir_modified(dentry->d_parent, false); |
246 ovl_dentry_set_upper_alias(dentry); 247 if (!hardlink) { 248 /* 249 * ovl_obtain_alias() can be called after ovl_create_real() 250 * and before we get here, so we may get an inode from cache 251 * with the same real upperdentry that is not the inode we 252 * pre-allocated. In this case we will use the cached inode 253 * to instantiate the new dentry. --- 463 unchanged lines hidden (view full) --- 717 !ovl_matches_upper(dentry, upper))) { 718 goto out_dput_upper; 719 } 720 721 err = ovl_cleanup_and_whiteout(workdir, d_inode(upperdir), upper); 722 if (err) 723 goto out_d_drop; 724 | 246 ovl_dentry_set_upper_alias(dentry); 247 if (!hardlink) { 248 /* 249 * ovl_obtain_alias() can be called after ovl_create_real() 250 * and before we get here, so we may get an inode from cache 251 * with the same real upperdentry that is not the inode we 252 * pre-allocated. In this case we will use the cached inode 253 * to instantiate the new dentry. --- 463 unchanged lines hidden (view full) --- 717 !ovl_matches_upper(dentry, upper))) { 718 goto out_dput_upper; 719 } 720 721 err = ovl_cleanup_and_whiteout(workdir, d_inode(upperdir), upper); 722 if (err) 723 goto out_d_drop; 724 |
725 ovl_dentry_version_inc(dentry->d_parent, true); | 725 ovl_dir_modified(dentry->d_parent, true); |
726out_d_drop: 727 d_drop(dentry); 728out_dput_upper: 729 dput(upper); 730out_unlock: 731 unlock_rename(workdir, upperdir); 732out_dput: 733 dput(opaquedir); --- 28 unchanged lines hidden (view full) --- 762 if ((opaquedir && upper != opaquedir) || 763 (!opaquedir && !ovl_matches_upper(dentry, upper))) 764 goto out_dput_upper; 765 766 if (is_dir) 767 err = vfs_rmdir(dir, upper); 768 else 769 err = vfs_unlink(dir, upper, NULL); | 726out_d_drop: 727 d_drop(dentry); 728out_dput_upper: 729 dput(upper); 730out_unlock: 731 unlock_rename(workdir, upperdir); 732out_dput: 733 dput(opaquedir); --- 28 unchanged lines hidden (view full) --- 762 if ((opaquedir && upper != opaquedir) || 763 (!opaquedir && !ovl_matches_upper(dentry, upper))) 764 goto out_dput_upper; 765 766 if (is_dir) 767 err = vfs_rmdir(dir, upper); 768 else 769 err = vfs_unlink(dir, upper, NULL); |
770 ovl_dentry_version_inc(dentry->d_parent, ovl_type_origin(dentry)); | 770 ovl_dir_modified(dentry->d_parent, ovl_type_origin(dentry)); |
771 772 /* 773 * Keeping this dentry hashed would mean having to release 774 * upperpath/lowerpath, which could only be done if we are the 775 * sole user of this dentry. Too tricky... Just unhash for 776 * now. 777 */ 778 if (!err) --- 13 unchanged lines hidden (view full) --- 792 !ovl_test_flag(OVL_WHITEOUTS, d_inode(dentry)); 793} 794 795static int ovl_do_remove(struct dentry *dentry, bool is_dir) 796{ 797 int err; 798 bool locked = false; 799 const struct cred *old_cred; | 771 772 /* 773 * Keeping this dentry hashed would mean having to release 774 * upperpath/lowerpath, which could only be done if we are the 775 * sole user of this dentry. Too tricky... Just unhash for 776 * now. 777 */ 778 if (!err) --- 13 unchanged lines hidden (view full) --- 792 !ovl_test_flag(OVL_WHITEOUTS, d_inode(dentry)); 793} 794 795static int ovl_do_remove(struct dentry *dentry, bool is_dir) 796{ 797 int err; 798 bool locked = false; 799 const struct cred *old_cred; |
800 struct dentry *upperdentry; |
|
800 bool lower_positive = ovl_lower_positive(dentry); 801 LIST_HEAD(list); 802 803 /* No need to clean pure upper removed by vfs_rmdir() */ 804 if (is_dir && (lower_positive || !ovl_pure_upper(dentry))) { 805 err = ovl_check_empty_dir(dentry, &list); 806 if (err) 807 goto out; --- 19 unchanged lines hidden (view full) --- 827 revert_creds(old_cred); 828 if (!err) { 829 if (is_dir) 830 clear_nlink(dentry->d_inode); 831 else 832 drop_nlink(dentry->d_inode); 833 } 834 ovl_nlink_end(dentry, locked); | 801 bool lower_positive = ovl_lower_positive(dentry); 802 LIST_HEAD(list); 803 804 /* No need to clean pure upper removed by vfs_rmdir() */ 805 if (is_dir && (lower_positive || !ovl_pure_upper(dentry))) { 806 err = ovl_check_empty_dir(dentry, &list); 807 if (err) 808 goto out; --- 19 unchanged lines hidden (view full) --- 828 revert_creds(old_cred); 829 if (!err) { 830 if (is_dir) 831 clear_nlink(dentry->d_inode); 832 else 833 drop_nlink(dentry->d_inode); 834 } 835 ovl_nlink_end(dentry, locked); |
836 837 /* 838 * Copy ctime 839 * 840 * Note: we fail to update ctime if there was no copy-up, only a 841 * whiteout 842 */ 843 upperdentry = ovl_dentry_upper(dentry); 844 if (upperdentry) 845 ovl_copyattr(d_inode(upperdentry), d_inode(dentry)); 846 |
|
835out_drop_write: 836 ovl_drop_write(dentry); 837out: 838 ovl_cache_free(&list); 839 return err; 840} 841 842static int ovl_unlink(struct inode *dir, struct dentry *dentry) --- 290 unchanged lines hidden (view full) --- 1133 1134 if (overwrite && d_inode(new)) { 1135 if (new_is_dir) 1136 clear_nlink(d_inode(new)); 1137 else 1138 drop_nlink(d_inode(new)); 1139 } 1140 | 847out_drop_write: 848 ovl_drop_write(dentry); 849out: 850 ovl_cache_free(&list); 851 return err; 852} 853 854static int ovl_unlink(struct inode *dir, struct dentry *dentry) --- 290 unchanged lines hidden (view full) --- 1145 1146 if (overwrite && d_inode(new)) { 1147 if (new_is_dir) 1148 clear_nlink(d_inode(new)); 1149 else 1150 drop_nlink(d_inode(new)); 1151 } 1152 |
1141 ovl_dentry_version_inc(old->d_parent, ovl_type_origin(old) || 1142 (!overwrite && ovl_type_origin(new))); 1143 ovl_dentry_version_inc(new->d_parent, ovl_type_origin(old) || 1144 (d_inode(new) && ovl_type_origin(new))); | 1153 ovl_dir_modified(old->d_parent, ovl_type_origin(old) || 1154 (!overwrite && ovl_type_origin(new))); 1155 ovl_dir_modified(new->d_parent, ovl_type_origin(old) || 1156 (d_inode(new) && ovl_type_origin(new))); |
1145 | 1157 |
1158 /* copy ctime: */ 1159 ovl_copyattr(d_inode(olddentry), d_inode(old)); 1160 if (d_inode(new) && ovl_dentry_upper(new)) 1161 ovl_copyattr(d_inode(newdentry), d_inode(new)); 1162 |
|
1146out_dput: 1147 dput(newdentry); 1148out_dput_old: 1149 dput(olddentry); 1150out_unlock: 1151 unlock_rename(new_upperdir, old_upperdir); 1152out_revert_creds: 1153 revert_creds(old_cred); --- 26 unchanged lines hidden --- | 1163out_dput: 1164 dput(newdentry); 1165out_dput_old: 1166 dput(olddentry); 1167out_unlock: 1168 unlock_rename(new_upperdir, old_upperdir); 1169out_revert_creds: 1170 revert_creds(old_cred); --- 26 unchanged lines hidden --- |