xfs_file.c (00acb28d96746f78389f23a7b5309a917b45c12f) | xfs_file.c (ee20808d848c87a51e176706d81b95a21747d6cf) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (c) 2000-2005 Silicon Graphics, Inc. 4 * All Rights Reserved. 5 */ 6#include "xfs.h" 7#include "xfs_fs.h" 8#include "xfs_shared.h" --- 25 unchanged lines hidden (view full) --- 34#include <linux/mount.h> 35 36static const struct vm_operations_struct xfs_file_vm_ops; 37 38/* 39 * Decide if the given file range is aligned to the size of the fundamental 40 * allocation unit for the file. 41 */ | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (c) 2000-2005 Silicon Graphics, Inc. 4 * All Rights Reserved. 5 */ 6#include "xfs.h" 7#include "xfs_fs.h" 8#include "xfs_shared.h" --- 25 unchanged lines hidden (view full) --- 34#include <linux/mount.h> 35 36static const struct vm_operations_struct xfs_file_vm_ops; 37 38/* 39 * Decide if the given file range is aligned to the size of the fundamental 40 * allocation unit for the file. 41 */ |
42static bool | 42bool |
43xfs_is_falloc_aligned( 44 struct xfs_inode *ip, 45 loff_t pos, 46 long long int len) 47{ | 43xfs_is_falloc_aligned( 44 struct xfs_inode *ip, 45 loff_t pos, 46 long long int len) 47{ |
48 struct xfs_mount *mp = ip->i_mount; 49 uint64_t mask; | 48 unsigned int alloc_unit = xfs_inode_alloc_unitsize(ip); |
50 | 49 |
51 if (XFS_IS_REALTIME_INODE(ip)) { 52 if (!is_power_of_2(mp->m_sb.sb_rextsize)) { 53 u64 rextbytes; 54 u32 mod; | 50 if (!is_power_of_2(alloc_unit)) { 51 u32 mod; |
55 | 52 |
56 rextbytes = XFS_FSB_TO_B(mp, mp->m_sb.sb_rextsize); 57 div_u64_rem(pos, rextbytes, &mod); 58 if (mod) 59 return false; 60 div_u64_rem(len, rextbytes, &mod); 61 return mod == 0; 62 } 63 mask = XFS_FSB_TO_B(mp, mp->m_sb.sb_rextsize) - 1; 64 } else { 65 mask = mp->m_sb.sb_blocksize - 1; | 53 div_u64_rem(pos, alloc_unit, &mod); 54 if (mod) 55 return false; 56 div_u64_rem(len, alloc_unit, &mod); 57 return mod == 0; |
66 } 67 | 58 } 59 |
68 return !((pos | len) & mask); | 60 return !((pos | len) & (alloc_unit - 1)); |
69} 70 71/* 72 * Fsync operations on directories are much simpler than on regular files, 73 * as there is no file data to flush, and thus also no need for explicit 74 * cache flush operations, and there are no non-transaction metadata updates 75 * on directories either. 76 */ --- 1377 unchanged lines hidden --- | 61} 62 63/* 64 * Fsync operations on directories are much simpler than on regular files, 65 * as there is no file data to flush, and thus also no need for explicit 66 * cache flush operations, and there are no non-transaction metadata updates 67 * on directories either. 68 */ --- 1377 unchanged lines hidden --- |