From 77f5bb4dace53e0040dea4ce5c72156e901e6819 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Fri, 13 Nov 2020 10:01:06 +1100 Subject: [PATCH] LU-6142 lustre: convert IFTODT to S_DT In Linux v5.1-rc1~141^2~1 introduced include/linux/fs_types.h which adds macros for manipulating file types, including S_DT() which does what the userpsace IFTODT() macro does. So change kernel code to use S_DT() instead of IFTODT(), and provide definitions for kernels which don't yet have this file. fs_types.h is included by fs.h, so we don't need to explicitly include it anywhere. Signed-off-by: Mr NeilBrown Change-Id: If001f7e7a97992af690222b7524770c5e4b7003d Reviewed-on: https://review.whamcloud.com/40641 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- contrib/scripts/libcfs_cleanup.sed | 3 --- libcfs/include/libcfs/linux/linux-fs.h | 10 +++++----- lustre/llite/dir.c | 2 +- lustre/osd-zfs/osd_index.c | 8 ++++---- lustre/osd-zfs/osd_object.c | 2 +- lustre/osd-zfs/osd_oi.c | 2 +- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/contrib/scripts/libcfs_cleanup.sed b/contrib/scripts/libcfs_cleanup.sed index 0d605b8..fb6e160 100644 --- a/contrib/scripts/libcfs_cleanup.sed +++ b/contrib/scripts/libcfs_cleanup.sed @@ -254,9 +254,6 @@ s/\b[cfs_]*flock_set_start(\([^,]*\), \([^)]*\))\b/\1->fl_start = \2/g s/\b[cfs_]*flock_end(\([^)]*\))\b/\1->fl_end/g s/\b[cfs_]*flock_set_end(\([^,]*\), \([^)]*\))\b/\1->fl_end = \2/g s/\bcfs_user_write\b/user_write/g -s/\bCFS_IFSHIFT\b/IFSHIFT/g -s/\bCFS_IFTODT\b/IFTODT/g -s/\bCFS_DTTOIF\b/DTTOIF/g ################################################################################ # memory operations diff --git a/libcfs/include/libcfs/linux/linux-fs.h b/libcfs/include/libcfs/linux/linux-fs.h index 13c2e50..a5beff2 100644 --- a/libcfs/include/libcfs/linux/linux-fs.h +++ b/libcfs/include/libcfs/linux/linux-fs.h @@ -49,15 +49,15 @@ static inline struct dentry *file_dentry(const struct file *file) } #endif -#ifndef IFSHIFT -#define IFSHIFT 12 +#ifndef S_DT_SHIFT +#define S_DT_SHIFT 12 #endif -#ifndef IFTODT -#define IFTODT(type) (((type) & S_IFMT) >> IFSHIFT) +#ifndef S_DT +#define S_DT(type) (((type) & S_IFMT) >> S_DT_SHIFT) #endif #ifndef DTTOIF -#define DTTOIF(dirtype) ((dirtype) << IFSHIFT) +#define DTTOIF(dirtype) ((dirtype) << S_DT_SHIFT) #endif #endif diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 2d631d9..73444a7 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -233,7 +233,7 @@ int ll_dir_read(struct inode *inode, __u64 *ppos, struct md_op_data *op_data, lhash = hash; fid_le_to_cpu(&fid, &ent->lde_fid); ino = cl_fid_build_ino(&fid, is_api32); - type = IFTODT(lu_dirent_type_get(ent)); + type = S_DT(lu_dirent_type_get(ent)); /* For ll_nfs_get_name_filldir(), it will try to access * 'ent' through 'lde_name', so the parameter 'name' * for 'filldir()' must be part of the 'ent'. */ diff --git a/lustre/osd-zfs/osd_index.c b/lustre/osd-zfs/osd_index.c index 75cbec8..9116cba 100644 --- a/lustre/osd-zfs/osd_index.c +++ b/lustre/osd-zfs/osd_index.c @@ -815,7 +815,7 @@ int osd_add_to_remote_parent(const struct lu_env *env, osd_fid2str(name, fid, sizeof(info->oti_str)); zde->lzd_reg.zde_dnode = obj->oo_dn->dn_object; - zde->lzd_reg.zde_type = IFTODT(S_IFDIR); + zde->lzd_reg.zde_type = S_DT(S_IFDIR); zde->lzd_fid = *fid; rc = osd_zap_add(osd, osd->od_remote_parent_dir, NULL, @@ -1042,7 +1042,7 @@ static int osd_dir_insert(const struct lu_env *env, struct dt_object *dt, BUILD_BUG_ON(sizeof(*zde) % 8 != 0); memset(&zde->lzd_reg, 0, sizeof(zde->lzd_reg)); - zde->lzd_reg.zde_type = IFTODT(rec1->rec_type & S_IFMT); + zde->lzd_reg.zde_type = S_DT(rec1->rec_type & S_IFMT); zde->lzd_fid = *fid; if (idc->oic_remote) { @@ -1502,7 +1502,7 @@ static int osd_dir_it_rec(const struct lu_env *env, const struct dt_it *di, lu_object_fid(&it->ozi_obj->oo_dt.do_lu)); lde->lde_attrs = LUDA_FID; /* append lustre attributes */ - osd_it_append_attrs(lde, attr, 1, IFTODT(S_IFDIR)); + osd_it_append_attrs(lde, attr, 1, S_DT(S_IFDIR)); lde->lde_reclen = cpu_to_le16(lu_dirent_calc_size(1, attr)); it->ozi_pos = OZI_POS_DOT; RETURN(0); @@ -1521,7 +1521,7 @@ static int osd_dir_it_rec(const struct lu_env *env, const struct dt_it *di, } /* append lustre attributes */ - osd_it_append_attrs(lde, attr, 2, IFTODT(S_IFDIR)); + osd_it_append_attrs(lde, attr, 2, S_DT(S_IFDIR)); lde->lde_reclen = cpu_to_le16(lu_dirent_calc_size(2, attr)); RETURN(0); } diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c index 7df429e..9817cc5 100644 --- a/lustre/osd-zfs/osd_object.c +++ b/lustre/osd-zfs/osd_object.c @@ -1972,7 +1972,7 @@ static int osd_create(const struct lu_env *env, struct dt_object *dt, zde->zde_pad = 0; zde->zde_dnode = dn->dn_object; - zde->zde_type = IFTODT(attr->la_mode & S_IFMT); + zde->zde_type = S_DT(attr->la_mode & S_IFMT); zapid = osd_get_name_n_idx(env, osd, fid, buf, sizeof(info->oti_str), &zdn); diff --git a/lustre/osd-zfs/osd_oi.c b/lustre/osd-zfs/osd_oi.c index 5a21b3f..af618f0 100644 --- a/lustre/osd-zfs/osd_oi.c +++ b/lustre/osd-zfs/osd_oi.c @@ -211,7 +211,7 @@ static int osd_obj_create(const struct lu_env *env, struct osd_device *o, zde->zde_dnode = oid; zde->zde_pad = 0; - zde->zde_type = IFTODT(isdir ? S_IFDIR : S_IFREG); + zde->zde_type = S_DT(isdir ? S_IFDIR : S_IFREG); rc = -zap_add(o->od_os, parent, name, 8, 1, (void *)zde, tx); GOTO(commit, rc); -- 1.8.3.1