Changeset 499


Ignore:
Timestamp:
Dec 13, 2010, 5:10:38 PM (15 years ago)
Author:
Silvan Scherrer
Message:

samba client 2.1: caching

Location:
trunk/client/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/src/Makefile.kmk

    r472 r499  
    3232        printf.c \
    3333        util.c \
     34        dircache.c \
    3435        smbwrp.c
    3536
  • trunk/client/src/debug.c

    r448 r499  
    5353        struct stat filestat;
    5454
     55        // do we have to log at all
     56        if (!debuglvl(level))
     57        {
     58                return;
     59        }
     60
    5561        // if the file ndpsmb.dbg is around we write a logfile
    5662        if (!debugfile[0])
     
    8288        } /* endif */
    8389
    84         if (!debuglvl(level))
    85         {
    86                 return;
    87         }
    8890        do
    8991        {
  • trunk/client/src/help/ndpsmb.ipf

    r494 r499  
    138138:li.:link reftype=hd res=001.Version 1.0:elink.
    139139:li.:link reftype=hd res=002.Version 1.5:elink.
    140 :li.:link reftype=hd res=003.Version 1.6:elink.
     140:li.:link reftype=hd res=003.Version 2.0:elink.
     141:li.:link reftype=hd res=004.Version 2.1:elink.
    141142:eul
    142143:h2 res=001.Version 1.0
     
    211212:eul.
    212213:eul.
    213 :h2 res=002.Version 1.5 
     214:h2 res=002.Version 1.5   
    214215:ul.
    215216:li.alpha1
     
    254255:li.Fix help files
    255256:eul.
    256 :eul.
    257 :h2 res=003.Version 1.6
    258 :p.
    259 :ul.
    260 :li.alpha1
     257:li.1.5.3
     258:ul.
     259:li.Fix timestamp problem
     260:eul.
     261:eul.
     262:h2 res=003.Version 2.0   
     263:ul.
     264:li.2.0.0
     265:ul.
     266:li.added dir caching
     267:eul.
     268:eul.
     269:h2 res=004.Version 2.1   
     270:ul.
     271:li.2.1.0 alpha1
    261272:ul.
    262273:li.moved to samba 3.3 source base
    263 :eul.
    264 :li.beta1
    265 :ul.
    266 :li.first public build
    267 :li.fixed some traps from alpha1
    268 :eul.
    269 :li.beta2
    270 :ul.
    271 :li.fixed a timezone problem
    272 :eul.
    273 :eul.
    274 :p.
     274:li.new merge of 2.0 code and 1.6 code
     275:eul.
     276:eul.
    275277.******************************************************
    276278:h1.Credit
     
    282284:li.Alex Taylor (aka AlexT)
    283285:li.Nikolay Kolosov (aka nickk)
     286:li.Vitali Pelenyov (aka sunlover)
    284287:li.and all we missed
    285288:eul.
  • trunk/client/src/help/ndpsmb_de.ipf

    r494 r499  
    141141:li.:link reftype=hd res=001.Version 1.0:elink.
    142142:li.:link reftype=hd res=002.Version 1.5:elink.
    143 :li.:link reftype=hd res=003.Version 1.6:elink.
     143:li.:link reftype=hd res=003.Version 2.0:elink.
     144:li.:link reftype=hd res=004.Version 2.1:elink.
    144145:eul
    145146:h2 res=001.Version 1.0
     
    249250:p.
    250251(ACHTUNG! Kompatibilit&ae.tswarnung&colon. Die Token m&ue.ssen auch aus alten *.evp&comma. *.ndc und volumes.cfg Dateien entfernt werden&comma. anonsten scheitert die Wiederherstellung von Verbindungsprofilen)
    251 :li.Logging-Funktion fr Samba Meldungen hinzugef&ue.gt
     252:li.Logging-Funktion fr Samba Meldungen hinzugefgt
    252253:eul.
    253254:li.1.5.1
    254255:ul.
    255 :li.Fix f&ue.r den Crash auf Quadcore Maschinen
     256:li.Fix fr den Crash auf Quadcore Maschinen
    256257:eul.
    257258:li.1.5.2
     
    259260:li.Korrekturen in den Hilfedateien
    260261:eul.
    261 :eul.
    262 :h2 res=003.Version 1.6
    263 :p.
    264 :ul.
    265 :li.alpha1
    266 :ul.
     262:li.1.5.3
     263:ul.
     264:li.Zeitzonenproblem behoben
     265:eul.
     266:eul.
     267:h2 res=003.Version 2.0   
     268:ul.
     269:li.2.0.0
     270:ul.
     271:li.Caching von Verzeichnissen
     272:eul.
     273:eul.
     274:h2 res=004.Version 2.1   
     275:ul.
     276:li.2.1.0 alpha1
    267277:li.Update auf Samba 3.3 Client-Code
    268 :eul.
    269 :li.beta1
    270 :ul.
    271 :li.erster &oe.ffentlicher build
    272 :li.einige Abst&ue.rze von alpha1 repariert
    273 :eul.
    274 :li.beta2
    275 :ul.
    276 :li.ein Zeitzonenproblem behoben
    277 :eul.
    278 :eul.
    279 :p.
     278:li.neuer Merge von 1.6 code und 2.0 code
     279:eul.
     280:eul.
    280281.******************************************************
    281282:h1.Credit
     
    287288:li.Alex Taylor (aka AlexT)
    288289:li.Nikolay Kolosov (aka nickk)
     290:li.Vitali Pelenyov (aka sunlover)
    289291:li.und alle&comma. die wir vergessen haben!
    290292:eul.
  • trunk/client/src/help/ndpsmb_fr.ipf

    r494 r499  
    206206:li.:link reftype=hd res=001.Version 1.0:elink.
    207207:li.:link reftype=hd res=002.Version 1.5:elink.
    208 :li.:link reftype=hd res=003.Version 1.6:elink.
     208:li.:link reftype=hd res=003.Version 2.0:elink.
     209:li.:link reftype=hd res=004.Version 2.1:elink.
    209210:eul.
    210211:h2 res=001.Version 1.0
     
    344345:li.Corriger les fichier d'aide
    345346:eul.
    346 :eul.
    347 :h2 res=003.Version 1.6
    348 :p.
    349 :ul.
    350 :li.alpha1
    351 :ul.
    352 :li.Passage au code du client Samba 3.3
    353 :eul.
    354 :li.beta1
    355 :ul.
    356 :li.first public build
    357 :li.fixed some traps from alpha1
    358 :eul.
    359 :li.beta2
    360 :ul.
    361 :li.fixed a timezone problem
     347:li.1.5.3
     348:ul.
     349:li.Fix timestamp problem
     350:eul.
     351:eul.
     352:h2 res=003.Version 2.0
     353:ul.
     354:li.2.0.0
     355:ul.
     356:li.added dir caching
     357:eul.
     358:eul.
     359:h2 res=004.Version 2.1   
     360:ul.
     361:li.2.1.0 alpha1
     362:ul.
     363:li.moved to samba 3.3 source base
     364:li.new merge of 2.0 code and 1.6 code
    362365:eul.
    363366:eul.
     
    374377:li.Alex Taylor (alias AlexT)
    375378:li.Nikolay Kolosov (alias nickk)
     379:li.Vitali Pelenyov (aka sunlover)
    376380:li.et tous ceux que nous avons pu oublier
    377381:eul.
  • trunk/client/src/help/readme.txt

    r494 r499  
    245245   - added logging feature for samba messages
    246246   
    247  v1.5.1:
     247v1.5.1:
    248248   - Fix crashes on quadcore machines
    249249   
    250  v1.5.2:
     250v1.5.2:
    251251   - Fix help files
    252252
    253  v1.6.0 alpha1:
     253v1.5.3:
     254   - Fix timestamp problem
     255
     256v2.0.0 :
     257   - added dir caching
     258
     259v2.1.0 alpha1 :
    254260   - moved to samba 3.3 source base
    255 
    256  v1.6.0 beta1:
    257    - first public build
    258    - fixed some traps from alpha1
    259 
    260  v1.6.0 beta2:
    261    - fixed a timezone problem
     261   - new merge of 2.0 code and 1.6 code
     262
  • trunk/client/src/help/readme_de.txt

    r494 r499  
    256256   - Logging-Funktion fr Samba Meldungen hinzugefgt
    257257
    258  v1.5.1:
     258v1.5.1
    259259   - Behebung der Abstrze auf Quadcore Maschinen
    260260   
    261  v1.5.2:
     261v1.5.2
    262262   - Korrekturen an den Hilfedateien
    263263
    264  v1.6.0 alpha1:
     264v1.5.3
     265   - Zeitzonenproblem behoben
     266
     267v2.0.0
     268   - Caching von Verzeichnissen
     269
     270v2.1.0 alpha1:
    265271   - Update auf Samba 3.3 Client-Code
    266 
    267  v1.6.0 beta1:
    268    - erster ”ffentlicher build
    269    - einige Abstrze von alpha1 repariert
    270 
    271  v1.6.0 beta2:
    272    - ein Zeitzonenproblem behoben
     272   - neuer Merge von 1.6 code und 2.0 code
  • trunk/client/src/help/readme_fr.txt

    r494 r499  
    317317   - added logging feature for samba messages
    318318   
    319  v1.5.1:
     319 v1.5.1 :
    320320   - Fix crashes on quadcore machines
    321321   
    322  v1.5.2:
     322 v1.5.2 :
    323323   - Corriger les fichiers d'aide
    324324
    325  v1.6.0 alpha1:
     325 v1.5.3 :
     326   - Fix timestamp problem
     327
     328 v2.0.0 :
     329   - added dir caching
     330
     331 v2.1.0 alpha1 :
    326332   - Passage au code du client Samba 3.3
    327 
    328  v1.6.0 beta1:
    329    - first public build
    330    - fixed some traps from alpha1
    331 
    332  v1.6.0 beta2:
    333    - fixed a timezone problem
     333   - new merge of 2.0 code and 1.6 code
     334
    334335
    335336Traduction fran‡aise : Guillaume Gay <guillaume.gay@bigfoot.com>
  • trunk/client/src/ndpsmb.c

    r494 r499  
    223223
    224224
    225 static PLUGINHELPERTABLE2L *ph;
     225PLUGINHELPERTABLE2L *ph;
    226226static int ifL;
    227227
     
    396396        pRes->krb5support = 0;
    397397#endif
     398        pRes->pdc = NULL;
    398399
    399400        t = 0, q = NULL;
     
    500501                }
    501502        }
     503
     504        /* Create a directory cache with expiration time 15 seconds and up to 32 listings cached. */
     505        dircache_create(&pRes->pdc, 10, 32);
    502506
    503507        return rc;
     
    723727{
    724728        Resource *pRes = (Resource *)resource;
     729        dircache_delete(pRes->pdc);
    725730        MemSet(&pRes->srv, 0, sizeof(pRes->srv));
    726731        free(pRes);
     
    958963
    959964                do {
     965                        /* First check if there is information in the directory cache. */
     966                        unsigned long ulAge = 0;
     967                        if (dircache_find_path(pRes->pdc, szPath, &finfo, &ulAge))
     968                        {
     969                                if (ulAge <= 15) /* @todo configurable. */
     970                                {
     971                                        rc = NO_ERROR;
     972                                        finfo.easize = -1;
     973                                        getfindinfoL(pConn, plist, &finfo, 0, NULL);
     974                                        break;
     975                                }
     976                        }
    960977
    961978                        rc = pathparser(pRes, pConn, szPath, path);
     
    10871104                strcpy( state.dir_mask, mask);
    10881105                strcpy( state.mask, path);
     1106                state.fullpath = szPath;
     1107                /* This plugin always reads a complete directory listing and filters results
     1108                 * using actual mask (state.dir_mask) in getfindinfoL.
     1109                 * May be this was a workaround for some server bug.
     1110                 * If this will be changed, then directory listing cache must be changed too,
     1111                 * and must remember the mask, which was used to obtain a listing.
     1112                 * Now the directory cache saves complete directory listings and then uses them to find
     1113                 * information about single files.
     1114                 * However, with a directory cache, it is probably faster to get a full listing and
     1115                 * then use it to obtain info about separate files than to perform a network
     1116                 * list query operation using actual wild cards for each file. Some application,
     1117                 * for example OpenOffice, do this.
     1118                 */
    10891119                p = getlastslash(state.mask);
    10901120                if (p)
     
    10971127                        strcpy(state.mask, "\\*");
    10981128                }
     1129                debuglocal(9,"NdpFindStart: dir [%s], dir_mask [%s], mask [%s], szPath [%s]\n",
     1130                           state.dir, state.dir_mask, state.mask, state.fullpath);
    10991131                rc = smbwrp_filelist( &pRes->srv, pConn->cli, &state);
    11001132                // we need to handle reconnection also here, because NdpQueryPathInfo
     
    14631495        debuglocal(9,"NdpForceDelete in\n");
    14641496
     1497        dircache_invalidate(szFile, pRes->pdc, 1);
     1498
    14651499        do {
    14661500                rc = pathparser(pRes, pConn, szFile, path);
     
    14871521        debuglocal(9,"NdpCreateDir in\n");
    14881522
     1523        dircache_invalidate(szDirName, pRes->pdc, 1);
     1524
    14891525        do {
    14901526                rc = pathparser(pRes, pConn, szDirName, path);
     
    15111547        debuglocal(9,"NdpDeleteDir in\n");
    15121548
     1549        dircache_invalidate(szDir, pRes->pdc, 1);
     1550
    15131551        do {
    15141552                rc = pathparser(pRes, pConn, szDir, path);
     
    15361574
    15371575        debuglocal(9,"NdpMove in from <%s> to <%s>\n", szSrc, szDst);
     1576
     1577        dircache_invalidate(szSrc, pRes->pdc, 1);
     1578        dircache_invalidate(szDst, pRes->pdc, 1);
    15381579
    15391580        do
     
    15901631        debuglocal(9,"smbopen in %d\n", pConn->file.fd);
    15911632
     1633        if (flags & O_CREAT)
     1634        {
     1635                dircache_invalidate(szFileName, pRes->pdc, 1);
     1636        }
    15921637        do {
    15931638                if (pConn->file.fd > 0)
  • trunk/client/src/smbwrp.c

    r494 r499  
    11051105
    11061106        ZERO_STRUCTP(finfo);
    1107         debuglocal(9,"fname %s (serverzone %d, level %d)\n",finfo->fname, cli->serverzone, level);
    11081107       
    11091108        switch (level) {
     
    13031302                return -1;
    13041303        }
     1304
     1305        /* Try to get the listing from cache. */
     1306        if (dircache_list_files(fn, state, &total_received))
     1307        {
     1308                /* Got from cache. */
     1309                return(total_received);
     1310        }
    13051311
    13061312        while (ff_eos == 0) {
     
    15141520                total_received = -1;
    15151521        } else {
     1522                void *dircachectx = dircache_write_begin(state, total_received);
     1523
    15161524                /* no connection problem.  let user function add each entry */
    15171525                rdata_end = dirlist + dirlist_len;
     
    15251533                        }
    15261534                        fn( mnt,&finfo, Mask, state );
     1535
     1536                        /* Also add the entry to the cache. */
     1537                        dircache_write_entry(dircachectx, &finfo);
    15271538                }
     1539
     1540                dircache_write_end(dircachectx);
     1541
    15281542        }
    15291543
  • trunk/client/src/smbwrp.h

    r472 r499  
    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.