ocfs2 fixes
PATCH 1/1 ocfs2 fixes
Mostly fixes and two very small/obvious cleanups.
--Mark
Please pull from 'upstream-linus' branch ofgit://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/ocfs2.git upstream-linus
to receive the following updates:
fs/ocfs2/alloc.c | 4 -- fs/ocfs2/cluster/tcp.c | 24 +++++++++++------ fs/ocfs2/file.c | 28 +++++++++++++++++-- fs/ocfs2/namei.c | 16 ++++++++++- fs/ocfs2/ocfs2.h | 8 ++--- fs/ocfs2/super.c | 69 +++++++++++++++++++++++++++++-------------------- fs/ocfs2/super.h | 2 - 7 files changed, 101 insertions(+), 50 deletions(-)
Adrian Bunk (1):
[2.6 patch] ocfs2_insert_extent(): remove dead code
Mark Fasheh (6):
ocfs2: Restrict inode changes in ocfs2_update_inode_atime()
ocfs2: use s_maxbytes directly in ocfs2_change_file_space()
ocfs2: Fix some casting errors related to file writes
ocfs2: check ia_size limits in setattr
ocfs2: Fix max offset calculations
ocfs2: set non-default s_time_gran during mount
Sunil Mushran (2):
ocfs2: Fix rename/extend race
ocfs2: Retry sendpage() if it returns EAGAIN
fs/ocfs2/alloc.c +0 -4
@@ -3731,7 +3731,6 @@ int ocfs2_insert_extent(struct ocfs2_super *osb, {int status;struct buffer_head *last_eb_bh =NULL ; -struct buffer_head *bh =NULL ;struct ocfs2_insert_type insert = {0 , };struct ocfs2_extent_rec rec;
@@ -3783,9 +3782,6 @@ int ocfs2_insert_extent(struct ocfs2_super *osb,ocfs2_extent_map_insert_rec (inode, &rec); bail: -if (bh) -brelse (bh); -if (last_eb_bh)brelse (last_eb_bh);
fs/ocfs2/cluster/tcp.c +16 -8
@@ -854,17 +854,25 @@ static void o2net_sendpage(struct o2net_sock_container *sc,struct o2net_node *nn =o2net_nn_from_num (sc->sc_node->nd_num);ssize_t ret; - -mutex_lock (&sc->sc_send_lock); - ret = sc->sc_sock->ops->sendpage (sc->sc_sock, -virt_to_page (kmalloced_virt), - (long )kmalloced_virt & ~PAGE_MASK , - size,MSG_DONTWAIT ); -mutex_unlock (&sc->sc_send_lock); -if (ret != size) { +while (1 ) { +mutex_lock (&sc->sc_send_lock); + ret = sc->sc_sock->ops->sendpage (sc->sc_sock, +virt_to_page (kmalloced_virt), + (long )kmalloced_virt & ~PAGE_MASK , + size,MSG_DONTWAIT ); +mutex_unlock (&sc->sc_send_lock); +if (ret == size) +break ; +if (ret == (ssize_t )-EAGAIN ) { +mlog (0 ,"sendpage of size %zu to " SC_NODEF_FMT +" returned EAGAIN\n" , size,SC_NODEF_ARGS (sc)); +cond_resched (); +continue ; + }mlog (ML_ERROR ,"sendpage of size %zu to " SC_NODEF_FMT " failed with %zd\n" , size,SC_NODEF_ARGS (sc), ret);o2net_ensure_shutdown (nn, sc,0 ); +break ; } }
fs/ocfs2/file.c +25 -3
@@ -187,6 +187,7 @@ int ocfs2_update_inode_atime(struct inode *inode,int ret;struct ocfs2_super *osb =OCFS2_SB (inode->i_sb);handle_t *handle; +struct ocfs2_dinode *di = (struct ocfs2_dinode *) bh->b_data;mlog_entry_void ();
@@ -197,11 +198,27 @@ int ocfs2_update_inode_atime(struct inode *inode, goto out; } + ret =ocfs2_journal_access (handle, inode, bh, +OCFS2_JOURNAL_ACCESS_WRITE ); +if (ret) { +mlog_errno (ret); + goto out_commit; + } + +/* +* Don't use ocfs2_mark_inode_dirty() here as we don't always +* have i_mutex to guard against concurrent changes to other +* inode fields. +*/ inode->i_atime =CURRENT_TIME ; - ret =ocfs2_mark_inode_dirty (handle, inode, bh); + di->i_atime =cpu_to_le64 (inode->i_atime.tv_sec); + di->i_atime_nsec =cpu_to_le32 (inode->i_atime.tv_nsec); + + ret =ocfs2_journal_dirty (handle, bh);if (ret <0 )mlog_errno (ret); +out_commit:ocfs2_commit_trans (OCFS2_SB (inode->i_sb), handle); out:mlog_exit (ret);
@@ -1011,6 +1028,11 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) }if (size_change && attr->ia_size !=i_size_read (inode)) { +if (attr->ia_size > sb->s_maxbytes) { + status = -EFBIG ; + goto bail_unlock; + } +if (i_size_read (inode) > attr->ia_size) status =ocfs2_truncate_file (inode, bh, attr->ia_size);else
@@ -1516,7 +1538,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,struct ocfs2_super *osb =OCFS2_SB (inode->i_sb);struct buffer_head *di_bh =NULL ;handle_t *handle; -unsigned long long max_off =ocfs2_max_file_offset (inode->i_sb->s_blocksize_bits); +unsigned long long max_off = inode->i_sb->s_maxbytes;if (ocfs2_is_hard_readonly (osb) ||ocfs2_is_soft_readonly (osb))return -EROFS ;
@@ -1942,7 +1964,7 @@ static ssize_t ocfs2_file_buffered_write(struct file *file, loff_t *ppos, } dst =kmap_atomic (page,KM_USER0 ); -memcpy (dst + (pos & (PAGE_CACHE_SIZE -1 )), buf, bytes); +memcpy (dst + (pos & (loff_t)(PAGE_CACHE_SIZE -1 )), buf, bytes);kunmap_atomic (dst,KM_USER0 );flush_dcache_page (page);ocfs2_put_write_source (user_page);
fs/ocfs2/namei.c +15 -1
@@ -1080,6 +1080,7 @@ static int ocfs2_rename(struct inode *old_dir,struct buffer_head *old_inode_de_bh =NULL ;// if old_dentry is a dir, // this is the 1st dirent bh nlink_t old_dir_nlink = old_dir->i_nlink; +struct ocfs2_dinode *old_di;/* At some point it might be nice to break this function up a * bit. */
@@ -1354,7 +1355,20 @@ static int ocfs2_rename(struct inode *old_dir, old_inode->i_ctime =CURRENT_TIME ;mark_inode_dirty (old_inode); -ocfs2_mark_inode_dirty (handle, old_inode, old_inode_bh); + + status =ocfs2_journal_access (handle, old_inode, old_inode_bh, +OCFS2_JOURNAL_ACCESS_WRITE ); +if (status >=0 ) { + old_di = (struct ocfs2_dinode *) old_inode_bh->b_data; + + old_di->i_ctime =cpu_to_le64 (old_inode->i_ctime.tv_sec); + old_di->i_ctime_nsec =cpu_to_le32 (old_inode->i_ctime.tv_nsec); + + status =ocfs2_journal_dirty (handle, old_inode_bh); +if (status <0 ) +mlog_errno (status); + }else +mlog_errno (status);/* now that the name has been added to new_dir, remove the old name */ status =ocfs2_delete_entry (handle, old_dir, old_de, old_de_bh);
fs/ocfs2/ocfs2.h +4 -4
@@ -494,16 +494,16 @@ static inline unsigned int ocfs2_page_index_to_clusters(struct super_block *sb,/* * Find the 1st page index which covers the given clusters. */ -static inline unsigned long ocfs2_align_clusters_to_page_index (struct super_block *sb, +static inline pgoff_t ocfs2_align_clusters_to_page_index (struct super_block *sb,u32 clusters) {unsigned int cbits =OCFS2_SB (sb)->s_clustersize_bits; -unsigned long index = clusters; +pgoff_t index = clusters;if (PAGE_CACHE_SHIFT > cbits) { - index = clusters >> (PAGE_CACHE_SHIFT - cbits); + index = (pgoff_t )clusters >> (PAGE_CACHE_SHIFT - cbits); }else if (PAGE_CACHE_SHIFT < cbits) { - index = clusters << (cbits -PAGE_CACHE_SHIFT ); + index = (pgoff_t )clusters << (cbits -PAGE_CACHE_SHIFT ); }return index;
fs/ocfs2/super.c +41 -28
105 lines not on this page · raw message
fs/ocfs2/super.h +0 -2
@@ -45,6 +45,4 @@ void __ocfs2_abort(struct super_block *sb, #define ocfs2_abort(sb, fmt, args...) __ocfs2_abort(sb, __PRETTY_FUNCTION__, fmt, ##args) -unsigned long long ocfs2_max_file_offset (unsigned int blockshift); -#endif /* OCFS2_SUPER_H */