aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/dir.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2014-01-06 06:28:41 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2014-01-06 06:28:41 -0500
commit3c1c0ae1db74b1f3e606f42158b5dadd89105c1f (patch)
treea3731a3e3ff2d6e76a3411e55a7de6749b3b129c /fs/gfs2/dir.c
parent70d4ee94b370c5ef54d0870600f16bd92d18013c (diff)
GFS2: Add directory addition info structure
The intent is that this structure will hold the information required when adding entries to a directory (linking). To start with, it will contain only the number of blocks which are required to link the new entry into the directory. The current calculation returns either 0 or the maximim number of blocks that can ever be requested by such a transaction. The intent is that in a later patch, we can update the dir code to calculate this value more accurately. In addition further patches will also add further fields to the new structure to increase its utility. In addition this patch fixes a bug where the link used during inode creation was adding requesting too many blocks in some cases. This is harmless unless the fs is close to being full. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/dir.c')
-rw-r--r--fs/gfs2/dir.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 2e5fc268d324..0b6be202a82c 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -2017,18 +2017,24 @@ out:
2017 * gfs2_diradd_alloc_required - find if adding entry will require an allocation 2017 * gfs2_diradd_alloc_required - find if adding entry will require an allocation
2018 * @ip: the file being written to 2018 * @ip: the file being written to
2019 * @filname: the filename that's going to be added 2019 * @filname: the filename that's going to be added
2020 * @da: The structure to return dir alloc info
2020 * 2021 *
2021 * Returns: 1 if alloc required, 0 if not, -ve on error 2022 * Returns: 0 if ok, -ve on error
2022 */ 2023 */
2023 2024
2024int gfs2_diradd_alloc_required(struct inode *inode, const struct qstr *name) 2025int gfs2_diradd_alloc_required(struct inode *inode, const struct qstr *name,
2026 struct gfs2_diradd *da)
2025{ 2027{
2028 struct gfs2_sbd *sdp = GFS2_SB(inode);
2026 struct gfs2_dirent *dent; 2029 struct gfs2_dirent *dent;
2027 struct buffer_head *bh; 2030 struct buffer_head *bh;
2028 2031
2032 da->nr_blocks = 0;
2033
2029 dent = gfs2_dirent_search(inode, name, gfs2_dirent_find_space, &bh); 2034 dent = gfs2_dirent_search(inode, name, gfs2_dirent_find_space, &bh);
2030 if (!dent) { 2035 if (!dent) {
2031 return 1; 2036 da->nr_blocks = sdp->sd_max_dirres;
2037 return 0;
2032 } 2038 }
2033 if (IS_ERR(dent)) 2039 if (IS_ERR(dent))
2034 return PTR_ERR(dent); 2040 return PTR_ERR(dent);