Merge git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-2.6-fixes

* git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-2.6-fixes:
GFS2: Use MAX_LFS_FILESIZE for meta inode size
GFS2: Fix gfs2_xattr_acl_chmod()
GFS2: Fix locking bug in rename
GFS2: Ensure uptodate inode size when using O_APPEND

+52 -15
+36 -2
fs/gfs2/file.c
··· 569 return ret; 570 } 571 572 #ifdef CONFIG_GFS2_FS_LOCKING_DLM 573 574 /** ··· 745 .read = do_sync_read, 746 .aio_read = generic_file_aio_read, 747 .write = do_sync_write, 748 - .aio_write = generic_file_aio_write, 749 .unlocked_ioctl = gfs2_ioctl, 750 .mmap = gfs2_mmap, 751 .open = gfs2_open, ··· 775 .read = do_sync_read, 776 .aio_read = generic_file_aio_read, 777 .write = do_sync_write, 778 - .aio_write = generic_file_aio_write, 779 .unlocked_ioctl = gfs2_ioctl, 780 .mmap = gfs2_mmap, 781 .open = gfs2_open,
··· 569 return ret; 570 } 571 572 + /** 573 + * gfs2_file_aio_write - Perform a write to a file 574 + * @iocb: The io context 575 + * @iov: The data to write 576 + * @nr_segs: Number of @iov segments 577 + * @pos: The file position 578 + * 579 + * We have to do a lock/unlock here to refresh the inode size for 580 + * O_APPEND writes, otherwise we can land up writing at the wrong 581 + * offset. There is still a race, but provided the app is using its 582 + * own file locking, this will make O_APPEND work as expected. 583 + * 584 + */ 585 + 586 + static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov, 587 + unsigned long nr_segs, loff_t pos) 588 + { 589 + struct file *file = iocb->ki_filp; 590 + 591 + if (file->f_flags & O_APPEND) { 592 + struct dentry *dentry = file->f_dentry; 593 + struct gfs2_inode *ip = GFS2_I(dentry->d_inode); 594 + struct gfs2_holder gh; 595 + int ret; 596 + 597 + ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh); 598 + if (ret) 599 + return ret; 600 + gfs2_glock_dq_uninit(&gh); 601 + } 602 + 603 + return generic_file_aio_write(iocb, iov, nr_segs, pos); 604 + } 605 + 606 #ifdef CONFIG_GFS2_FS_LOCKING_DLM 607 608 /** ··· 711 .read = do_sync_read, 712 .aio_read = generic_file_aio_read, 713 .write = do_sync_write, 714 + .aio_write = gfs2_file_aio_write, 715 .unlocked_ioctl = gfs2_ioctl, 716 .mmap = gfs2_mmap, 717 .open = gfs2_open, ··· 741 .read = do_sync_read, 742 .aio_read = generic_file_aio_read, 743 .write = do_sync_write, 744 + .aio_write = gfs2_file_aio_write, 745 .unlocked_ioctl = gfs2_ioctl, 746 .mmap = gfs2_mmap, 747 .open = gfs2_open,
+1 -1
fs/gfs2/meta_io.c
··· 121 if (aspace) { 122 mapping_set_gfp_mask(aspace->i_mapping, GFP_NOFS); 123 aspace->i_mapping->a_ops = &aspace_aops; 124 - aspace->i_size = ~0ULL; 125 ip = GFS2_I(aspace); 126 clear_bit(GIF_USER, &ip->i_flags); 127 insert_inode_hash(aspace);
··· 121 if (aspace) { 122 mapping_set_gfp_mask(aspace->i_mapping, GFP_NOFS); 123 aspace->i_mapping->a_ops = &aspace_aops; 124 + aspace->i_size = MAX_LFS_FILESIZE; 125 ip = GFS2_I(aspace); 126 clear_bit(GIF_USER, &ip->i_flags); 127 insert_inode_hash(aspace);
+4 -2
fs/gfs2/ops_inode.c
··· 748 struct gfs2_rgrpd *nrgd; 749 unsigned int num_gh; 750 int dir_rename = 0; 751 - int alloc_required; 752 unsigned int x; 753 int error; 754 ··· 867 goto out_gunlock; 868 } 869 870 - alloc_required = error = gfs2_diradd_alloc_required(ndir, &ndentry->d_name); 871 if (error < 0) 872 goto out_gunlock; 873 error = 0;
··· 748 struct gfs2_rgrpd *nrgd; 749 unsigned int num_gh; 750 int dir_rename = 0; 751 + int alloc_required = 0; 752 unsigned int x; 753 int error; 754 ··· 867 goto out_gunlock; 868 } 869 870 + if (nip == NULL) 871 + alloc_required = gfs2_diradd_alloc_required(ndir, &ndentry->d_name); 872 + error = alloc_required; 873 if (error < 0) 874 goto out_gunlock; 875 error = 0;
+11 -10
fs/gfs2/xattr.c
··· 1296 1297 int gfs2_xattr_acl_chmod(struct gfs2_inode *ip, struct iattr *attr, char *data) 1298 { 1299 struct gfs2_ea_location el; 1300 struct buffer_head *dibh; 1301 int error; ··· 1306 return error; 1307 1308 if (GFS2_EA_IS_STUFFED(el.el_ea)) { 1309 - error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + RES_EATTR, 0); 1310 - if (error) 1311 - return error; 1312 - 1313 - gfs2_trans_add_bh(ip->i_gl, el.el_bh, 1); 1314 - memcpy(GFS2_EA2DATA(el.el_ea), data, 1315 - GFS2_EA_DATA_LEN(el.el_ea)); 1316 - } else 1317 error = ea_acl_chmod_unstuffed(ip, el.el_ea, data); 1318 1319 if (error) 1320 return error; 1321 ··· 1329 brelse(dibh); 1330 } 1331 1332 - gfs2_trans_end(GFS2_SB(&ip->i_inode)); 1333 - 1334 return error; 1335 } 1336
··· 1296 1297 int gfs2_xattr_acl_chmod(struct gfs2_inode *ip, struct iattr *attr, char *data) 1298 { 1299 + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1300 struct gfs2_ea_location el; 1301 struct buffer_head *dibh; 1302 int error; ··· 1305 return error; 1306 1307 if (GFS2_EA_IS_STUFFED(el.el_ea)) { 1308 + error = gfs2_trans_begin(sdp, RES_DINODE + RES_EATTR, 0); 1309 + if (error == 0) { 1310 + gfs2_trans_add_bh(ip->i_gl, el.el_bh, 1); 1311 + memcpy(GFS2_EA2DATA(el.el_ea), data, 1312 + GFS2_EA_DATA_LEN(el.el_ea)); 1313 + } 1314 + } else { 1315 error = ea_acl_chmod_unstuffed(ip, el.el_ea, data); 1316 + } 1317 1318 + brelse(el.el_bh); 1319 if (error) 1320 return error; 1321 ··· 1327 brelse(dibh); 1328 } 1329 1330 + gfs2_trans_end(sdp); 1331 return error; 1332 } 1333