forked from mirrors/linux
		
	xfs: ensure that fpunch, fcollapse, and finsert operations are aligned to rt extent size
Make sure that any fallocate operation that requires the range to be block-aligned also checks that the range is aligned to the realtime extent size. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
		
							parent
							
								
									2a6ca4baed
								
							
						
					
					
						commit
						fe341eb151
					
				
					 1 changed files with 16 additions and 0 deletions
				
			
		| 
						 | 
					@ -946,6 +946,14 @@ xfs_free_file_space(
 | 
				
			||||||
	startoffset_fsb = XFS_B_TO_FSB(mp, offset);
 | 
						startoffset_fsb = XFS_B_TO_FSB(mp, offset);
 | 
				
			||||||
	endoffset_fsb = XFS_B_TO_FSBT(mp, offset + len);
 | 
						endoffset_fsb = XFS_B_TO_FSBT(mp, offset + len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* We can only free complete realtime extents. */
 | 
				
			||||||
 | 
						if (XFS_IS_REALTIME_INODE(ip)) {
 | 
				
			||||||
 | 
							xfs_extlen_t	extsz = xfs_get_extsz_hint(ip);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if ((startoffset_fsb | endoffset_fsb) & (extsz - 1))
 | 
				
			||||||
 | 
								return -EINVAL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Need to zero the stuff we're not freeing, on disk.
 | 
						 * Need to zero the stuff we're not freeing, on disk.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
| 
						 | 
					@ -1139,6 +1147,14 @@ xfs_insert_file_space(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	trace_xfs_insert_file_space(ip);
 | 
						trace_xfs_insert_file_space(ip);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* We can only insert complete realtime extents. */
 | 
				
			||||||
 | 
						if (XFS_IS_REALTIME_INODE(ip)) {
 | 
				
			||||||
 | 
							xfs_extlen_t	extsz = xfs_get_extsz_hint(ip);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if ((stop_fsb | shift_fsb) & (extsz - 1))
 | 
				
			||||||
 | 
								return -EINVAL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	error = xfs_bmap_can_insert_extents(ip, stop_fsb, shift_fsb);
 | 
						error = xfs_bmap_can_insert_extents(ip, stop_fsb, shift_fsb);
 | 
				
			||||||
	if (error)
 | 
						if (error)
 | 
				
			||||||
		return error;
 | 
							return error;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue