Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-18082

Support paths longer than PATH_MAX for fid2path

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • Lustre 2.16.0
    • Lustre 2.16.0
    • 3
    • 9223372036854775807

    Description

      PATH_MAX affects the path length of a single pathname, but it is possible to exceed this by eg. creating a subdirectory tree, then cd into it (or use as a subdirectory mountpoint), then create a deep tree below this using a relative pathname.

      So 'lfs fid2path' should not limit its output buffer to PATH_MAX.

      Attachments

        Issue Links

          Activity

            [LU-18082] Support paths longer than PATH_MAX for fid2path

            "Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/56369/
            Subject: LU-18082 tests: fix sanity test_154i for interop
            Project: fs/lustre-release
            Branch: master
            Current Patch Set:
            Commit: 24366d89d610490fd94a0c6bb6aa44ca16dc9639

            gerrit Gerrit Updater added a comment - "Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/56369/ Subject: LU-18082 tests: fix sanity test_154i for interop Project: fs/lustre-release Branch: master Current Patch Set: Commit: 24366d89d610490fd94a0c6bb6aa44ca16dc9639

            "Sebastien Buisson <sbuisson@ddn.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/56369
            Subject: LU-18082 tests: fix sanity test_154i for interop
            Project: fs/lustre-release
            Branch: master
            Current Patch Set: 1
            Commit: 05cfb3bec3ed3f79cfeb941abe0f344b9f490cfc

            gerrit Gerrit Updater added a comment - "Sebastien Buisson <sbuisson@ddn.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/56369 Subject: LU-18082 tests: fix sanity test_154i for interop Project: fs/lustre-release Branch: master Current Patch Set: 1 Commit: 05cfb3bec3ed3f79cfeb941abe0f344b9f490cfc
            pjones Peter Jones added a comment -

            Merged for 2.16

            pjones Peter Jones added a comment - Merged for 2.16

            "Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/55897/
            Subject: LU-18082 utils: fid2path support for path exceeding PATH_MAX
            Project: fs/lustre-release
            Branch: master
            Current Patch Set:
            Commit: f5251cb7af4cfae8f2e9e7f69251253c0bc233b6

            gerrit Gerrit Updater added a comment - "Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/55897/ Subject: LU-18082 utils: fid2path support for path exceeding PATH_MAX Project: fs/lustre-release Branch: master Current Patch Set: Commit: f5251cb7af4cfae8f2e9e7f69251253c0bc233b6
            adilger Andreas Dilger added a comment - - edited

            I think there are more things to be fixed beyond just the userspace allocation. There was a patch in LU-14179 that fixed handling of long pathnames in "lfs find" (to at least PATH_MAX x 2).

            I coincidentally also came across an old patch fragment that should be included in this patch, without which the fid2path code will spit console errors like:

            [Wed Jul 31 15:04:10 2024] LustreError: 9096:0:(mdt_handler.c:7684:mdt_fid2path()) fid [0x200000404:0x3:0x0], path verylongpathnameforadeepdeepersubdir3/verylongpathnameforadeepdeepersubdir4/verylongpathnameforadeepdeepersubdir5/verylongpathnameforadeepdeepersubdir6/verylongpathnameforadeepdeepersubdir7/verylongpathnameforadeepdeepersubdir8/verylongpathnameforadeepdeepersubdir9/verylongpathnameforadeepdeepersubdir10/verylongpathnameforadeepdeepersubdir11/verylongpathnameforadeepdeepersubdir12/verylongpathnameforadeepdeepersubdir13/verylongpathnameforadeepdeepersubdir14/verylongpathnameforadeepdeepersubdir15/verylongpathnameforadeepdeepersubdir16/verylongpathnameforadeepdeepersubdir17/verylongpathnameforadeepdeepersubdir18/verylongpathnameforadeepdeepersubdir19/verylongpathnameforadeepdeepersubdir20/verylongpathnameforadeepdeepersubdir21/verylongpathnameforadeepdeepersubdir22/verylongpathnameforadeepdeepersubdir23/verylongpathnameforadeepdeepersubdir24/verylongpathnameforadeepdeepersubdir25/verylongpat
            [Wed Jul 31 15:04:10 2024] LustreError: cowardly refusing to write 5308 bytes in a page
            
            diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c
            index a8ee803473..f7af8e9e6e 100644
            --- a/lustre/lmv/lmv_obd.c
            +++ b/lustre/lmv/lmv_obd.c
            @@ -601,10 +601,10 @@ repeat_fid2path:
                            ptr[len] = '/';
                    }
             
            -       CDEBUG(D_INFO, "%s: get path %s "DFID" rec: %llu ln: %u\n",
            +       CDEBUG(D_INFO, "%s: get path %.*s "DFID" rec: %llu ln: %u\n",
                           tgt->ltd_exp->exp_obd->obd_name,
            -              gf->gf_u.gf_path, PFID(&gf->gf_fid), gf->gf_recno,
            -              gf->gf_linkno);
            +              min(3072u, gf->gf_pathlen), gf->gf_u.gf_path, PFID(&gf->gf_fid),
            +              gf->gf_recno, gf->gf_linkno);
             
                    if (rc == 0)
                            GOTO(out_fid2path, rc);
            diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c
            index 65c956b819..3ca22e4509 100644
            --- a/lustre/mdt/mdt_handler.c
            +++ b/lustre/mdt/mdt_handler.c
            @@ -6933,8 +6933,8 @@ static int mdt_fid2path(struct mdt_thread_info *info,
             
                    rc = mdt_path(info, obj, fp, root_fid);
             
            -       CDEBUG(D_INFO, "fid "DFID", path %s recno %#llx linkno %u\n",
            -              PFID(&fp->gf_fid), fp->gf_u.gf_path,
            +       CDEBUG(D_INFO, "fid "DFID", path %.*s recno %#llx linkno %u\n",
            +              PFID(&fp->gf_fid), min(3072u, fp->gf_pathlen), fp->gf_u.gf_path,
                           fp->gf_recno, fp->gf_linkno);
             
                    mdt_object_put(info->mti_env, obj);
            

            This has the effect of logging the first 3072 characters of the pathname, rather than the last 3072 characters. In this case (fid2path on multiple links) it might be better to log the last 3072 characters, like:

            +       excess = fp->gf_pathlen > 3072 ? fp->gf_pathlen - 3072 : 0;
            +       CDEBUG(D_INFO, "fid "DFID", path %.*s recno %#llx linkno %u\n",
            +              PFID(&fp->gf_fid), fp->gf_pathlen - excess, fp->gf_u.gf_path + excess,
                           fp->gf_recno, fp->gf_linkno);
            
            adilger Andreas Dilger added a comment - - edited I think there are more things to be fixed beyond just the userspace allocation. There was a patch in LU-14179 that fixed handling of long pathnames in "lfs find" (to at least PATH_MAX x 2 ). I coincidentally also came across an old patch fragment that should be included in this patch, without which the fid2path code will spit console errors like: [Wed Jul 31 15:04:10 2024] LustreError: 9096:0:(mdt_handler.c:7684:mdt_fid2path()) fid [0x200000404:0x3:0x0], path verylongpathnameforadeepdeepersubdir3/verylongpathnameforadeepdeepersubdir4/verylongpathnameforadeepdeepersubdir5/verylongpathnameforadeepdeepersubdir6/verylongpathnameforadeepdeepersubdir7/verylongpathnameforadeepdeepersubdir8/verylongpathnameforadeepdeepersubdir9/verylongpathnameforadeepdeepersubdir10/verylongpathnameforadeepdeepersubdir11/verylongpathnameforadeepdeepersubdir12/verylongpathnameforadeepdeepersubdir13/verylongpathnameforadeepdeepersubdir14/verylongpathnameforadeepdeepersubdir15/verylongpathnameforadeepdeepersubdir16/verylongpathnameforadeepdeepersubdir17/verylongpathnameforadeepdeepersubdir18/verylongpathnameforadeepdeepersubdir19/verylongpathnameforadeepdeepersubdir20/verylongpathnameforadeepdeepersubdir21/verylongpathnameforadeepdeepersubdir22/verylongpathnameforadeepdeepersubdir23/verylongpathnameforadeepdeepersubdir24/verylongpathnameforadeepdeepersubdir25/verylongpat [Wed Jul 31 15:04:10 2024] LustreError: cowardly refusing to write 5308 bytes in a page diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index a8ee803473..f7af8e9e6e 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -601,10 +601,10 @@ repeat_fid2path: ptr[len] = '/' ; } - CDEBUG(D_INFO, "%s: get path %s " DFID " rec: %llu ln: %u\n" , + CDEBUG(D_INFO, "%s: get path %.*s " DFID " rec: %llu ln: %u\n" , tgt->ltd_exp->exp_obd->obd_name, - gf->gf_u.gf_path, PFID(&gf->gf_fid), gf->gf_recno, - gf->gf_linkno); + min(3072u, gf->gf_pathlen), gf->gf_u.gf_path, PFID(&gf->gf_fid), + gf->gf_recno, gf->gf_linkno); if (rc == 0) GOTO(out_fid2path, rc); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 65c956b819..3ca22e4509 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -6933,8 +6933,8 @@ static int mdt_fid2path(struct mdt_thread_info *info, rc = mdt_path(info, obj, fp, root_fid); - CDEBUG(D_INFO, "fid " DFID ", path %s recno %#llx linkno %u\n" , - PFID(&fp->gf_fid), fp->gf_u.gf_path, + CDEBUG(D_INFO, "fid " DFID ", path %.*s recno %#llx linkno %u\n" , + PFID(&fp->gf_fid), min(3072u, fp->gf_pathlen), fp->gf_u.gf_path, fp->gf_recno, fp->gf_linkno); mdt_object_put(info->mti_env, obj); This has the effect of logging the first 3072 characters of the pathname, rather than the last 3072 characters. In this case (fid2path on multiple links) it might be better to log the last 3072 characters, like: + excess = fp->gf_pathlen > 3072 ? fp->gf_pathlen - 3072 : 0; + CDEBUG(D_INFO, "fid " DFID ", path %.*s recno %#llx linkno %u\n" , + PFID(&fp->gf_fid), fp->gf_pathlen - excess, fp->gf_u.gf_path + excess, fp->gf_recno, fp->gf_linkno);

            "Sebastien Buisson <sbuisson@ddn.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/55897
            Subject: LU-18082 utils: fid2path support for path exceeding PATH_MAX
            Project: fs/lustre-release
            Branch: master
            Current Patch Set: 1
            Commit: 3e3d878791b66bf9c9844238beb8df269bc9332c

            gerrit Gerrit Updater added a comment - "Sebastien Buisson <sbuisson@ddn.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/55897 Subject: LU-18082 utils: fid2path support for path exceeding PATH_MAX Project: fs/lustre-release Branch: master Current Patch Set: 1 Commit: 3e3d878791b66bf9c9844238beb8df269bc9332c

            People

              sebastien Sebastien Buisson
              sebastien Sebastien Buisson
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: