#include "mdt_internal.h"
+static const struct file_operations mdt_open_files_seq_fops = {
+ .owner = THIS_MODULE,
+ .open = lprocfs_mdt_open_files_seq_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release,
+};
+
int mdt_export_stats_init(struct obd_device *obd,
struct obd_export *exp,
void *localdata)
rc = lprocfs_nid_ldlm_stats_init(tmp);
if (rc)
GOTO(clean, rc);
- }
+
+ rc = lprocfs_seq_create(tmp->nid_proc, "open_files",
+ 0444, &mdt_open_files_seq_fops, tmp);
+ if (rc) {
+ CWARN("%s: error adding the open_files file: rc = %d\n",
+ obd->obd_name, rc);
+ GOTO(clean, rc);
+ }
+ }
RETURN(0);
clean:
return rc;
void lprocfs_mds_init_vars(struct lprocfs_static_vars *lvars);
int mdt_procfs_init(struct mdt_device *mdt, const char *name);
void mdt_procfs_fini(struct mdt_device *mdt);
+
+/* lustre/mdt_mdt_lproc.c */
+int lprocfs_mdt_open_files_seq_open(struct inode *inode,
+ struct file *file);
void mdt_rename_counter_tally(struct mdt_thread_info *info,
struct mdt_device *mdt,
struct ptlrpc_request *req,
{ 0 }
};
+int lprocfs_mdt_print_open_files(cfs_hash_t *hs, cfs_hash_bd_t *bd,
+ cfs_hlist_node_t *hnode, void *v)
+{
+ struct obd_export *exp = cfs_hash_object(hs, hnode);
+ struct seq_file *seq = v;
+
+ if (exp->exp_lock_hash != NULL) {
+ struct mdt_export_data *med = &exp->exp_mdt_data;
+ struct mdt_file_data *mfd;
+
+ spin_lock(&med->med_open_lock);
+ cfs_list_for_each_entry(mfd, &med->med_open_head, mfd_list) {
+ seq_printf(seq, DFID"\n",
+ PFID(mdt_object_fid(mfd->mfd_object)));
+ }
+ spin_unlock(&med->med_open_lock);
+ }
+
+ return 0;
+}
+
+int lprocfs_mdt_open_files_seq_show(struct seq_file *seq, void *v)
+{
+ struct nid_stat *stats = seq->private;
+ struct obd_device *obd = stats->nid_obd;
+
+ cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
+ lprocfs_mdt_print_open_files, seq);
+
+ return 0;
+}
+
+int lprocfs_mdt_open_files_seq_open(struct inode *inode, struct file *file)
+{
+ struct proc_dir_entry *dp = PDE(inode);
+ struct seq_file *seq;
+ struct nid_stat *tmp;
+ int rc;
+
+ if (LPROCFS_ENTRY_CHECK(dp))
+ return -ENOENT;
+
+ tmp = dp->data;
+ rc = single_open(file, &lprocfs_mdt_open_files_seq_show, NULL);
+ if (rc != 0)
+ return rc;
+
+ seq = file->private_data;
+ seq->private = tmp;
+
+ return 0;
+}
+
void mdt_counter_incr(struct ptlrpc_request *req, int opcode)
{
struct obd_export *exp = req->rq_export;
}
struct exp_uuid_cb_data {
- char *page;
- int count;
- int *eof;
- int *len;
+ char *page;
+ int count;
+ int *eof;
+ int *len;
};
static void
}
run_test 154c "lfs path2fid and fid2path multiple arguments"
+test_154d() {
+ [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
+ skip "Need MDS version at least 2.5.53" && return
+
+ if remote_mds; then
+ nid=$($LCTL list_nids | sed "s/\./\\\./g")
+ else
+ nid="0@lo"
+ fi
+ local proc_ofile="mdt.*.exports.'$nid'.open_files"
+ local fd
+ local cmd
+
+ rm -f $DIR/$tfile
+ touch $DIR/$tfile
+
+ fid=$($LFS path2fid $DIR/$tfile)
+ # Open the file
+ fd=$(free_fd)
+ cmd="exec $fd<$DIR/$tfile"
+ eval $cmd
+ fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
+ echo $fid_list | grep $fid
+ rc=$?
+
+ cmd="exec $fd>/dev/null"
+ eval $cmd
+ if [ $rc -ne 0 ]; then
+ error "FID $fid not found in open files list $fid_list"
+ fi
+}
+run_test 154d "Verify open file fid"
+
test_155_small_load() {
local temp=$TMP/$tfile
local file=$DIR/$tfile
}
run_test 75 "osc: upcall after unuse lock==================="
+test_76() { #LU-946
+ [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
+ skip "Need MDS version at least 2.5.53" && return
+
+ remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ local fcount=2048
+ local fd
+ local cmd
+ local mdt_idx
+ local mds_idx
+ declare -a fd_list
+ declare -a fid_list
+
+ if remote_mds; then
+ nid=$($LCTL list_nids | sed "s/\./\\\./g")
+ else
+ nid="0@lo"
+ fi
+
+ rm -rf $DIR/$tdir
+ test_mkdir -p $DIR/$tdir
+ if [ $MDSCOUNT -gt 1 ]; then
+ mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
+ else
+ mdt_idx=0
+ fi
+ mds_idx=$((mdt_idx + 1))
+ proc_ofile="mdt.*$mdt_idx.exports.'$nid'.open_files"
+
+ cancel_lru_locks mdc
+
+ echo -n "open files "
+ ulimit -n 8096
+ for (( i = 0; i < $fcount; i++ )) ; do
+ touch $DIR/$tdir/f_$i
+ fd=$(free_fd)
+ cmd="exec $fd<$DIR/$tdir/f_$i"
+ eval $cmd
+ fd_list[i]=$fd
+ echo -n "."
+ done
+ echo
+
+ fid_list=($(do_facet mds$mds_idx $LCTL get_param -n $proc_ofile))
+
+ # Possible errors in openfiles FID list.
+ # 1. Missing FIDs. Check 1
+ # 2. Extra FIDs. Check 1
+ # 3. Duplicated FID. Check 2
+ # 4. Invalid FIDs. Check 2
+ # 5. Valid FID, points to some other file. Check 3
+
+ # Check 1
+ [ ${#fid_list[@]} -ne $fcount ] &&
+ error "${#fid_list[@]} != $fcount open files"
+
+ for (( i = 0; i < $fcount; i++ )) ; do
+ cmd="exec ${fd_list[i]}</dev/null"
+ eval $cmd
+ filename=$($LFS fid2path $DIR2 ${fid_list[i]})
+
+ # Check 2
+ rm --interactive=no $filename
+ [ $? -ne 0 ] &&
+ error "Nonexisting fid ${fid_list[i]} listed."
+ done
+
+ # Check 3
+ ls_op=$(ls $DIR2/$tdir | wc -l)
+ [ $ls_op -ne 0 ] &&
+ error "Some openfiles are missing in lproc output"
+
+ rm -rf $DIR/$tdir
+}
+run_test 76 "Verify open file for 2048 files"
+
log "cleanup: ======================================================"
[ "$(mount | grep $MOUNT2)" ] && umount $MOUNT2