Merge git://git.infradead.org/mtd-2.6

* git://git.infradead.org/mtd-2.6:
[MTD] [NOR] Fix deadlock in Intel chip driver caused by get_chip recursion
[JFFS2] Fix return value from jffs2_write_end()
[MTD] [OneNAND] Fix wrong free the static address in onenand_sim
[MTD] [NAND] Replace -1 with -EBADMSG in nand error correction code
[RSLIB] BUG() when passing illegal parameters to decode_rs8() or decode_rs16()
[MTD] [NAND] treat any negative return value from correct() as an error
[MTD] [NAND] nandsim: bugfix in initialization
[MTD] Fix typo in Alauda config option help text.
[MTD] [NAND] add s3c2440-specific read_buf/write_buf
[MTD] [OneNAND] onenand-sim: fix kernel-doc and typos
[JFFS2] Tidy up fix for ACL/permissions problem.

+226 -199
+77 -69
drivers/mtd/chips/cfi_cmdset_0001.c
··· 85 85 static void cfi_intelext_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, 86 86 size_t len); 87 87 88 + static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode); 88 89 static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode); 89 90 static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr); 90 91 #include "fwh_lock.h" ··· 642 641 /* 643 642 * *********** CHIP ACCESS FUNCTIONS *********** 644 643 */ 645 - 646 - static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode) 644 + static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode) 647 645 { 648 646 DECLARE_WAITQUEUE(wait, current); 649 647 struct cfi_private *cfi = map->fldrv_priv; 650 648 map_word status, status_OK = CMD(0x80), status_PWS = CMD(0x01); 651 - unsigned long timeo; 652 649 struct cfi_pri_intelext *cfip = cfi->cmdset_priv; 653 - 654 - resettime: 655 - timeo = jiffies + HZ; 656 - retry: 657 - if (chip->priv && (mode == FL_WRITING || mode == FL_ERASING || mode == FL_OTP_WRITE || mode == FL_SHUTDOWN)) { 658 - /* 659 - * OK. We have possibility for contension on the write/erase 660 - * operations which are global to the real chip and not per 661 - * partition. So let's fight it over in the partition which 662 - * currently has authority on the operation. 663 - * 664 - * The rules are as follows: 665 - * 666 - * - any write operation must own shared->writing. 667 - * 668 - * - any erase operation must own _both_ shared->writing and 669 - * shared->erasing. 670 - * 671 - * - contension arbitration is handled in the owner's context. 672 - * 673 - * The 'shared' struct can be read and/or written only when 674 - * its lock is taken. 675 - */ 676 - struct flchip_shared *shared = chip->priv; 677 - struct flchip *contender; 678 - spin_lock(&shared->lock); 679 - contender = shared->writing; 680 - if (contender && contender != chip) { 681 - /* 682 - * The engine to perform desired operation on this 683 - * partition is already in use by someone else. 684 - * Let's fight over it in the context of the chip 685 - * currently using it. If it is possible to suspend, 686 - * that other partition will do just that, otherwise 687 - * it'll happily send us to sleep. In any case, when 688 - * get_chip returns success we're clear to go ahead. 689 - */ 690 - int ret = spin_trylock(contender->mutex); 691 - spin_unlock(&shared->lock); 692 - if (!ret) 693 - goto retry; 694 - spin_unlock(chip->mutex); 695 - ret = get_chip(map, contender, contender->start, mode); 696 - spin_lock(chip->mutex); 697 - if (ret) { 698 - spin_unlock(contender->mutex); 699 - return ret; 700 - } 701 - timeo = jiffies + HZ; 702 - spin_lock(&shared->lock); 703 - spin_unlock(contender->mutex); 704 - } 705 - 706 - /* We now own it */ 707 - shared->writing = chip; 708 - if (mode == FL_ERASING) 709 - shared->erasing = chip; 710 - spin_unlock(&shared->lock); 711 - } 650 + unsigned long timeo = jiffies + HZ; 712 651 713 652 switch (chip->state) { 714 653 ··· 663 722 if (chip->priv && map_word_andequal(map, status, status_PWS, status_PWS)) 664 723 break; 665 724 666 - if (time_after(jiffies, timeo)) { 667 - printk(KERN_ERR "%s: Waiting for chip to be ready timed out. Status %lx\n", 668 - map->name, status.x[0]); 669 - return -EIO; 670 - } 671 725 spin_unlock(chip->mutex); 672 726 cfi_udelay(1); 673 727 spin_lock(chip->mutex); 674 728 /* Someone else might have been playing with it. */ 675 - goto retry; 729 + return -EAGAIN; 676 730 } 677 731 678 732 case FL_READY: ··· 745 809 schedule(); 746 810 remove_wait_queue(&chip->wq, &wait); 747 811 spin_lock(chip->mutex); 748 - goto resettime; 812 + return -EAGAIN; 749 813 } 814 + } 815 + 816 + static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode) 817 + { 818 + int ret; 819 + 820 + retry: 821 + if (chip->priv && (mode == FL_WRITING || mode == FL_ERASING 822 + || mode == FL_OTP_WRITE || mode == FL_SHUTDOWN)) { 823 + /* 824 + * OK. We have possibility for contention on the write/erase 825 + * operations which are global to the real chip and not per 826 + * partition. So let's fight it over in the partition which 827 + * currently has authority on the operation. 828 + * 829 + * The rules are as follows: 830 + * 831 + * - any write operation must own shared->writing. 832 + * 833 + * - any erase operation must own _both_ shared->writing and 834 + * shared->erasing. 835 + * 836 + * - contention arbitration is handled in the owner's context. 837 + * 838 + * The 'shared' struct can be read and/or written only when 839 + * its lock is taken. 840 + */ 841 + struct flchip_shared *shared = chip->priv; 842 + struct flchip *contender; 843 + spin_lock(&shared->lock); 844 + contender = shared->writing; 845 + if (contender && contender != chip) { 846 + /* 847 + * The engine to perform desired operation on this 848 + * partition is already in use by someone else. 849 + * Let's fight over it in the context of the chip 850 + * currently using it. If it is possible to suspend, 851 + * that other partition will do just that, otherwise 852 + * it'll happily send us to sleep. In any case, when 853 + * get_chip returns success we're clear to go ahead. 854 + */ 855 + ret = spin_trylock(contender->mutex); 856 + spin_unlock(&shared->lock); 857 + if (!ret) 858 + goto retry; 859 + spin_unlock(chip->mutex); 860 + ret = chip_ready(map, contender, contender->start, mode); 861 + spin_lock(chip->mutex); 862 + 863 + if (ret == -EAGAIN) { 864 + spin_unlock(contender->mutex); 865 + goto retry; 866 + } 867 + if (ret) { 868 + spin_unlock(contender->mutex); 869 + return ret; 870 + } 871 + spin_lock(&shared->lock); 872 + spin_unlock(contender->mutex); 873 + } 874 + 875 + /* We now own it */ 876 + shared->writing = chip; 877 + if (mode == FL_ERASING) 878 + shared->erasing = chip; 879 + spin_unlock(&shared->lock); 880 + } 881 + ret = chip_ready(map, chip, adr, mode); 882 + if (ret == -EAGAIN) 883 + goto retry; 884 + 885 + return ret; 750 886 } 751 887 752 888 static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr)
+1 -1
drivers/mtd/nand/Kconfig
··· 300 300 via platform_data. 301 301 302 302 config MTD_ALAUDA 303 - tristate "MTD driver for Olympus MAUSB-10 and Fijufilm DPC-R1" 303 + tristate "MTD driver for Olympus MAUSB-10 and Fujifilm DPC-R1" 304 304 depends on MTD_NAND && USB 305 305 help 306 306 These two (and possibly other) Alauda-based cardreaders for
+2 -2
drivers/mtd/nand/diskonchip.c
··· 220 220 } 221 221 } 222 222 /* If the parity is wrong, no rescue possible */ 223 - return parity ? -1 : nerr; 223 + return parity ? -EBADMSG : nerr; 224 224 } 225 225 226 226 static void DoC_Delay(struct doc_priv *doc, unsigned short cycles) ··· 1034 1034 WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf); 1035 1035 else 1036 1036 WriteDOC(DOC_ECC_DIS, docptr, ECCConf); 1037 - if (no_ecc_failures && (ret == -1)) { 1037 + if (no_ecc_failures && (ret == -EBADMSG)) { 1038 1038 printk(KERN_ERR "suppressing ECC failure\n"); 1039 1039 ret = 0; 1040 1040 }
+3 -3
drivers/mtd/nand/nand_base.c
··· 789 789 int stat; 790 790 791 791 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); 792 - if (stat == -1) 792 + if (stat < 0) 793 793 mtd->ecc_stats.failed++; 794 794 else 795 795 mtd->ecc_stats.corrected += stat; ··· 833 833 int stat; 834 834 835 835 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); 836 - if (stat == -1) 836 + if (stat < 0) 837 837 mtd->ecc_stats.failed++; 838 838 else 839 839 mtd->ecc_stats.corrected += stat; ··· 874 874 chip->read_buf(mtd, oob, eccbytes); 875 875 stat = chip->ecc.correct(mtd, p, oob, NULL); 876 876 877 - if (stat == -1) 877 + if (stat < 0) 878 878 mtd->ecc_stats.failed++; 879 879 else 880 880 mtd->ecc_stats.corrected += stat;
+1 -1
drivers/mtd/nand/nand_ecc.c
··· 189 189 if(countbits(s0 | ((uint32_t)s1 << 8) | ((uint32_t)s2 <<16)) == 1) 190 190 return 1; 191 191 192 - return -1; 192 + return -EBADMSG; 193 193 } 194 194 EXPORT_SYMBOL(nand_correct_data); 195 195
+1 -1
drivers/mtd/nand/nandsim.c
··· 511 511 } 512 512 513 513 if (ns->options & OPT_SMALLPAGE) { 514 - if (ns->geom.totsz < (64 << 20)) { 514 + if (ns->geom.totsz < (32 << 20)) { 515 515 ns->geom.pgaddrbytes = 3; 516 516 ns->geom.secaddrbytes = 2; 517 517 } else {
+14
drivers/mtd/nand/s3c2410.c
··· 488 488 readsb(this->IO_ADDR_R, buf, len); 489 489 } 490 490 491 + static void s3c2440_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) 492 + { 493 + struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); 494 + readsl(info->regs + S3C2440_NFDATA, buf, len / 4); 495 + } 496 + 491 497 static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) 492 498 { 493 499 struct nand_chip *this = mtd->priv; 494 500 writesb(this->IO_ADDR_W, buf, len); 501 + } 502 + 503 + static void s3c2440_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) 504 + { 505 + struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); 506 + writesl(info->regs + S3C2440_NFDATA, buf, len / 4); 495 507 } 496 508 497 509 /* device management functions */ ··· 616 604 info->sel_bit = S3C2440_NFCONT_nFCE; 617 605 chip->cmd_ctrl = s3c2440_nand_hwcontrol; 618 606 chip->dev_ready = s3c2440_nand_devready; 607 + chip->read_buf = s3c2440_nand_read_buf; 608 + chip->write_buf = s3c2440_nand_write_buf; 619 609 break; 620 610 621 611 case TYPE_S3C2412:
+25 -25
drivers/mtd/onenand/onenand_sim.c
··· 88 88 89 89 /** 90 90 * onenand_lock_handle - Handle Lock scheme 91 - * @param this OneNAND device structure 92 - * @param cmd The command to be sent 91 + * @this: OneNAND device structure 92 + * @cmd: The command to be sent 93 93 * 94 94 * Send lock command to OneNAND device. 95 - * The lock scheme is depends on chip type. 95 + * The lock scheme depends on chip type. 96 96 */ 97 97 static void onenand_lock_handle(struct onenand_chip *this, int cmd) 98 98 { ··· 131 131 132 132 /** 133 133 * onenand_bootram_handle - Handle BootRAM area 134 - * @param this OneNAND device structure 135 - * @param cmd The command to be sent 134 + * @this: OneNAND device structure 135 + * @cmd: The command to be sent 136 136 * 137 137 * Emulate BootRAM area. It is possible to do basic operation using BootRAM. 138 138 */ ··· 153 153 154 154 /** 155 155 * onenand_update_interrupt - Set interrupt register 156 - * @param this OneNAND device structure 157 - * @param cmd The command to be sent 156 + * @this: OneNAND device structure 157 + * @cmd: The command to be sent 158 158 * 159 - * Update interrupt register. The status is depends on command. 159 + * Update interrupt register. The status depends on command. 160 160 */ 161 161 static void onenand_update_interrupt(struct onenand_chip *this, int cmd) 162 162 { ··· 189 189 } 190 190 191 191 /** 192 - * onenand_check_overwrite - Check over-write if happend 193 - * @param dest The destination pointer 194 - * @param src The source pointer 195 - * @param count The length to be check 196 - * @return 0 on same, otherwise 1 192 + * onenand_check_overwrite - Check if over-write happened 193 + * @dest: The destination pointer 194 + * @src: The source pointer 195 + * @count: The length to be check 196 + * 197 + * Returns: 0 on same, otherwise 1 197 198 * 198 199 * Compare the source with destination 199 200 */ ··· 214 213 215 214 /** 216 215 * onenand_data_handle - Handle OneNAND Core and DataRAM 217 - * @param this OneNAND device structure 218 - * @param cmd The command to be sent 219 - * @param dataram Which dataram used 220 - * @param offset The offset to OneNAND Core 216 + * @this: OneNAND device structure 217 + * @cmd: The command to be sent 218 + * @dataram: Which dataram used 219 + * @offset: The offset to OneNAND Core 221 220 * 222 221 * Copy data from OneNAND Core to DataRAM (read) 223 222 * Copy data from DataRAM to OneNAND Core (write) ··· 296 295 297 296 /** 298 297 * onenand_command_handle - Handle command 299 - * @param this OneNAND device structure 300 - * @param cmd The command to be sent 298 + * @this: OneNAND device structure 299 + * @cmd: The command to be sent 301 300 * 302 301 * Emulate OneNAND command. 303 302 */ ··· 351 350 352 351 /** 353 352 * onenand_writew - [OneNAND Interface] Emulate write operation 354 - * @param value value to write 355 - * @param addr address to write 353 + * @value: value to write 354 + * @addr: address to write 356 355 * 357 356 * Write OneNAND register with value 358 357 */ ··· 374 373 375 374 /** 376 375 * flash_init - Initialize OneNAND simulator 377 - * @param flash OneNAND simulaotr data strucutres 376 + * @flash: OneNAND simulator data strucutres 378 377 * 379 378 * Initialize OneNAND simulator. 380 379 */ ··· 417 416 418 417 /** 419 418 * flash_exit - Clean up OneNAND simulator 420 - * @param flash OneNAND simulaotr data strucutres 419 + * @flash: OneNAND simulator data structures 421 420 * 422 421 * Clean up OneNAND simulator. 423 422 */ ··· 425 424 { 426 425 vfree(ONENAND_CORE(flash)); 427 426 kfree(flash->base); 428 - kfree(flash); 429 427 } 430 428 431 429 static int __init onenand_sim_init(void) ··· 449 449 info->onenand.write_word = onenand_writew; 450 450 451 451 if (flash_init(&info->flash)) { 452 - printk(KERN_ERR "Unable to allocat flash.\n"); 452 + printk(KERN_ERR "Unable to allocate flash.\n"); 453 453 kfree(ffchars); 454 454 kfree(info); 455 455 return -ENOMEM;
+65 -36
fs/jffs2/acl.c
··· 228 228 return acl; 229 229 } 230 230 231 + static int __jffs2_set_acl(struct inode *inode, int xprefix, struct posix_acl *acl) 232 + { 233 + char *value = NULL; 234 + size_t size = 0; 235 + int rc; 236 + 237 + if (acl) { 238 + value = jffs2_acl_to_medium(acl, &size); 239 + if (IS_ERR(value)) 240 + return PTR_ERR(value); 241 + } 242 + rc = do_jffs2_setxattr(inode, xprefix, "", value, size, 0); 243 + if (!value && rc == -ENODATA) 244 + rc = 0; 245 + kfree(value); 246 + 247 + return rc; 248 + } 249 + 231 250 static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl) 232 251 { 233 252 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 234 - size_t size = 0; 235 - char *value = NULL; 236 253 int rc, xprefix; 237 254 238 255 if (S_ISLNK(inode->i_mode)) ··· 284 267 default: 285 268 return -EINVAL; 286 269 } 287 - if (acl) { 288 - value = jffs2_acl_to_medium(acl, &size); 289 - if (IS_ERR(value)) 290 - return PTR_ERR(value); 291 - } 292 - 293 - rc = do_jffs2_setxattr(inode, xprefix, "", value, size, 0); 294 - if (!value && rc == -ENODATA) 295 - rc = 0; 296 - if (value) 297 - kfree(value); 270 + rc = __jffs2_set_acl(inode, xprefix, acl); 298 271 if (!rc) { 299 272 switch(type) { 300 273 case ACL_TYPE_ACCESS: ··· 319 312 return generic_permission(inode, mask, jffs2_check_acl); 320 313 } 321 314 322 - int jffs2_init_acl(struct inode *inode, struct posix_acl *acl) 315 + int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode) 323 316 { 324 317 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 325 - struct posix_acl *clone; 326 - mode_t mode; 327 - int rc = 0; 318 + struct posix_acl *acl, *clone; 319 + int rc; 328 320 329 - f->i_acl_access = JFFS2_ACL_NOT_CACHED; 330 - f->i_acl_default = JFFS2_ACL_NOT_CACHED; 321 + f->i_acl_default = NULL; 322 + f->i_acl_access = NULL; 331 323 332 - if (acl) { 333 - if (S_ISDIR(inode->i_mode)) { 334 - rc = jffs2_set_acl(inode, ACL_TYPE_DEFAULT, acl); 335 - if (rc) 336 - goto cleanup; 337 - } 324 + if (S_ISLNK(*i_mode)) 325 + return 0; /* Symlink always has no-ACL */ 326 + 327 + acl = jffs2_get_acl(dir_i, ACL_TYPE_DEFAULT); 328 + if (IS_ERR(acl)) 329 + return PTR_ERR(acl); 330 + 331 + if (!acl) { 332 + *i_mode &= ~current->fs->umask; 333 + } else { 334 + if (S_ISDIR(*i_mode)) 335 + jffs2_iset_acl(inode, &f->i_acl_default, acl); 336 + 338 337 clone = posix_acl_clone(acl, GFP_KERNEL); 339 - rc = -ENOMEM; 340 338 if (!clone) 341 - goto cleanup; 342 - mode = inode->i_mode; 343 - rc = posix_acl_create_masq(clone, &mode); 344 - if (rc >= 0) { 345 - inode->i_mode = mode; 346 - if (rc > 0) 347 - rc = jffs2_set_acl(inode, ACL_TYPE_ACCESS, clone); 348 - } 339 + return -ENOMEM; 340 + rc = posix_acl_create_masq(clone, (mode_t *)i_mode); 341 + if (rc < 0) 342 + return rc; 343 + if (rc > 0) 344 + jffs2_iset_acl(inode, &f->i_acl_access, clone); 345 + 349 346 posix_acl_release(clone); 350 347 } 351 - cleanup: 352 - posix_acl_release(acl); 348 + return 0; 349 + } 350 + 351 + int jffs2_init_acl_post(struct inode *inode) 352 + { 353 + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 354 + int rc; 355 + 356 + if (f->i_acl_default) { 357 + rc = __jffs2_set_acl(inode, JFFS2_XPREFIX_ACL_DEFAULT, f->i_acl_default); 358 + if (rc) 359 + return rc; 360 + } 361 + 362 + if (f->i_acl_access) { 363 + rc = __jffs2_set_acl(inode, JFFS2_XPREFIX_ACL_ACCESS, f->i_acl_access); 364 + if (rc) 365 + return rc; 366 + } 367 + 353 368 return rc; 354 369 } 355 370
+7 -5
fs/jffs2/acl.h
··· 31 31 extern struct posix_acl *jffs2_get_acl(struct inode *inode, int type); 32 32 extern int jffs2_permission(struct inode *, int, struct nameidata *); 33 33 extern int jffs2_acl_chmod(struct inode *); 34 - extern int jffs2_init_acl(struct inode *, struct posix_acl *); 34 + extern int jffs2_init_acl_pre(struct inode *, struct inode *, int *); 35 + extern int jffs2_init_acl_post(struct inode *); 35 36 extern void jffs2_clear_acl(struct jffs2_inode_info *); 36 37 37 38 extern struct xattr_handler jffs2_acl_access_xattr_handler; ··· 40 39 41 40 #else 42 41 43 - #define jffs2_get_acl(inode, type) (NULL) 44 - #define jffs2_permission NULL 45 - #define jffs2_acl_chmod(inode) (0) 46 - #define jffs2_init_acl(inode,dir) (0) 42 + #define jffs2_get_acl(inode, type) (NULL) 43 + #define jffs2_permission (NULL) 44 + #define jffs2_acl_chmod(inode) (0) 45 + #define jffs2_init_acl_pre(dir_i,inode,mode) (0) 46 + #define jffs2_init_acl_post(inode) (0) 47 47 #define jffs2_clear_acl(f) 48 48 49 49 #endif /* CONFIG_JFFS2_FS_POSIX_ACL */
+7 -28
fs/jffs2/dir.c
··· 182 182 struct jffs2_inode_info *f, *dir_f; 183 183 struct jffs2_sb_info *c; 184 184 struct inode *inode; 185 - struct posix_acl *acl; 186 185 int ret; 187 186 188 187 ri = jffs2_alloc_raw_inode(); ··· 192 193 193 194 D1(printk(KERN_DEBUG "jffs2_create()\n")); 194 195 195 - inode = jffs2_new_inode(dir_i, mode, ri, &acl); 196 + inode = jffs2_new_inode(dir_i, mode, ri); 196 197 197 198 if (IS_ERR(inode)) { 198 199 D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n")); ··· 210 211 211 212 ret = jffs2_do_create(c, dir_f, f, ri, 212 213 dentry->d_name.name, dentry->d_name.len); 213 - 214 - if (ret) 215 - goto fail_acl; 216 - 217 - ret = jffs2_init_security(inode, dir_i); 218 - if (ret) 219 - goto fail_acl; 220 - ret = jffs2_init_acl(inode, acl); 221 214 if (ret) 222 215 goto fail; 223 216 ··· 222 231 inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink, inode->i_mapping->nrpages)); 223 232 return 0; 224 233 225 - fail_acl: 226 - posix_acl_release(acl); 227 234 fail: 228 235 make_bad_inode(inode); 229 236 iput(inode); ··· 298 309 struct jffs2_full_dirent *fd; 299 310 int namelen; 300 311 uint32_t alloclen; 301 - struct posix_acl *acl; 302 312 int ret, targetlen = strlen(target); 303 313 304 314 /* FIXME: If you care. We'd need to use frags for the target ··· 324 336 return ret; 325 337 } 326 338 327 - inode = jffs2_new_inode(dir_i, S_IFLNK | S_IRWXUGO, ri, &acl); 339 + inode = jffs2_new_inode(dir_i, S_IFLNK | S_IRWXUGO, ri); 328 340 329 341 if (IS_ERR(inode)) { 330 342 jffs2_free_raw_inode(ri); ··· 354 366 up(&f->sem); 355 367 jffs2_complete_reservation(c); 356 368 jffs2_clear_inode(inode); 357 - posix_acl_release(acl); 358 369 return PTR_ERR(fn); 359 370 } 360 371 ··· 364 377 up(&f->sem); 365 378 jffs2_complete_reservation(c); 366 379 jffs2_clear_inode(inode); 367 - posix_acl_release(acl); 368 380 return -ENOMEM; 369 381 } 370 382 ··· 381 395 ret = jffs2_init_security(inode, dir_i); 382 396 if (ret) { 383 397 jffs2_clear_inode(inode); 384 - posix_acl_release(acl); 385 398 return ret; 386 399 } 387 - ret = jffs2_init_acl(inode, acl); 400 + ret = jffs2_init_acl_post(inode); 388 401 if (ret) { 389 402 jffs2_clear_inode(inode); 390 403 return ret; ··· 461 476 struct jffs2_full_dirent *fd; 462 477 int namelen; 463 478 uint32_t alloclen; 464 - struct posix_acl *acl; 465 479 int ret; 466 480 467 481 mode |= S_IFDIR; ··· 483 499 return ret; 484 500 } 485 501 486 - inode = jffs2_new_inode(dir_i, mode, ri, &acl); 502 + inode = jffs2_new_inode(dir_i, mode, ri); 487 503 488 504 if (IS_ERR(inode)) { 489 505 jffs2_free_raw_inode(ri); ··· 510 526 up(&f->sem); 511 527 jffs2_complete_reservation(c); 512 528 jffs2_clear_inode(inode); 513 - posix_acl_release(acl); 514 529 return PTR_ERR(fn); 515 530 } 516 531 /* No data here. Only a metadata node, which will be ··· 523 540 ret = jffs2_init_security(inode, dir_i); 524 541 if (ret) { 525 542 jffs2_clear_inode(inode); 526 - posix_acl_release(acl); 527 543 return ret; 528 544 } 529 - ret = jffs2_init_acl(inode, acl); 545 + ret = jffs2_init_acl_post(inode); 530 546 if (ret) { 531 547 jffs2_clear_inode(inode); 532 548 return ret; ··· 621 639 union jffs2_device_node dev; 622 640 int devlen = 0; 623 641 uint32_t alloclen; 624 - struct posix_acl *acl; 625 642 int ret; 626 643 627 644 if (!new_valid_dev(rdev)) ··· 647 666 return ret; 648 667 } 649 668 650 - inode = jffs2_new_inode(dir_i, mode, ri, &acl); 669 + inode = jffs2_new_inode(dir_i, mode, ri); 651 670 652 671 if (IS_ERR(inode)) { 653 672 jffs2_free_raw_inode(ri); ··· 676 695 up(&f->sem); 677 696 jffs2_complete_reservation(c); 678 697 jffs2_clear_inode(inode); 679 - posix_acl_release(acl); 680 698 return PTR_ERR(fn); 681 699 } 682 700 /* No data here. Only a metadata node, which will be ··· 689 709 ret = jffs2_init_security(inode, dir_i); 690 710 if (ret) { 691 711 jffs2_clear_inode(inode); 692 - posix_acl_release(acl); 693 712 return ret; 694 713 } 695 - ret = jffs2_init_acl(inode, acl); 714 + ret = jffs2_init_acl_post(inode); 696 715 if (ret) { 697 716 jffs2_clear_inode(inode); 698 717 return ret;
+4 -7
fs/jffs2/file.c
··· 255 255 _whole_ page. This helps to reduce the number of 256 256 nodes in files which have many short writes, like 257 257 syslog files. */ 258 - start = aligned_start = 0; 258 + aligned_start = 0; 259 259 } 260 260 261 261 ri = jffs2_alloc_raw_inode(); ··· 291 291 } 292 292 293 293 /* Adjust writtenlen for the padding we did, so we don't confuse our caller */ 294 - if (writtenlen < (start&3)) 295 - writtenlen = 0; 296 - else 297 - writtenlen -= (start&3); 294 + writtenlen -= min(writtenlen, (start - aligned_start)); 298 295 299 296 if (writtenlen) { 300 - if (inode->i_size < (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen) { 301 - inode->i_size = (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen; 297 + if (inode->i_size < pos + writtenlen) { 298 + inode->i_size = pos + writtenlen; 302 299 inode->i_blocks = (inode->i_size + 511) >> 9; 303 300 304 301 inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime));
+6 -15
fs/jffs2/fs.c
··· 402 402 403 403 /* jffs2_new_inode: allocate a new inode and inocache, add it to the hash, 404 404 fill in the raw_inode while you're at it. */ 405 - struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri, 406 - struct posix_acl **acl) 405 + struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri) 407 406 { 408 407 struct inode *inode; 409 408 struct super_block *sb = dir_i->i_sb; ··· 437 438 438 439 /* POSIX ACLs have to be processed now, at least partly. 439 440 The umask is only applied if there's no default ACL */ 440 - if (!S_ISLNK(mode)) { 441 - *acl = jffs2_get_acl(dir_i, ACL_TYPE_DEFAULT); 442 - if (IS_ERR(*acl)) { 443 - make_bad_inode(inode); 444 - iput(inode); 445 - inode = (void *)*acl; 446 - *acl = NULL; 447 - return inode; 448 - } 449 - if (!(*acl)) 450 - mode &= ~current->fs->umask; 451 - } else { 452 - *acl = NULL; 441 + ret = jffs2_init_acl_pre(dir_i, inode, &mode); 442 + if (ret) { 443 + make_bad_inode(inode); 444 + iput(inode); 445 + return ERR_PTR(ret); 453 446 } 454 447 ret = jffs2_do_new_inode (c, f, mode, ri); 455 448 if (ret) {
+1 -3
fs/jffs2/os-linux.h
··· 173 173 extern const struct inode_operations jffs2_symlink_inode_operations; 174 174 175 175 /* fs.c */ 176 - struct posix_acl; 177 - 178 176 int jffs2_setattr (struct dentry *, struct iattr *); 179 177 int jffs2_do_setattr (struct inode *, struct iattr *); 180 178 void jffs2_read_inode (struct inode *); 181 179 void jffs2_clear_inode (struct inode *); 182 180 void jffs2_dirty_inode(struct inode *inode); 183 181 struct inode *jffs2_new_inode (struct inode *dir_i, int mode, 184 - struct jffs2_raw_inode *ri, struct posix_acl **acl); 182 + struct jffs2_raw_inode *ri); 185 183 int jffs2_statfs (struct dentry *, struct kstatfs *); 186 184 void jffs2_write_super (struct super_block *); 187 185 int jffs2_remount_fs (struct super_block *, int *, char *);
+8
fs/jffs2/write.c
··· 465 465 466 466 up(&f->sem); 467 467 jffs2_complete_reservation(c); 468 + 469 + ret = jffs2_init_security(&f->vfs_inode, &dir_f->vfs_inode); 470 + if (ret) 471 + return ret; 472 + ret = jffs2_init_acl_post(&f->vfs_inode); 473 + if (ret) 474 + return ret; 475 + 468 476 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen, 469 477 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 470 478
+2 -3
lib/reed_solomon/decode_rs.c
··· 39 39 40 40 /* Check length parameter for validity */ 41 41 pad = nn - nroots - len; 42 - if (pad < 0 || pad >= nn) 43 - return -ERANGE; 42 + BUG_ON(pad < 0 || pad >= nn); 44 43 45 44 /* Does the caller provide the syndrome ? */ 46 45 if (s != NULL) ··· 202 203 * deg(lambda) unequal to number of roots => uncorrectable 203 204 * error detected 204 205 */ 205 - count = -1; 206 + count = -EBADMSG; 206 207 goto finish; 207 208 } 208 209 /*
+2
lib/reed_solomon/reed_solomon.c
··· 320 320 * The syndrome and parity uses a uint16_t data type to enable 321 321 * symbol size > 8. The calling code must take care of decoding of the 322 322 * syndrome result and the received parity before calling this code. 323 + * Returns the number of corrected bits or -EBADMSG for uncorrectable errors. 323 324 */ 324 325 int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len, 325 326 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, ··· 364 363 * @corr: buffer to store correction bitmask on eras_pos 365 364 * 366 365 * Each field in the data array contains up to symbol size bits of valid data. 366 + * Returns the number of corrected bits or -EBADMSG for uncorrectable errors. 367 367 */ 368 368 int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len, 369 369 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk,