| @@ -376,12 +376,11 @@ static void munge_mode_uid_gid(const struct gfs2_inode *dip, · 375 unmodified lines |
| 376 | 376 | inode->i_gid = current_fsgid(); |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | | −static int alloc_dinode(struct gfs2_inode *ip, u32 flags) |
| 379 | +static int alloc_dinode(struct gfs2_inode *ip, u32 flags, unsigned *dblocks) |
| 380 | 380 | { |
| 381 | 381 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 382 | | − struct gfs2_alloc_parms ap = { .target = RES_DINODE, .aflags = flags, }; |
| 382 | + struct gfs2_alloc_parms ap = { .target = *dblocks, .aflags = flags, }; |
| 383 | 383 | int error; |
| 384 | | − int dblocks = 1; |
| 385 | 384 | |
| 386 | 385 | error = gfs2_quota_lock_check(ip); |
| 387 | 386 | if (error) |
| @@ -391,11 +390,11 @@ static int alloc_dinode(struct gfs2_inode *ip, u32 flags) · 3 unmodified lines |
| 391 | 390 | if (error) |
| 392 | 391 | goto out_quota; |
| 393 | 392 | |
| 394 | | − error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA, 0); |
| 393 | + error = gfs2_trans_begin(sdp, (*dblocks * RES_RG_BIT) + RES_STATFS + RES_QUOTA, 0); |
| 395 | 394 | if (error) |
| 396 | 395 | goto out_ipreserv; |
| 397 | 396 | |
| 398 | | − error = gfs2_alloc_blocks(ip, &ip->i_no_addr, &dblocks, 1, &ip->i_generation); |
| 397 | + error = gfs2_alloc_blocks(ip, &ip->i_no_addr, dblocks, 1, &ip->i_generation); |
| 399 | 398 | ip->i_no_formal_ino = ip->i_generation; |
| 400 | 399 | ip->i_inode.i_ino = ip->i_no_addr; |
| 401 | 400 | ip->i_goal = ip->i_no_addr; |
| @@ -427,6 +426,33 @@ static void gfs2_init_dir(struct buffer_head *dibh, · 25 unmodified lines |
| 427 | 426 | |
| 428 | 427 | } |
| 429 | 428 | |
| 429 | +/** |
| 430 | + * gfs2_init_xattr - Initialise an xattr block for a new inode |
| 431 | + * @ip: The inode in question |
| 432 | + * |
| 433 | + * This sets up an empty xattr block for a new inode, ready to |
| 434 | + * take any ACLs, LSM xattrs, etc. |
| 435 | + */ |
| 436 | + |
| 437 | +static void gfs2_init_xattr(struct gfs2_inode *ip) |
| 438 | +{ |
| 439 | + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 440 | + struct buffer_head *bh; |
| 441 | + struct gfs2_ea_header *ea; |
| 442 | + |
| 443 | + bh = gfs2_meta_new(ip->i_gl, ip->i_eattr); |
| 444 | + gfs2_trans_add_meta(ip->i_gl, bh); |
| 445 | + gfs2_metatype_set(bh, GFS2_METATYPE_EA, GFS2_FORMAT_EA); |
| 446 | + gfs2_buffer_clear_tail(bh, sizeof(struct gfs2_meta_header)); |
| 447 | + |
| 448 | + ea = GFS2_EA_BH2FIRST(bh); |
| 449 | + ea->ea_rec_len = cpu_to_be32(sdp->sd_jbsize); |
| 450 | + ea->ea_type = GFS2_EATYPE_UNUSED; |
| 451 | + ea->ea_flags = GFS2_EAFLAG_LAST; |
| 452 | + |
| 453 | + brelse(bh); |
| 454 | +} |
| 455 | + |
| 430 | 456 | /** |
| 431 | 457 | * init_dinode - Fill in a new dinode structure |
| 432 | 458 | * @dip: The directory this inode is being created in |
| @@ -580,6 +606,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, · 147 unmodified lines |
| 580 | 606 | struct dentry *d; |
| 581 | 607 | int error; |
| 582 | 608 | u32 aflags = 0; |
| 609 | + unsigned blocks = 1; |
| 583 | 610 | struct gfs2_diradd da = { .bh = NULL, }; |
| 584 | 611 | |
| 585 | 612 | if (!name->len || name->len > GFS2_FNAMESIZE) |
| @@ -676,10 +703,15 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, · 90 unmodified lines |
| 676 | 703 | (dip->i_diskflags & GFS2_DIF_TOPDIR)) |
| 677 | 704 | aflags |= GFS2_AF_ORLOV; |
| 678 | 705 | |
| 679 | | − error = alloc_dinode(ip, aflags); |
| 706 | + if (default_acl || acl) |
| 707 | + blocks++; |
| 708 | + |
| 709 | + error = alloc_dinode(ip, aflags, &blocks); |
| 680 | 710 | if (error) |
| 681 | 711 | goto fail_free_inode; |
| 682 | 712 | |
| 713 | + gfs2_set_inode_blocks(inode, blocks); |
| 714 | + |
| 683 | 715 | error = gfs2_glock_get(sdp, ip->i_no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl); |
| 684 | 716 | if (error) |
| 685 | 717 | goto fail_free_inode; |
| @@ -689,10 +721,14 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, · 3 unmodified lines |
| 689 | 721 | if (error) |
| 690 | 722 | goto fail_free_inode; |
| 691 | 723 | |
| 692 | | − error = gfs2_trans_begin(sdp, RES_DINODE, 0); |
| 724 | + error = gfs2_trans_begin(sdp, blocks, 0); |
| 693 | 725 | if (error) |
| 694 | 726 | goto fail_gunlock2; |
| 695 | 727 | |
| 728 | + if (blocks > 1) { |
| 729 | + ip->i_eattr = ip->i_no_addr + 1; |
| 730 | + gfs2_init_xattr(ip); |
| 731 | + } |
| 696 | 732 | init_dinode(dip, ip, symname); |
| 697 | 733 | gfs2_trans_end(sdp); |
| 698 | 734 | |