Changeset 497


Ignore:
Timestamp:
Dec 13, 2010, 4:05:51 PM (15 years ago)
Author:
Silvan Scherrer
Message:

samba client: caching

Location:
branches/client-2.0/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/client-2.0/src/Makefile.kmk

    r442 r497  
    3232        printf.c \
    3333        util.c \
     34        dircache.c \
    3435        smbwrp.c
    3536
  • branches/client-2.0/src/debug.c

    r439 r497  
    5151        struct stat filestat;
    5252
     53        // do we have to log at all
     54        if (!debuglvl(level))
     55        {
     56                return;
     57        }
     58
    5359        // if the file ndpsmb.dbg is around we write a logfile
    5460        if (!debugfile[0])
     
    8086        } /* endif */
    8187
    82         if (!debuglvl(level))
    83         {
    84                 return;
    85         }
    8688        do
    8789        {
  • branches/client-2.0/src/help/ndpsmb.ipf

    r493 r497  
    138138:li.:link reftype=hd res=001.Version 1.0:elink.
    139139:li.:link reftype=hd res=002.Version 1.5.0:elink.
     140:li.:link reftype=hd res=003.Version 2.0.0:elink.
    140141:eul
    141142:h2 res=001.Version 1.0
     
    258259:eul.
    259260:eul.
     261:h2 res=003.Version 2.0.0   
     262:ul.
     263:li.beta1
     264:ul.
     265:li.added dir caching
     266:eul.
     267:eul.
    260268.******************************************************
    261269:h1.Credit
     
    267275:li.Alex Taylor (aka AlexT)
    268276:li.Nikolay Kolosov (aka nickk)
     277:li.Vitali Pelenyov (aka sunlover)
    269278:li.and all we missed
    270279:eul.
  • branches/client-2.0/src/help/ndpsmb_de.ipf

    r493 r497  
    141141:li.:link reftype=hd res=001.Version 1.0:elink.
    142142:li.:link reftype=hd res=002.Version 1.5.0:elink.
     143:li.:link reftype=hd res=003.Version 2.0.0:elink.
    143144:eul
    144145:h2 res=001.Version 1.0
     
    263264:eul.
    264265:eul.
     266:h2 res=003.Version 2.0.0   
     267:ul.
     268:li.beta1
     269:ul.
     270:li.Caching von Verzeichnissen
     271:eul.
     272:eul.
    265273.******************************************************
    266274:h1.Credit
     
    272280:li.Alex Taylor (aka AlexT)
    273281:li.Nikolay Kolosov (aka nickk)
     282:li.Vitali Pelenyov (aka sunlover)
    274283:li.und alle&comma. die wir vergessen haben!
    275284:eul.
  • branches/client-2.0/src/help/ndpsmb_fr.ipf

    r493 r497  
    206206:li.:link reftype=hd res=001.Version 1.0:elink.
    207207:li.:link reftype=hd res=002.Version 1.5.0:elink.
     208:li.:link reftype=hd res=003.Version 2.0.0:elink.
    208209:eul.
    209210:h2 res=001.Version 1.0
     
    348349:eul.
    349350:eul.
     351:h2 res=003.Version 2.0.0
     352:ul.
     353:li.beta1
     354:ul.
     355:li.added dir caching
     356:eul.
     357:eul.
    350358:p.
    351359.******************************************************
     
    360368:li.Alex Taylor (alias AlexT)
    361369:li.Nikolay Kolosov (alias nickk)
     370:li.Vitali Pelenyov (aka sunlover)
    362371:li.et tous ceux que nous avons pu oublier
    363372:eul.
  • branches/client-2.0/src/help/readme.txt

    r493 r497  
    254254   - Fix timestamp problem
    255255
     256v2.0.0 beta1
     257   - added dir caching
  • branches/client-2.0/src/help/readme_de.txt

    r493 r497  
    265265   - Zeitzonenproblem behoben
    266266
     267v2.0.0 beta1
     268   - Caching von Verzeichnissen
     269
  • branches/client-2.0/src/help/readme_fr.txt

    r493 r497  
    326326   - Fix timestamp problem
    327327
     328 v2.0.0 beta1
     329   - added dir caching
     330
    328331
    329332Traduction fran‡aise : Guillaume Gay <guillaume.gay@bigfoot.com>
  • branches/client-2.0/src/ndpsmb.c

    r493 r497  
    224224
    225225
    226 static PLUGINHELPERTABLE2L *ph;
     226PLUGINHELPERTABLE2L *ph;
    227227static int ifL;
    228228
     
    397397        pRes->krb5support = 0;
    398398#endif
     399        pRes->pdc = NULL;
    399400
    400401        t = 0, q = NULL;
     
    503504                }
    504505        }
     506
     507        /* Create a directory cache with expiration time 15 seconds and up to 32 listings cached. */
     508        dircache_create(&pRes->pdc, 10, 32);
    505509
    506510        return rc;
     
    727731{
    728732        Resource *pRes = (Resource *)resource;
     733        dircache_delete(pRes->pdc);
    729734        MemSet(&pRes->srv, 0, sizeof(pRes->srv));
    730735        free(pRes);
     
    963968
    964969                do {
     970                        /* First check if there is information in the directory cache. */
     971                        unsigned long ulAge = 0;
     972                        if (dircache_find_path(pRes->pdc, szPath, &finfo, &ulAge))
     973                        {
     974                                if (ulAge <= 15) /* @todo configurable. */
     975                                {
     976                                        rc = NO_ERROR;
     977                                        finfo.easize = -1;
     978                                        getfindinfoL(pConn, plist, &finfo, 0, NULL);
     979                                        break;
     980                                }
     981                        }
    965982
    966983                        rc = pathparser(pRes, pConn, szPath, path);
     
    10921109                strcpy( state.dir_mask, mask);
    10931110                strcpy( state.mask, path);
     1111                state.fullpath = szPath;
     1112                /* This plugin always reads a complete directory listing and filters results
     1113                 * using actual mask (state.dir_mask) in getfindinfoL.
     1114                 * May be this was a workaround for some server bug.
     1115                 * If this will be changed, then directory listing cache must be changed too,
     1116                 * and must remember the mask, which was used to obtain a listing.
     1117                 * Now the directory cache saves complete directory listings and then uses them to find
     1118                 * information about single files.
     1119                 * However, with a directory cache, it is probably faster to get a full listing and
     1120                 * then use it to obtain info about separate files than to perform a network
     1121                 * list query operation using actual wild cards for each file. Some application,
     1122                 * for example OpenOffice, do this.
     1123                 */
    10941124                p = getlastslash(state.mask);
    10951125                if (p)
     
    11021132                        strcpy(state.mask, "\\*");
    11031133                }
     1134                debuglocal(9,"NdpFindStart: dir [%s], dir_mask [%s], mask [%s], szPath [%s]\n",
     1135                           state.dir, state.dir_mask, state.mask, state.fullpath);
    11041136                rc = smbwrp_filelist( &pRes->srv, pConn->cli, &state);
    11051137                // we need to handle reconnection also here, because NdpQueryPathInfo
     
    14681500        debuglocal(9,"NdpForceDelete in\n");
    14691501
     1502        dircache_invalidate(szFile, pRes->pdc, 1);
     1503
    14701504        do {
    14711505                rc = pathparser(pRes, pConn, szFile, path);
     
    14921526        debuglocal(9,"NdpCreateDir in\n");
    14931527
     1528        dircache_invalidate(szDirName, pRes->pdc, 1);
     1529
    14941530        do {
    14951531                rc = pathparser(pRes, pConn, szDirName, path);
     
    15161552        debuglocal(9,"NdpDeleteDir in\n");
    15171553
     1554        dircache_invalidate(szDir, pRes->pdc, 1);
     1555
    15181556        do {
    15191557                rc = pathparser(pRes, pConn, szDir, path);
     
    15411579
    15421580        debuglocal(9,"NdpMove in from <%s> to <%s>\n", szSrc, szDst);
     1581
     1582        dircache_invalidate(szSrc, pRes->pdc, 1);
     1583        dircache_invalidate(szDst, pRes->pdc, 1);
    15431584
    15441585        do
     
    15951636        debuglocal(9,"smbopen in %d\n", pConn->file.fd);
    15961637
     1638        if (flags & O_CREAT)
     1639        {
     1640                dircache_invalidate(szFileName, pRes->pdc, 1);
     1641        }
    15971642        do {
    15981643                if (pConn->file.fd > 0)
  • branches/client-2.0/src/smbwrp.c

    r493 r497  
    10811081        finfo->ctime = def_finfo.ctime_ts.tv_sec;
    10821082        strncpy(finfo->fname, def_finfo.name, sizeof(finfo->fname) - 1);
    1083         debuglocal(9,"fname %s (serverzone %d, level %d)\n",finfo->fname, cli->serverzone, level);
    10841083       
    10851084        switch (level) {
     
    12401239                pstrcpy(mask,Mask);
    12411240
     1241        /* Try to get the listing from cache. */
     1242        if (dircache_list_files(fn, state, &total_received))
     1243        {
     1244                /* Got from cache. */
     1245                return(total_received);
     1246        }
     1247
    12421248        while (ff_eos == 0) {
    12431249                loop_count++;
     
    14251431                total_received = -1;
    14261432        } else {
     1433                void *dircachectx = dircache_write_begin(state, total_received);
     1434
    14271435                /* no connection problem.  let user function add each entry */
    14281436                for (p=dirlist,i=0;i<total_received;i++) {
     
    14301438                                                     &finfo,NULL,NULL,NULL);
    14311439                        fn( mnt,&finfo, Mask, state );
     1440
     1441                        /* Also add the entry to the cache. */
     1442                        dircache_write_entry(dircachectx, &finfo);
    14321443                }
     1444
     1445                dircache_write_end(dircachectx);
    14331446        }
    14341447
  • branches/client-2.0/src/smbwrp.h

    r151 r497  
    125125#endif
    126126
     127struct DirectoryCache;
     128
    127129typedef struct _Resource
    128130{
     
    133135        int easupport;
    134136        int krb5support;
     137        struct DirectoryCache *pdc;
    135138} Resource;
    136139
     
    157160        void *plist;
    158161        unsigned long ulAttribute;
     162        const char *fullpath;
    159163} filelist_state;
    160164
     
    186190int _System smbwrp_dskattr(cli_state * cli, FSALLOCATE *pfsa);
    187191
     192/* Directory cache helpers. */
     193int dircache_create(struct DirectoryCache **ppdc, unsigned long ulExpirationTime, int cMaxEntries);
     194void dircache_delete(struct DirectoryCache *pdc);
     195
     196typedef void FNADDDIRENTRY(const char*, smbwrp_fileinfo *, const char *, void *);
     197typedef FNADDDIRENTRY *PFNADDDIRENTRY;
     198
     199/* Note: dircache_list_files or dircache_write_begin construct the directory path
     200 *       using information in the filelist_state structure.
     201 */
     202int dircache_list_files(PFNADDDIRENTRY fn,
     203                        filelist_state *state,
     204                        int *ptotal_received);
     205
     206void *dircache_write_begin(filelist_state *state,
     207                           int cFiles);
     208void dircache_write_entry(void *dircachectx, const smbwrp_fileinfo *finfo);
     209void dircache_write_end(void *dircachectx);
     210
     211void dircache_invalidate(const char *path,
     212                         struct DirectoryCache *pdc,
     213                         int fParent);
     214
     215int dircache_find_path(struct DirectoryCache *pdc,
     216                       const char *path,
     217                       smbwrp_fileinfo *finfo,
     218                       unsigned long *pulAge);
     219
     220/* Prototype the debug log helper. */
     221void debuglocal(int level, const char * fmt, ...);
     222
    188223#endif /* _SMBWRP_H */
Note: See TracChangeset for help on using the changeset viewer.