/usr/src/kernel-patches/lustre/patches/vfs_intent-2.6-sles10.patch is in linux-patch-lustre 1.8.5+dfsg-3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 | Index: LINUX-SRC-TREE/fs/9p/vfs_inode.c
===================================================================
--- LINUX-SRC-TREE.orig/fs/9p/vfs_inode.c
+++ LINUX-SRC-TREE/fs/9p/vfs_inode.c
@@ -469,7 +469,7 @@ v9fs_vfs_create(struct inode *dir, struc
perm = unixmode2p9mode(v9ses, mode);
if (nd && nd->flags & LOOKUP_OPEN)
- flags = nd->intent.open.flags - 1;
+ flags = nd->intent.flags - 1;
else
flags = O_RDWR;
Index: LINUX-SRC-TREE/fs/cifs/dir.c
===================================================================
--- LINUX-SRC-TREE.orig/fs/cifs/dir.c
+++ LINUX-SRC-TREE/fs/cifs/dir.c
@@ -157,11 +157,7 @@ cifs_create(struct inode *inode, struct
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)
if(nd && (nd->flags & LOOKUP_OPEN)) {
-#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,5) /* SUSE included Lustre patch */
int oflags = nd->intent.it_flags;
-#else
- int oflags = nd->intent.open.flags;
-#endif
desiredAccess = 0;
if (oflags & FMODE_READ)
Index: LINUX-SRC-TREE/fs/exec.c
===================================================================
--- LINUX-SRC-TREE.orig/fs/exec.c
+++ LINUX-SRC-TREE/fs/exec.c
@@ -129,7 +129,9 @@ asmlinkage long sys_uselib(const char __
struct nameidata nd;
int error;
- error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, FMODE_READ);
+ intent_init(&nd.intent, IT_OPEN);
+ error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd,
+ FMODE_READ | FMODE_EXEC);
if (error)
goto out;
@@ -481,7 +483,9 @@ struct file *open_exec(const char *name)
int err;
struct file *file;
- err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ);
+ intent_init(&nd.intent, IT_OPEN);
+ err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd,
+ FMODE_READ | FMODE_EXEC, 0);
file = ERR_PTR(err);
if (!err) {
@@ -1543,7 +1547,7 @@ int do_coredump(long signr, int exit_cod
goto close_fail;
if (!file->f_op->write)
goto close_fail;
- if (do_truncate(file->f_dentry, 0, 0, file) != 0)
+ if (do_truncate(file->f_dentry, 0, 0, file, 0) != 0)
goto close_fail;
retval = binfmt->core_dump(signr, regs, file);
Index: LINUX-SRC-TREE/fs/fuse/dir.c
===================================================================
--- LINUX-SRC-TREE.orig/fs/fuse/dir.c
+++ LINUX-SRC-TREE/fs/fuse/dir.c
@@ -242,7 +242,7 @@ static int fuse_create_open(struct inode
struct fuse_entry_out outentry;
struct fuse_file *ff;
struct file *file;
- int flags = nd->intent.open.flags - 1;
+ int flags = nd->intent.flags - 1;
err = -ENOSYS;
if (fc->no_create)
Index: LINUX-SRC-TREE/fs/inode.c
===================================================================
--- LINUX-SRC-TREE.orig/fs/inode.c
+++ LINUX-SRC-TREE/fs/inode.c
@@ -236,6 +236,7 @@ void __iget(struct inode * inode)
inodes_stat.nr_unused--;
}
+EXPORT_SYMBOL(__iget);
/**
* clear_inode - clear an inode
* @inode: inode to clear
Index: LINUX-SRC-TREE/fs/namei.c
===================================================================
--- LINUX-SRC-TREE.orig/fs/namei.c
+++ LINUX-SRC-TREE/fs/namei.c
@@ -337,8 +337,19 @@ int deny_write_access(struct file * file
return 0;
}
+void intent_release(struct lookup_intent *it)
+{
+ if (!it)
+ return;
+ if (it->it_magic != INTENT_MAGIC)
+ return;
+ if (it->it_op_release)
+ it->it_op_release(it);
+}
+
void path_release(struct nameidata *nd)
{
+ intent_release(&nd->intent);
dput(nd->dentry);
mntput(nd->mnt);
}
@@ -359,10 +370,10 @@ void path_release_on_umount(struct namei
*/
void release_open_intent(struct nameidata *nd)
{
- if (nd->intent.open.file->f_dentry == NULL)
- put_filp(nd->intent.open.file);
+ if (nd->intent.file->f_dentry == NULL)
+ put_filp(nd->intent.file);
else
- fput(nd->intent.open.file);
+ fput(nd->intent.file);
}
/*
@@ -440,8 +451,12 @@ static struct dentry * real_lookup(struc
{
struct dentry * result;
struct inode *dir = parent->d_inode;
+ int counter = 0;
mutex_lock(&dir->i_mutex);
+again:
+ counter++;
+
/*
* First re-do the cached lookup just in case it was created
* while we waited for the directory semaphore..
@@ -475,13 +490,16 @@ static struct dentry * real_lookup(struc
* Uhhuh! Nasty case: the cache was re-populated while
* we waited on the semaphore. Need to revalidate.
*/
- mutex_unlock(&dir->i_mutex);
if (result->d_op && result->d_op->d_revalidate) {
if (!result->d_op->d_revalidate(result, nd) && !d_invalidate(result)) {
dput(result);
- result = ERR_PTR(-ENOENT);
+ if (counter > 10)
+ result = ERR_PTR(-ESTALE);
+ if (!IS_ERR(result))
+ goto again;
}
}
+ mutex_unlock(&dir->i_mutex);
return result;
}
@@ -510,6 +528,7 @@ static __always_inline int __vfs_follow_
{
int res = 0;
char *name;
+
if (IS_ERR(link))
goto fail;
@@ -519,6 +538,7 @@ static __always_inline int __vfs_follow_
/* weird __emul_prefix() stuff did it */
goto out;
}
+ intent_reset_fs_part(&nd->intent);
res = link_path_walk(link, nd);
out:
if (nd->depth || res || nd->last_type!=LAST_NORM)
@@ -768,6 +788,33 @@ fail:
return PTR_ERR(dentry);
}
+static int revalidate_special(struct nameidata *nd)
+{
+ struct dentry *dentry = nd->dentry;
+ int err, counter = 0;
+
+ revalidate_again:
+ if (!dentry->d_op || !dentry->d_op->d_revalidate)
+ return 0;
+ if (!dentry->d_op->d_revalidate(dentry, nd)) {
+ struct dentry *new;
+ if ((err = permission(dentry->d_parent->d_inode, MAY_EXEC, nd)))
+ return err;
+ new = real_lookup(dentry->d_parent, &dentry->d_name, nd);
+ if (IS_ERR(new))
+ return PTR_ERR(new);
+ d_invalidate(dentry);
+ dput(dentry);
+ nd->dentry = dentry = new;
+ counter++;
+ if (counter < 10)
+ goto revalidate_again;
+ //printk("excessive revalidate_it loops\n");
+ return -ESTALE;
+ }
+ return 0;
+}
+
/*
* Name resolution.
* This is the basic name resolution function, turning a pathname into
@@ -864,7 +911,11 @@ static fastcall int __link_path_walk(con
goto out_dput;
if (inode->i_op->follow_link) {
+ int save_flags = nd->flags;
+ nd->flags |= LOOKUP_LINK_NOTLAST;
err = do_follow_link(&next, nd);
+ if (!(save_flags & LOOKUP_LINK_NOTLAST))
+ nd->flags &= ~LOOKUP_LINK_NOTLAST;
if (err)
goto return_err;
err = -ENOENT;
@@ -899,6 +950,23 @@ last_component:
inode = nd->dentry->d_inode;
/* fallthrough */
case 1:
+ nd->flags |= LOOKUP_LAST;
+ err = revalidate_special(nd);
+ nd->flags &= ~LOOKUP_LAST;
+ if (!nd->dentry->d_inode)
+ err = -ENOENT;
+ if (err) {
+ path_release(nd);
+ goto return_err;
+ }
+ if (lookup_flags & LOOKUP_DIRECTORY) {
+ err = -ENOTDIR;
+ if(!nd->dentry->d_inode->i_op ||
+ !nd->dentry->d_inode->i_op->lookup) {
+ path_release(nd);
+ goto return_err;
+ }
+ }
goto return_reval;
}
if (nd->dentry->d_op && nd->dentry->d_op->d_hash) {
@@ -906,7 +974,9 @@ last_component:
if (err < 0)
break;
}
+ nd->flags |= LOOKUP_LAST;
err = do_lookup(nd, &this, &next);
+ nd->flags &= ~LOOKUP_LAST;
if (err)
break;
inode = next.dentry->d_inode;
@@ -1066,7 +1136,7 @@ set_it:
}
/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
-static int fastcall do_path_lookup(int dfd, const char *name,
+static int fastcall do_path_lookup_it(int dfd, const char *name,
unsigned int flags, struct nameidata *nd)
{
int retval = 0;
@@ -1134,10 +1204,23 @@ fput_fail:
goto out_fail;
}
-int fastcall path_lookup(const char *name, unsigned int flags,
+static int fastcall do_path_lookup(int dfd, const char *name,
+ unsigned int flags, struct nameidata *nd)
+{
+ intent_init(&nd->intent, IT_GETATTR);
+ return do_path_lookup_it(dfd, name, flags, nd);
+}
+
+int fastcall path_lookup_it(const char *name, unsigned int flags,
struct nameidata *nd)
{
- return do_path_lookup(AT_FDCWD, name, flags, nd);
+ return do_path_lookup_it(AT_FDCWD, name, flags, nd);
+}
+
+int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata *nd)
+{
+ intent_init(&nd->intent, IT_GETATTR);
+ return path_lookup_it(name, flags, nd);
}
static int __path_lookup_intent_open(int dfd, const char *name,
@@ -1149,13 +1232,13 @@ static int __path_lookup_intent_open(int
if (filp == NULL)
return -ENFILE;
- nd->intent.open.file = filp;
- nd->intent.open.flags = open_flags;
- nd->intent.open.create_mode = create_mode;
- err = do_path_lookup(dfd, name, lookup_flags|LOOKUP_OPEN, nd);
- if (IS_ERR(nd->intent.open.file)) {
+ nd->intent.file = filp;
+ nd->intent.flags = open_flags;
+ nd->intent.create_mode = create_mode;
+ err = do_path_lookup_it(dfd, name, lookup_flags|LOOKUP_OPEN, nd);
+ if (IS_ERR(nd->intent.file)) {
if (err == 0) {
- err = PTR_ERR(nd->intent.open.file);
+ err = PTR_ERR(nd->intent.file);
path_release(nd);
}
} else if (err != 0)
@@ -1172,10 +1255,10 @@ static int __path_lookup_intent_open(int
* @open_flags: open intent flags
*/
int path_lookup_open(int dfd, const char *name, unsigned int lookup_flags,
- struct nameidata *nd, int open_flags)
+ struct nameidata *nd, int open_flags, int create_mode)
{
return __path_lookup_intent_open(dfd, name, lookup_flags, nd,
- open_flags, 0);
+ open_flags, create_mode);
}
/**
@@ -1258,7 +1341,7 @@ struct dentry * lookup_hash(struct namei
}
/* SMP-safe */
-struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
+struct dentry * lookup_one_len_it(const char * name, struct dentry * base, int len, struct nameidata *nd)
{
unsigned long hash;
struct qstr this;
@@ -1278,11 +1361,17 @@ struct dentry * lookup_one_len(const cha
}
this.hash = end_name_hash(hash);
- return __lookup_hash(&this, base, NULL);
+ return __lookup_hash(&this, base, nd);
access:
return ERR_PTR(-EACCES);
}
+struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
+{
+ return lookup_one_len_it(name, base, len, NULL);
+}
+
+
/*
* namei()
*
@@ -1294,22 +1383,36 @@ access:
* that namei follows links, while lnamei does not.
* SMP-safe
*/
-int fastcall __user_walk_fd(int dfd, const char __user *name, unsigned flags,
- struct nameidata *nd)
+
+int fastcall __user_walk_fd_it(int dfd, const char __user *name, unsigned flags,
+ struct nameidata *nd)
{
char *tmp = getname(name);
int err = PTR_ERR(tmp);
if (!IS_ERR(tmp)) {
- err = do_path_lookup(dfd, tmp, flags, nd);
+ err = do_path_lookup_it(dfd, tmp, flags, nd);
putname(tmp);
}
return err;
}
+int fastcall __user_walk_fd(int dfd, const char __user *name, unsigned flags,
+ struct nameidata *nd)
+{
+ intent_init(&nd->intent, IT_LOOKUP);
+ return __user_walk_fd_it(dfd, name, flags, nd);
+}
+
+int fastcall __user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd)
+{
+ return __user_walk_fd_it(AT_FDCWD, name, flags, nd);
+}
+
int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
{
- return __user_walk_fd(AT_FDCWD, name, flags, nd);
+ intent_init(&nd->intent, IT_LOOKUP);
+ return __user_walk_it(name, flags, nd);
}
/*
@@ -1545,7 +1648,7 @@ int may_open(struct nameidata *nd, int a
if (!error) {
DQUOT_INIT(inode);
- error = do_truncate(dentry, 0, ATTR_MTIME|ATTR_CTIME, NULL);
+ error = do_truncate(dentry, 0, ATTR_MTIME|ATTR_CTIME, NULL, 1);
}
put_write_access(inode);
if (error)
@@ -1595,7 +1698,7 @@ int open_namei(int dfd, const char *path
*/
if (!(flag & O_CREAT)) {
error = path_lookup_open(dfd, pathname, lookup_flags(flag),
- nd, flag);
+ nd, flag, mode);
if (error)
return error;
goto ok;
@@ -1604,6 +1707,7 @@ int open_namei(int dfd, const char *path
/*
* Create - we need to know the parent.
*/
+ nd->intent.it_op |= IT_CREAT;
error = path_lookup_create(dfd,pathname,LOOKUP_PARENT,nd,flag,mode);
if (error)
return error;
@@ -1620,7 +1724,9 @@ int open_namei(int dfd, const char *path
dir = nd->dentry;
nd->flags &= ~LOOKUP_PARENT;
mutex_lock(&dir->d_inode->i_mutex);
+ nd->flags |= LOOKUP_LAST;
path.dentry = lookup_hash(nd);
+ nd->flags &= ~LOOKUP_LAST;
path.mnt = nd->mnt;
do_last:
@@ -1630,9 +1736,9 @@ do_last:
goto exit;
}
- if (IS_ERR(nd->intent.open.file)) {
+ if (IS_ERR(nd->intent.file)) {
mutex_unlock(&dir->d_inode->i_mutex);
- error = PTR_ERR(nd->intent.open.file);
+ error = PTR_ERR(nd->intent.file);
goto exit_dput;
}
@@ -1687,7 +1793,7 @@ ok:
exit_dput:
dput_path(&path, nd);
exit:
- if (!IS_ERR(nd->intent.open.file))
+ if (!IS_ERR(nd->intent.file))
release_open_intent(nd);
path_release(nd);
return error;
@@ -1736,7 +1842,9 @@ do_link:
}
dir = nd->dentry;
mutex_lock(&dir->d_inode->i_mutex);
+ nd->flags |= LOOKUP_LAST;
path.dentry = lookup_hash(nd);
+ nd->flags &= ~LOOKUP_LAST;
path.mnt = nd->mnt;
__putname(nd->last.name);
goto do_last;
@@ -1821,15 +1929,26 @@ asmlinkage long sys_mknodat(int dfd, con
struct dentry * dentry;
struct nameidata nd;
+
if (S_ISDIR(mode))
return -EPERM;
tmp = getname(filename);
if (IS_ERR(tmp))
return PTR_ERR(tmp);
- error = do_path_lookup(dfd, tmp, LOOKUP_PARENT, &nd);
+ intent_init(&nd.intent, IT_LOOKUP);
+ error = do_path_lookup_it(dfd, tmp, LOOKUP_PARENT, &nd);
if (error)
goto out;
+
+ if (nd.dentry->d_inode->i_op->mknod_raw) {
+ struct inode_operations *op = nd.dentry->d_inode->i_op;
+ error = op->mknod_raw(&nd, mode, dev);
+ /* the file system wants to use normal vfs path now */
+ if (error != -EOPNOTSUPP)
+ goto out2;
+ }
+
dentry = lookup_create(&nd, 0);
error = PTR_ERR(dentry);
@@ -1856,6 +1975,7 @@ asmlinkage long sys_mknodat(int dfd, con
dput(dentry);
}
mutex_unlock(&nd.dentry->d_inode->i_mutex);
+out2:
path_release(&nd);
out:
putname(tmp);
@@ -1901,9 +2021,18 @@ asmlinkage long sys_mkdirat(int dfd, con
struct dentry *dentry;
struct nameidata nd;
- error = do_path_lookup(dfd, tmp, LOOKUP_PARENT, &nd);
+ intent_init(&nd.intent, IT_LOOKUP);
+ error = do_path_lookup_it(dfd, tmp, LOOKUP_PARENT, &nd);
if (error)
goto out;
+ if (nd.dentry->d_inode->i_op->mkdir_raw) {
+ struct inode_operations *op = nd.dentry->d_inode->i_op;
+ error = op->mkdir_raw(&nd, mode);
+ /* the file system wants to use normal vfs path now */
+ if (error != -EOPNOTSUPP)
+ goto out2;
+ }
+
dentry = lookup_create(&nd, 1);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
@@ -1913,6 +2042,7 @@ asmlinkage long sys_mkdirat(int dfd, con
dput(dentry);
}
mutex_unlock(&nd.dentry->d_inode->i_mutex);
+out2:
path_release(&nd);
out:
putname(tmp);
@@ -1997,8 +2127,9 @@ static long do_rmdir(int dfd, const char
name = getname(pathname);
if(IS_ERR(name))
return PTR_ERR(name);
-
- error = do_path_lookup(dfd, name, LOOKUP_PARENT, &nd);
+
+ intent_init(&nd.intent, IT_LOOKUP);
+ error = do_path_lookup_it(dfd, name, LOOKUP_PARENT, &nd);
if (error)
goto exit;
@@ -2013,6 +2144,14 @@ static long do_rmdir(int dfd, const char
error = -EBUSY;
goto exit1;
}
+ if (nd.dentry->d_inode->i_op->rmdir_raw) {
+ struct inode_operations *op = nd.dentry->d_inode->i_op;
+
+ error = op->rmdir_raw(&nd);
+ /* the file system wants to use normal vfs path now */
+ if (error != -EOPNOTSUPP)
+ goto exit1;
+ }
mutex_lock(&nd.dentry->d_inode->i_mutex);
dentry = lookup_hash(&nd);
error = PTR_ERR(dentry);
@@ -2081,12 +2220,20 @@ static long do_unlinkat(int dfd, const c
if(IS_ERR(name))
return PTR_ERR(name);
- error = do_path_lookup(dfd, name, LOOKUP_PARENT, &nd);
+ intent_init(&nd.intent, IT_LOOKUP);
+ error = do_path_lookup_it(dfd, name, LOOKUP_PARENT, &nd);
if (error)
goto exit;
error = -EISDIR;
if (nd.last_type != LAST_NORM)
goto exit1;
+ if (nd.dentry->d_inode->i_op->unlink_raw) {
+ struct inode_operations *op = nd.dentry->d_inode->i_op;
+ error = op->unlink_raw(&nd);
+ /* the file system wants to use normal vfs path now */
+ if (error != -EOPNOTSUPP)
+ goto exit1;
+ }
mutex_lock(&nd.dentry->d_inode->i_mutex);
dentry = lookup_hash(&nd);
error = PTR_ERR(dentry);
@@ -2169,9 +2316,17 @@ asmlinkage long sys_symlinkat(const char
struct dentry *dentry;
struct nameidata nd;
- error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd);
+ intent_init(&nd.intent, IT_LOOKUP);
+ error = do_path_lookup_it(newdfd, to, LOOKUP_PARENT, &nd);
if (error)
goto out;
+ if (nd.dentry->d_inode->i_op->symlink_raw) {
+ struct inode_operations *op = nd.dentry->d_inode->i_op;
+ error = op->symlink_raw(&nd, from);
+ /* the file system wants to use normal vfs path now */
+ if (error != -EOPNOTSUPP)
+ goto out2;
+ }
dentry = lookup_create(&nd, 0);
error = PTR_ERR(dentry);
if (!IS_ERR(dentry)) {
@@ -2179,6 +2334,7 @@ asmlinkage long sys_symlinkat(const char
dput(dentry);
}
mutex_unlock(&nd.dentry->d_inode->i_mutex);
+out2:
path_release(&nd);
out:
putname(to);
@@ -2255,15 +2411,25 @@ asmlinkage long sys_linkat(int olddfd, c
if (IS_ERR(to))
return PTR_ERR(to);
- error = __user_walk_fd(olddfd, oldname, 0, &old_nd);
+ intent_init(&old_nd.intent, IT_LOOKUP);
+ error = __user_walk_fd_it(olddfd, oldname, 0, &old_nd);
if (error)
goto exit;
- error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd);
+
+ intent_init(&nd.intent, IT_LOOKUP);
+ error = do_path_lookup_it(newdfd, to, LOOKUP_PARENT, &nd);
if (error)
goto out;
error = -EXDEV;
if (old_nd.mnt != nd.mnt)
goto out_release;
+ if (nd.dentry->d_inode->i_op->link_raw) {
+ struct inode_operations *op = nd.dentry->d_inode->i_op;
+ error = op->link_raw(&old_nd, &nd);
+ /* the file system wants to use normal vfs path now */
+ if (error != -EOPNOTSUPP)
+ goto out_release;
+ }
new_dentry = lookup_create(&nd, 0);
error = PTR_ERR(new_dentry);
if (!IS_ERR(new_dentry)) {
@@ -2440,12 +2606,14 @@ static int do_rename(int olddfd, const c
struct dentry * old_dentry, *new_dentry;
struct dentry * trap;
struct nameidata oldnd, newnd;
-
- error = do_path_lookup(olddfd, oldname, LOOKUP_PARENT, &oldnd);
+
+ intent_init(&oldnd.intent, IT_LOOKUP);
+ error = do_path_lookup_it(olddfd, oldname, LOOKUP_PARENT, &oldnd);
if (error)
goto exit;
-
- error = do_path_lookup(newdfd, newname, LOOKUP_PARENT, &newnd);
+
+ intent_init(&newnd.intent, IT_LOOKUP);
+ error = do_path_lookup_it(newdfd, newname, LOOKUP_PARENT, &newnd);
if (error)
goto exit1;
@@ -2462,6 +2630,13 @@ static int do_rename(int olddfd, const c
if (newnd.last_type != LAST_NORM)
goto exit2;
+ if (old_dir->d_inode->i_op->rename_raw) {
+ error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
+ /* the file system wants to use normal vfs path now */
+ if (error != -EOPNOTSUPP)
+ goto exit2;
+ }
+
trap = lock_rename(new_dir, old_dir);
old_dentry = lookup_hash(&oldnd);
@@ -2493,8 +2668,7 @@ static int do_rename(int olddfd, const c
if (new_dentry == trap)
goto exit5;
- error = vfs_rename(old_dir->d_inode, old_dentry,
- new_dir->d_inode, new_dentry);
+ error = vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry);
exit5:
dput(new_dentry);
exit4:
@@ -2700,6 +2874,7 @@ EXPORT_SYMBOL(__page_symlink);
EXPORT_SYMBOL(page_symlink);
EXPORT_SYMBOL(page_symlink_inode_operations);
EXPORT_SYMBOL(path_lookup);
+EXPORT_SYMBOL(path_lookup_it);
EXPORT_SYMBOL(path_release);
EXPORT_SYMBOL(path_walk);
EXPORT_SYMBOL(permission);
Index: LINUX-SRC-TREE/fs/namespace.c
===================================================================
--- LINUX-SRC-TREE.orig/fs/namespace.c
+++ LINUX-SRC-TREE/fs/namespace.c
@@ -75,6 +75,7 @@ struct vfsmount *alloc_vfsmnt(const char
INIT_LIST_HEAD(&mnt->mnt_share);
INIT_LIST_HEAD(&mnt->mnt_slave_list);
INIT_LIST_HEAD(&mnt->mnt_slave);
+ INIT_LIST_HEAD(&mnt->mnt_lustre_list);
if (name) {
int size = strlen(name) + 1;
char *newname = kmalloc(size, GFP_KERNEL);
@@ -155,6 +156,7 @@ static void __touch_namespace(struct nam
static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd)
{
+ memset(old_nd, 0, sizeof(*old_nd));
old_nd->dentry = mnt->mnt_mountpoint;
old_nd->mnt = mnt->mnt_parent;
mnt->mnt_parent = mnt;
@@ -273,6 +275,9 @@ static inline void __mntput(struct vfsmo
{
struct super_block *sb = mnt->mnt_sb;
dput(mnt->mnt_root);
+ spin_lock(&dcache_lock);
+ list_del(&mnt->mnt_lustre_list);
+ spin_unlock(&dcache_lock);
free_vfsmnt(mnt);
deactivate_super(sb);
}
@@ -539,6 +544,8 @@ static int do_umount(struct vfsmount *mn
*/
lock_kernel();
+ if (sb->s_op->umount_lustre)
+ sb->s_op->umount_lustre(sb);
if ((flags & MNT_FORCE) && sb->s_op->umount_begin)
sb->s_op->umount_begin(sb);
unlock_kernel();
@@ -871,7 +878,8 @@ static int do_loopback(struct nameidata
return err;
if (!old_name || !*old_name)
return -EINVAL;
- err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
+ intent_init(&old_nd.intent, IT_LOOKUP);
+ err = path_lookup_it(old_name, LOOKUP_FOLLOW, &old_nd);
if (err)
return err;
@@ -956,7 +964,8 @@ static int do_move_mount(struct nameidat
return -EPERM;
if (!old_name || !*old_name)
return -EINVAL;
- err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
+ intent_init(&old_nd.intent, IT_LOOKUP);
+ err = path_lookup_it(old_name, LOOKUP_FOLLOW, &old_nd);
if (err)
return err;
@@ -1271,6 +1280,7 @@ long do_mount(char *dev_name, char *dir_
int retval = 0;
int mnt_flags = 0;
+
/* Discard magic */
if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
flags &= ~MS_MGC_MSK;
@@ -1301,7 +1311,8 @@ long do_mount(char *dev_name, char *dir_
MS_NOATIME | MS_NODIRATIME);
/* ... and get the mountpoint */
- retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
+ intent_init(&nd.intent, IT_LOOKUP);
+ retval = path_lookup_it(dir_name, LOOKUP_FOLLOW, &nd);
if (retval)
return retval;
Index: LINUX-SRC-TREE/fs/nfs/dir.c
===================================================================
--- LINUX-SRC-TREE.orig/fs/nfs/dir.c
+++ LINUX-SRC-TREE/fs/nfs/dir.c
@@ -834,7 +834,7 @@ int nfs_is_exclusive_create(struct inode
return 0;
if (nd == NULL || nfs_lookup_check_intent(nd, LOOKUP_CREATE) == 0)
return 0;
- return (nd->intent.open.flags & O_EXCL) != 0;
+ return (nd->intent.it_flags & O_EXCL) != 0;
}
static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd)
@@ -911,7 +911,7 @@ static int is_atomic_open(struct inode *
if (nd->flags & LOOKUP_DIRECTORY)
return 0;
/* Are we trying to write to a read only partition? */
- if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
+ if (IS_RDONLY(dir) && (nd->intent.it_flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
return 0;
return 1;
}
@@ -932,7 +932,7 @@ static struct dentry *nfs_atomic_lookup(
dentry->d_op = NFS_PROTO(dir)->dentry_ops;
/* Let vfs_create() deal with O_EXCL */
- if (nd->intent.open.flags & O_EXCL) {
+ if (nd->intent.it_flags & O_EXCL) {
d_add(dentry, NULL);
goto out;
}
@@ -947,7 +947,7 @@ static struct dentry *nfs_atomic_lookup(
goto out;
}
- if (nd->intent.open.flags & O_CREAT) {
+ if (nd->intent.it_flags & O_CREAT) {
nfs_begin_data_update(dir);
res = nfs4_atomic_open(dir, dentry, nd);
nfs_end_data_update(dir);
@@ -966,7 +966,7 @@ static struct dentry *nfs_atomic_lookup(
case -ENOTDIR:
goto no_open;
case -ELOOP:
- if (!(nd->intent.open.flags & O_NOFOLLOW))
+ if (!(nd->intent.it_flags & O_NOFOLLOW))
goto no_open;
/* case -EINVAL: */
default:
@@ -1002,7 +1002,7 @@ static int nfs_open_revalidate(struct de
/* NFS only supports OPEN on regular files */
if (!S_ISREG(inode->i_mode))
goto no_open;
- openflags = nd->intent.open.flags;
+ openflags = nd->intent.it_flags;
/* We cannot do exclusive creation on a positive dentry */
if ((openflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
goto no_open;
@@ -1138,7 +1138,7 @@ static int nfs_create(struct inode *dir,
attr.ia_valid = ATTR_MODE;
if (nd && (nd->flags & LOOKUP_CREATE))
- open_flags = nd->intent.open.flags;
+ open_flags = nd->intent.it_flags;
lock_kernel();
nfs_begin_data_update(dir);
Index: LINUX-SRC-TREE/fs/nfs/nfs4proc.c
===================================================================
--- LINUX-SRC-TREE.orig/fs/nfs/nfs4proc.c
+++ LINUX-SRC-TREE/fs/nfs/nfs4proc.c
@@ -1220,7 +1220,7 @@ static void nfs4_intent_set_file(struct
ctx = (struct nfs_open_context *)filp->private_data;
ctx->state = state;
} else
- nfs4_close_state(state, nd->intent.open.flags);
+ nfs4_close_state(state, nd->intent.flags);
}
struct dentry *
@@ -1232,19 +1232,19 @@ nfs4_atomic_open(struct inode *dir, stru
struct dentry *res;
if (nd->flags & LOOKUP_CREATE) {
- attr.ia_mode = nd->intent.open.create_mode;
+ attr.ia_mode = nd->intent.create_mode;
attr.ia_valid = ATTR_MODE;
if (!IS_POSIXACL(dir))
attr.ia_mode &= ~current->fs->umask;
} else {
attr.ia_valid = 0;
- BUG_ON(nd->intent.open.flags & O_CREAT);
+ BUG_ON(nd->intent.flags & O_CREAT);
}
cred = rpcauth_lookupcred(NFS_SERVER(dir)->client->cl_auth, 0);
if (IS_ERR(cred))
return (struct dentry *)cred;
- state = nfs4_do_open(dir, dentry, nd->intent.open.flags, &attr, cred);
+ state = nfs4_do_open(dir, dentry, nd->intent.flags, &attr, cred);
put_rpccred(cred);
if (IS_ERR(state)) {
if (PTR_ERR(state) == -ENOENT)
Index: LINUX-SRC-TREE/fs/nfsctl.c
===================================================================
--- LINUX-SRC-TREE.orig/fs/nfsctl.c
+++ LINUX-SRC-TREE/fs/nfsctl.c
@@ -26,6 +26,7 @@ static struct file *do_open(char *name,
struct nameidata nd;
int error;
+ intent_init(&nd.intent, IT_OPEN);
nd.mnt = do_kern_mount("nfsd", 0, "nfsd", NULL);
if (IS_ERR(nd.mnt))
Index: LINUX-SRC-TREE/fs/open.c
===================================================================
--- LINUX-SRC-TREE.orig/fs/open.c
+++ LINUX-SRC-TREE/fs/open.c
@@ -198,9 +198,10 @@ out:
}
int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
- struct file *filp)
+ struct file *filp, int called_from_open)
{
int err;
+ struct inode_operations *op = dentry->d_inode->i_op;
struct iattr newattrs;
/* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
@@ -215,7 +216,17 @@ int do_truncate(struct dentry *dentry, l
}
mutex_lock(&dentry->d_inode->i_mutex);
- err = notify_change(dentry, &newattrs);
+ if (called_from_open)
+ newattrs.ia_valid |= ATTR_FROM_OPEN;
+ if (op->setattr_raw) {
+ newattrs.ia_valid |= ATTR_RAW;
+ newattrs.ia_ctime = CURRENT_TIME;
+ down_write(&dentry->d_inode->i_alloc_sem);
+ err = op->setattr_raw(dentry->d_inode, &newattrs);
+ up_write(&dentry->d_inode->i_alloc_sem);
+ } else
+ err = notify_change(dentry, &newattrs);
+
mutex_unlock(&dentry->d_inode->i_mutex);
return err;
}
@@ -225,12 +236,12 @@ static long do_sys_truncate(const char _
struct nameidata nd;
struct inode * inode;
int error;
-
+ intent_init(&nd.intent, IT_GETATTR);
error = -EINVAL;
if (length < 0) /* sorry, but loff_t says... */
goto out;
- error = user_path_walk(path, &nd);
+ error = user_path_walk_it(path, &nd);
if (error)
goto out;
inode = nd.dentry->d_inode;
@@ -270,7 +281,7 @@ static long do_sys_truncate(const char _
error = locks_verify_truncate(inode, NULL, length);
if (!error) {
DQUOT_INIT(inode);
- error = do_truncate(nd.dentry, length, 0, NULL);
+ error = do_truncate(nd.dentry, length, 0, NULL, 0);
}
put_write_access(inode);
@@ -322,7 +333,7 @@ static long do_sys_ftruncate(unsigned in
error = locks_verify_truncate(inode, file, length);
if (!error)
- error = do_truncate(dentry, length, 0, file);
+ error = do_truncate(dentry, length, 0, file, 0);
out_putf:
fput(file);
out:
@@ -407,9 +418,20 @@ asmlinkage long sys_utime(char __user *
(error = vfs_permission(&nd, MAY_WRITE)) != 0)
goto dput_and_out;
}
- mutex_lock(&inode->i_mutex);
- error = notify_change(nd.dentry, &newattrs);
- mutex_unlock(&inode->i_mutex);
+ if (inode->i_op->setattr_raw) {
+ struct inode_operations *op = nd.dentry->d_inode->i_op;
+
+ newattrs.ia_valid |= ATTR_RAW;
+ error = op->setattr_raw(inode, &newattrs);
+ /* the file system wants to use normal vfs path now */
+ if (error != -EOPNOTSUPP)
+ goto dput_and_out;
+ } else {
+ mutex_lock(&inode->i_mutex);
+ error = notify_change(nd.dentry, &newattrs);
+ mutex_unlock(&inode->i_mutex);
+ }
+
dput_and_out:
path_release(&nd);
out:
@@ -495,6 +517,7 @@ asmlinkage long sys_faccessat(int dfd, c
int old_fsuid, old_fsgid;
kernel_cap_t old_cap;
int res;
+ intent_init(&nd.intent, IT_GETATTR);
if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
return -EINVAL;
@@ -519,7 +542,7 @@ asmlinkage long sys_faccessat(int dfd, c
else
current->cap_effective = current->cap_permitted;
- res = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
+ res = __user_walk_fd_it(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
if (!res) {
res = vfs_permission(&nd, mode);
/* SuS v2 requires we report a read only fs too */
@@ -545,8 +568,9 @@ asmlinkage long sys_chdir(const char __u
{
struct nameidata nd;
int error;
+ intent_init(&nd.intent, IT_GETATTR);
- error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
+ error = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
if (error)
goto out;
@@ -596,8 +620,9 @@ asmlinkage long sys_chroot(const char __
{
struct nameidata nd;
int error;
+ intent_init(&nd.intent, IT_GETATTR);
- error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
+ error = __user_walk_it(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
if (error)
goto out;
@@ -618,38 +643,55 @@ out:
return error;
}
-asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
+int chmod_common(struct dentry *dentry, mode_t mode)
{
- struct inode * inode;
- struct dentry * dentry;
- struct file * file;
- int err = -EBADF;
+ struct inode * inode = dentry->d_inode;
struct iattr newattrs;
+ int error = -EROFS;
- file = fget(fd);
- if (!file)
+ if (IS_RDONLY(inode))
goto out;
- dentry = file->f_dentry;
- inode = dentry->d_inode;
+ if (inode->i_op->setattr_raw) {
+ struct inode_operations *op = dentry->d_inode->i_op;
- audit_inode(NULL, inode);
+ newattrs.ia_mode = mode;
+ newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
+ newattrs.ia_valid |= ATTR_RAW;
+ error = op->setattr_raw(inode, &newattrs);
+ /* the file system wants to use normal vfs path now */
+ if (error != -EOPNOTSUPP)
+ goto out;
+ }
- err = -EROFS;
- if (IS_RDONLY(inode))
- goto out_putf;
- err = -EPERM;
+ error = -EPERM;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
- goto out_putf;
+ goto out;
+
mutex_lock(&inode->i_mutex);
if (mode == (mode_t) -1)
mode = inode->i_mode;
newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
- err = notify_change(dentry, &newattrs);
+ error = notify_change(dentry, &newattrs);
mutex_unlock(&inode->i_mutex);
+out:
+ return error;
+}
+
+asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
+{
+ struct file * file;
+ int err = -EBADF;
+
+ file = fget(fd);
+ if (!file)
+ goto out;
+
+ audit_inode(NULL, file->f_dentry->d_inode);
+
+ err = chmod_common(file->f_dentry, mode);
-out_putf:
fput(file);
out:
return err;
@@ -659,32 +701,12 @@ asmlinkage long sys_fchmodat(int dfd, co
mode_t mode)
{
struct nameidata nd;
- struct inode * inode;
int error;
- struct iattr newattrs;
error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
if (error)
goto out;
- inode = nd.dentry->d_inode;
-
- error = -EROFS;
- if (IS_RDONLY(inode))
- goto dput_and_out;
-
- error = -EPERM;
- if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
- goto dput_and_out;
-
- mutex_lock(&inode->i_mutex);
- if (mode == (mode_t) -1)
- mode = inode->i_mode;
- newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
- newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
- error = notify_change(nd.dentry, &newattrs);
- mutex_unlock(&inode->i_mutex);
-
-dput_and_out:
+ error = chmod_common(nd.dentry, mode);
path_release(&nd);
out:
return error;
@@ -710,6 +732,18 @@ static int chown_common(struct dentry *
if (IS_RDONLY(inode))
goto out;
error = -EPERM;
+ if (inode->i_op->setattr_raw) {
+ struct inode_operations *op = dentry->d_inode->i_op;
+
+ newattrs.ia_uid = user;
+ newattrs.ia_gid = group;
+ newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
+ newattrs.ia_valid |= ATTR_RAW;
+ error = op->setattr_raw(inode, &newattrs);
+ /* the file system wants to use normal vfs path now */
+ if (error != -EOPNOTSUPP)
+ return error;
+ }
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
goto out;
newattrs.ia_valid = ATTR_CTIME;
@@ -823,6 +857,7 @@ static struct file *__dentry_open(struct
error = open(inode, f);
if (error)
goto cleanup_all;
+ intent_release(f->f_it);
}
f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
@@ -849,6 +884,7 @@ cleanup_all:
f->f_dentry = NULL;
f->f_vfsmnt = NULL;
cleanup_file:
+ intent_release(f->f_it);
put_filp(f);
dput(dentry);
mntput(mnt);
@@ -874,6 +910,7 @@ static struct file *do_filp_open(int dfd
{
int namei_flags, error;
struct nameidata nd;
+ intent_init(&nd.intent, IT_OPEN);
namei_flags = flags;
if ((namei_flags+1) & O_ACCMODE)
@@ -910,19 +947,19 @@ EXPORT_SYMBOL(filp_open);
struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
int (*open)(struct inode *, struct file *))
{
- if (IS_ERR(nd->intent.open.file))
+ if (IS_ERR(nd->intent.file))
goto out;
if (IS_ERR(dentry))
goto out_err;
- nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->mnt),
- nd->intent.open.flags - 1,
- nd->intent.open.file,
+ nd->intent.file = __dentry_open(dget(dentry), mntget(nd->mnt),
+ nd->intent.flags - 1,
+ nd->intent.file,
open);
out:
- return nd->intent.open.file;
+ return nd->intent.file;
out_err:
release_open_intent(nd);
- nd->intent.open.file = (struct file *)dentry;
+ nd->intent.file = (struct file *)dentry;
goto out;
}
EXPORT_SYMBOL_GPL(lookup_instantiate_filp);
@@ -939,7 +976,8 @@ struct file *nameidata_to_filp(struct na
struct file *filp;
/* Pick up the filp from the open intent */
- filp = nd->intent.open.file;
+ filp = nd->intent.file;
+ filp->f_it = &nd->intent;
/* Has the filesystem initialised the file for us? */
if (filp->f_dentry == NULL)
filp = __dentry_open(nd->dentry, nd->mnt, flags, filp, NULL);
Index: LINUX-SRC-TREE/fs/stat.c
===================================================================
--- LINUX-SRC-TREE.orig/fs/stat.c
+++ LINUX-SRC-TREE/fs/stat.c
@@ -38,7 +38,7 @@ void generic_fillattr(struct inode *inod
EXPORT_SYMBOL(generic_fillattr);
-int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
+int vfs_getattr_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat *stat)
{
struct inode *inode = dentry->d_inode;
int retval;
@@ -47,6 +47,8 @@ int vfs_getattr(struct vfsmount *mnt, st
if (retval)
return retval;
+ if (inode->i_op->getattr_it)
+ return inode->i_op->getattr_it(mnt, dentry, it, stat);
if (inode->i_op->getattr)
return inode->i_op->getattr(mnt, dentry, stat);
@@ -61,6 +63,11 @@ int vfs_getattr(struct vfsmount *mnt, st
return 0;
}
+int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
+{
+ return vfs_getattr_it(mnt, dentry, NULL, stat);
+}
+
EXPORT_SYMBOL(vfs_getattr);
int vfs_stat_fd(int dfd, char __user *name, struct kstat *stat)
@@ -68,9 +75,10 @@ int vfs_stat_fd(int dfd, char __user *na
struct nameidata nd;
int error;
- error = __user_walk_fd(dfd, name, LOOKUP_FOLLOW, &nd);
+ intent_init(&nd.intent, IT_GETATTR);
+ error = __user_walk_fd_it(dfd, name, LOOKUP_FOLLOW, &nd);
if (!error) {
- error = vfs_getattr(nd.mnt, nd.dentry, stat);
+ error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
path_release(&nd);
}
return error;
@@ -88,9 +96,10 @@ int vfs_lstat_fd(int dfd, char __user *n
struct nameidata nd;
int error;
- error = __user_walk_fd(dfd, name, 0, &nd);
+ intent_init(&nd.intent, IT_GETATTR);
+ error = __user_walk_fd_it(dfd, name, 0, &nd);
if (!error) {
- error = vfs_getattr(nd.mnt, nd.dentry, stat);
+ error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
path_release(&nd);
}
return error;
@@ -107,9 +116,12 @@ int vfs_fstat(unsigned int fd, struct ks
{
struct file *f = fget(fd);
int error = -EBADF;
+ struct nameidata nd;
+ intent_init(&nd.intent, IT_GETATTR);
if (f) {
- error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
+ error = vfs_getattr_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
+ intent_release(&nd.intent);
fput(f);
}
return error;
Index: LINUX-SRC-TREE/include/linux/dcache.h
===================================================================
--- LINUX-SRC-TREE.orig/include/linux/dcache.h
+++ LINUX-SRC-TREE/include/linux/dcache.h
@@ -36,6 +36,9 @@ struct qstr {
const unsigned char *name;
};
+struct inode;
+#include <linux/namei.h>
+
struct dentry_stat_t {
int nr_dentry;
int nr_unused;
Index: LINUX-SRC-TREE/include/linux/fs.h
===================================================================
--- LINUX-SRC-TREE.orig/include/linux/fs.h
+++ LINUX-SRC-TREE/include/linux/fs.h
@@ -61,6 +61,7 @@ extern int dir_notify_enable;
#define FMODE_READ 1
#define FMODE_WRITE 2
+#define FMODE_EXEC 16
/* Internal kernel extensions */
#define FMODE_LSEEK 4
@@ -272,6 +273,8 @@ typedef void (dio_iodone_t)(struct kiocb
#define ATTR_KILL_SUID 2048
#define ATTR_KILL_SGID 4096
#define ATTR_FILE 8192
+#define ATTR_RAW 16384 /* file system, not vfs will massage attrs */
+#define ATTR_FROM_OPEN 65536 /* called from open path, ie O_TRUNC */
#define ATTR_NO_BLOCK 32768 /* Return EAGAIN and don't block on long truncates */
/*
@@ -517,6 +520,7 @@ struct inode {
struct block_device *i_bdev;
struct cdev *i_cdev;
int i_cindex;
+ void *i_filterdata;
__u32 i_generation;
@@ -664,6 +668,7 @@ struct file {
spinlock_t f_ep_lock;
#endif /* #ifdef CONFIG_EPOLL */
struct address_space *f_mapping;
+ struct lookup_intent *f_it;
};
extern spinlock_t files_lock;
#define file_list_lock() spin_lock(&files_lock);
@@ -1059,20 +1064,29 @@ struct inode_operations {
int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
int (*link) (struct dentry *,struct inode *,struct dentry *);
+ int (*link_raw) (struct nameidata *,struct nameidata *);
int (*unlink) (struct inode *,struct dentry *);
+ int (*unlink_raw) (struct nameidata *);
int (*symlink) (struct inode *,struct dentry *,const char *);
+ int (*symlink_raw) (struct nameidata *,const char *);
int (*mkdir) (struct inode *,struct dentry *,int);
+ int (*mkdir_raw) (struct nameidata *,int);
int (*rmdir) (struct inode *,struct dentry *);
+ int (*rmdir_raw) (struct nameidata *);
int (*mknod) (struct inode *,struct dentry *,int,dev_t);
+ int (*mknod_raw) (struct nameidata *,int,dev_t);
int (*rename) (struct inode *, struct dentry *,
struct inode *, struct dentry *);
+ int (*rename_raw) (struct nameidata *, struct nameidata *);
int (*readlink) (struct dentry *, char __user *,int);
void * (*follow_link) (struct dentry *, struct nameidata *);
void (*put_link) (struct dentry *, struct nameidata *, void *);
void (*truncate) (struct inode *);
int (*permission) (struct inode *, int, struct nameidata *);
int (*setattr) (struct dentry *, struct iattr *);
+ int (*setattr_raw) (struct inode *, struct iattr *);
int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
+ int (*getattr_it) (struct vfsmount *, struct dentry *, struct lookup_intent *, struct kstat *);
int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
ssize_t (*listxattr) (struct dentry *, char *, size_t);
@@ -1113,6 +1127,7 @@ struct super_operations {
int (*remount_fs) (struct super_block *, int *, char *);
void (*clear_inode) (struct inode *);
void (*umount_begin) (struct super_block *);
+ void (*umount_lustre) (struct super_block *);
int (*show_options)(struct seq_file *, struct vfsmount *);
@@ -1322,6 +1337,7 @@ extern int may_umount_tree(struct vfsmou
extern int may_umount(struct vfsmount *);
extern void umount_tree(struct vfsmount *, int, struct list_head *);
extern void release_mounts(struct list_head *);
+struct vfsmount *do_kern_mount(const char *type, int flags, const char *name, void *data);
extern long do_mount(char *, char *, char *, unsigned long, void *);
extern struct vfsmount *copy_tree(struct vfsmount *, struct dentry *, int);
extern void mnt_set_mountpoint(struct vfsmount *, struct dentry *,
@@ -1378,11 +1394,12 @@ static inline int break_lease(struct ino
/* fs/open.c */
extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
- struct file *filp);
+ struct file *filp, int called_from_open);
extern long do_sys_open(int fdf, const char __user *filename, int flags,
int mode);
extern struct file *filp_open(const char *, int, int);
extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
+extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
extern int filp_close(struct file *, fl_owner_t id);
extern char * getname(const char __user *);
Index: LINUX-SRC-TREE/include/linux/mount.h
===================================================================
--- LINUX-SRC-TREE.orig/include/linux/mount.h
+++ LINUX-SRC-TREE/include/linux/mount.h
@@ -46,6 +46,8 @@ struct vfsmount {
struct list_head mnt_slave; /* slave list entry */
struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */
struct namespace *mnt_namespace; /* containing namespace */
+ struct list_head mnt_lustre_list; /* GNS mount list */
+ unsigned long mnt_last_used; /* for GNS auto-umount (jiffies) */
int mnt_pinned;
};
Index: LINUX-SRC-TREE/include/linux/namei.h
===================================================================
--- LINUX-SRC-TREE.orig/include/linux/namei.h
+++ LINUX-SRC-TREE/include/linux/namei.h
@@ -5,10 +5,39 @@
struct vfsmount;
+#define IT_OPEN (1)
+#define IT_CREAT (1<<1)
+#define IT_READDIR (1<<2)
+#define IT_GETATTR (1<<3)
+#define IT_LOOKUP (1<<4)
+#define IT_UNLINK (1<<5)
+#define IT_TRUNC (1<<6)
+#define IT_GETXATTR (1<<7)
+
+struct lustre_intent_data {
+ int it_disposition;
+ int it_status;
+ __u64 it_lock_handle;
+ void *it_data;
+ int it_lock_mode;
+};
+
+#define INTENT_MAGIC 0x19620323
+
+#define it_flags flags
+#define it_create_mode create_mode
+#define lookup_intent open_intent
+
struct open_intent {
- int flags;
- int create_mode;
- struct file *file;
+ int it_magic;
+ void (*it_op_release)(struct open_intent *);
+ int it_op;
+ int flags;
+ int create_mode;
+ struct file *file;
+ union {
+ struct lustre_intent_data lustre;
+ } d;
};
enum { MAX_NESTED_LINKS = 8 };
@@ -22,12 +51,23 @@ struct nameidata {
unsigned depth;
char *saved_names[MAX_NESTED_LINKS + 1];
- /* Intent data */
- union {
- struct open_intent open;
- } intent;
+ struct lookup_intent intent;
};
+static inline void intent_reset_fs_part(struct lookup_intent *it)
+{
+ memset(&it->d, 0, sizeof(it->d));
+ it->it_magic = INTENT_MAGIC;
+ it->it_op_release = NULL;
+}
+
+static inline void intent_init(struct lookup_intent *it, int op)
+{
+ memset(it, 0, sizeof(*it));
+ it->it_magic = INTENT_MAGIC;
+ it->it_op = op;
+}
+
/*
* Type of the last component on LOOKUP_PARENT
*/
@@ -48,6 +88,8 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA
#define LOOKUP_PARENT 16
#define LOOKUP_NOALT 32
#define LOOKUP_REVAL 64
+#define LOOKUP_LAST (0x1000)
+#define LOOKUP_LINK_NOTLAST (0x2000)
/*
* Intent data
*/
@@ -57,18 +99,29 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA
extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
extern int FASTCALL(__user_walk_fd(int dfd, const char __user *, unsigned, struct nameidata *));
+extern int FASTCALL(__user_walk_fd_it(int dfd, const char __user *, unsigned, struct nameidata *));
#define user_path_walk(name,nd) \
__user_walk_fd(AT_FDCWD, name, LOOKUP_FOLLOW, nd)
#define user_path_walk_link(name,nd) \
__user_walk_fd(AT_FDCWD, name, 0, nd)
+
+extern int FASTCALL(__user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd));
+#define user_path_walk_it(name,nd) \
+ __user_walk_it(name, LOOKUP_FOLLOW, nd)
+#define user_path_walk_link_it(name,nd) \
+ __user_walk_it(name, 0, nd)
+extern void intent_release(struct lookup_intent *);
+
extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
+extern int FASTCALL(path_lookup_it(const char *, unsigned, struct nameidata *));
extern int FASTCALL(path_walk(const char *, struct nameidata *));
extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
extern void path_release(struct nameidata *);
extern void path_release_on_umount(struct nameidata *);
extern int __user_path_lookup_open(const char __user *, unsigned lookup_flags, struct nameidata *nd, int open_flags);
-extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, int open_flags);
+extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *,
+ int open_flags, int create_mode);
extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
int (*open)(struct inode *, struct file *));
extern struct file *nameidata_to_filp(struct nameidata *nd, int flags);
|