Whamcloud - gitweb
current branches now use lnet from HEAD
[fs/lustre-release.git] / lustre / smfs / doc / hld.lyx
1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 221
3 \textclass article
4 \begin_preamble
5 \usepackage{listings}
6 \usepackage{color}
7 \usepackage{courier}
8
9 %\usepackage{pt}
10 %\usepackage{units}
11 %\usepackage{coz}
12
13 %\usepackage{epsf}
14 %\usepackage{lncsexample}
15 %\conttrue
16 %\usepackage{times}
17 %\usepackage{top}
18 %\usepackage{graphicx}
19 \newcommand{\lst}[3] {
20         \noindent\rule[-0.3mm]{\textwidth}{0.3mm}\vspace{-0.3mm}
21         \lstinputlisting[caption={#2},
22         label={#1},
23         showstringspaces=false, 
24         numbers=left, 
25         stepnumber=1,
26         frame=bottomline,
27         language=C,
28         extendedchars=true,
29         basicstyle=\small\tt,
30         numberstyle=\tiny,
31         keywordstyle=\color{red},
32         commentstyle=\color{cyan},
33         stringstyle=\color{green},
34         directivestyle=\color{magenta},
35         emph={1, 2, 3, 4, 5, 6, 7, 8, 9, 0, NULL, lustre, CFS},
36         emphstyle=\color{blue},
37         breaklines=true,
38         #3]
39         {#1}\vspace{0.3mm}
40 }
41 \end_preamble
42 \language english
43 \inputencoding auto
44 \fontscheme times
45 \graphics default
46 \paperfontsize default
47 \spacing single 
48 \papersize Default
49 \paperpackage a4
50 \use_geometry 1
51 \use_amsmath 0
52 \use_natbib 0
53 \use_numerical_citations 0
54 \paperorientation portrait
55 \leftmargin 1in
56 \topmargin 0.5in
57 \rightmargin 0.5in
58 \bottommargin 0.5in
59 \secnumdepth 4
60 \tocdepth 4
61 \paragraph_separation skip
62 \defskip medskip
63 \quotes_language english
64 \quotes_times 2
65 \papercolumns 1
66 \papersides 1
67 \paperpagestyle default
68
69 \layout Title
70
71
72 \noun on 
73 Storage Management File System
74 \layout Date
75
76 14 February 2005
77 \layout Author
78
79 Peter Braam, Mike Pershin
80 \layout Standard
81
82
83 \begin_inset LatexCommand \tableofcontents{}
84
85 \end_inset 
86
87
88 \layout Section
89
90 Requirements
91 \layout Standard
92
93 In this document SMFS (Storage Management File System) is described.
94  It is required to do the following:
95 \layout Itemize
96
97 works as transparent pseudo-filesystem on the top of real filesystem
98 \layout Itemize
99
100 have access to Lustre's API like llog and btree 
101 \layout Itemize
102
103 be portable to other file systems than ext3
104 \layout Itemize
105
106 be able to call side-functions from other modules and plugins using own
107  API.
108 \layout Standard
109
110 All features can exist together and should not affect bottom filesystem
111  in any way.
112 \layout Section
113
114 Architectural overview
115 \layout Standard
116
117 In order to achieve requirements SMFS is expected to have the following
118  major functionality divisions:
119 \layout Description
120
121 Backstore\SpecialChar ~
122 FS - main module that is placed in Lustre stack on top of backing
123  FS.
124  It is pseudo filesystem that just pass all operations to real one and can
125  invoke side-functions for each filesystem operation.
126  There is plugin API that can be used by special modules (plugins) to register
127  list of functions for various filesystem operations.
128 \layout Description
129
130 Plugins - major reason for SMFS existence is possibility to call side-functions
131  for any filesystem operation.
132  Let's call module with such functionality as SMFS plugin.
133  Each plugin is initialized via options when SMFS is mounted and corresponds
134  to certain method tables.
135  Plugins should register in SMFS using plugins API after that SMFS will
136  call their functions for specified filesystem operations.
137  
138 \layout Description
139
140 Upcalls - very similar with plugins but more generic.
141  Modules can use this API to place own hooks in SMFS.
142  It can be needed for notification or taking control from SMFS by upper-level.
143  
144 \layout Section
145 \pagebreak_top 
146 High Level Design
147 \layout Subsection
148
149
150 \noun on 
151 Functional Specification
152 \layout Subsubsection
153
154 Backstore FS operations
155 \layout Standard
156
157 SMFS creates copy of backstore FS objects when needed but setup own super/inode/
158 file operations and save pointer to original one.
159  SMFS should not affect the Lustre IO path.
160  Backstore FS should remains operational in case of SMFS error as long as
161  it possible.
162 \layout Subsubsection
163
164 SMFS plugins/upcalls managment
165 \layout Standard
166
167 SMFS can registers/deregisters plugin.
168  Plugins are activated after SMFS initialization and can register own functions
169  in SMFS using special API.
170  
171 \layout Standard
172
173 All plugins are linked in the list and their functions are invoked for several
174  filesystem operations if defined.
175  
176 \layout Standard
177
178 Deactivated process starts when SMFS uninitialization occur or ioctl is
179  received from user.
180  Ioctl interface or procfs (sysfs later) can be used also for plugin management.
181 \layout Standard
182
183 Upcall are similar to plugins but more generic.
184  There is upcall API in SMFS.
185  Upcalls are also organized in linked list and called one by one where needed.
186  
187 \layout Subsubsection
188
189 SMFS plugin API
190 \layout Standard
191
192 Plugins should be able to register and deregister with SMFS.
193  For these purposes SMFS has two methods
194 \layout Standard
195
196
197 \noun on 
198 Prototype
199 \noun default 
200 :
201 \layout LyX-Code
202
203 int smfs_register_plugin(struct smfs_plugin);
204 \layout LyX-Code
205
206 int smfs_deregister_plugin(int type);
207 \layout Standard
208
209 Before calling this function plugin should fill struct smfs_plugin with
210  own data.
211  Registration process will check it and add to the list if possible.
212  Deregistration takes type of plugin, search it in list and delete it.
213 \layout Standard
214
215 Plugins can insert own function hooks into SMFS.
216  Two major functions that can be setted by plugins are pre- and post-hook.
217  They will be called before filesystem operation and after it.
218 \layout Standard
219
220
221 \noun on 
222 Prototype:
223 \layout LyX-Code
224
225 /* this is prototype for plugin hook */
226 \layout LyX-Code
227
228 int smfs_hook_func (int hook_opcode, void * parameters);
229 \layout Standard
230
231 Here we pass to plugin hook_opcode and several parameters.
232  For each opcode paramaters can be different.
233 \layout Standard
234
235
236 \emph on 
237 Hook_opcode
238 \emph default 
239  is a number from enumerated list of all possible operations where hooks
240  are used.
241 \layout Subsubsection
242
243 SMFS upcall API
244 \layout Standard
245
246 Plugin API is defined for using with filesystem operations specially.
247  For cases where more generic functionality is needed upcall API can be
248  used.
249  
250 \layout Standard
251
252
253 \noun on 
254 Prototype:
255 \layout LyX-Code
256
257 int smfs_upcall (int type, void * arg);
258 \layout Standard
259
260 Here 
261 \emph on 
262 type
263 \emph default 
264  is number from enumerated list of upcalls, 
265 \emph on 
266 arg
267 \emph default 
268  is parameter or structure with parameters related to this upcall.
269  Upcalls can be used for notification purposes.
270  Upcalls are also widely used with plugins to get some data from they or
271  do some action.
272 \layout Standard
273
274 Due to upcall origin there can be no some modules while SMFS already is
275  loaded.
276  Therefore it is possible that not all functionality presents at the moment.
277  Upcall API should notify caller about this.
278 \layout Subsection
279
280
281 \noun on 
282 Use cases
283 \layout Standard
284
285 There are several plugins that use plugin API.
286  They should fit in proposed API well.
287 \layout Subsubsection
288
289 KML
290 \layout Standard
291
292 KML module designed to support writeback caching.
293  KML is quite simple plugin that receive notification about FS operations
294  and write they to the log using llog API.
295 \layout Standard
296
297 KML use post_op function for logging, that are called after FS operations.
298  It should have also pre_ops for transaction handling.
299  The SMFS functionality is sufficient for it.
300  
301 \layout Subsubsection
302
303 LRU
304 \layout Standard
305
306 LRU is designed for cache management in local MDS on client, but can be
307  used also for HSM in future.
308  LRU module defines both pre_op and post_op.
309  Pre_op is quit simple and is used mostly to check do we need purge cache
310  or not.
311  Post_op does cache operations.
312  There is special thread for purging cache, it can be awaken from pre_op
313  but.
314  SMFS plugin API functionality is sufficient for this module.
315 \layout Subsubsection
316
317 COW
318 \layout Standard
319
320 This module supports snapfs working over SMFS.
321  This module use all functionality of SMFS plugin API - pre_op and post_op.
322  Meanwhile it doesn't need extra functionality and fits in existent API.
323 \layout Subsection
324
325
326 \noun on 
327 Logic Specification
328 \layout Subsubsection
329
330 Backstore FS operations
331 \layout Standard
332
333 For succefull functioning SMFS should maintain copies of many filesystem
334  objects such as superblock, inodes, files, etc.
335  and replace their operations with own.
336  Therefore each filesystem object in SMFS has its origin object in backstore
337  FS and there is pointer on it.
338  While operating SMFS should maintain own object in consistency with real
339  objects.
340 \layout Standard
341
342 Example of superblock operation handling:
343 \layout LyX-Code
344
345 smfs_dirty/write_inode(struct inode * inode)
346 \layout LyX-Code
347
348 {
349 \layout LyX-Code
350
351         /* getting saved backstore fs inode */
352 \layout LyX-Code
353
354         backfs_inode = I2CI(inode);
355 \layout LyX-Code
356
357         /* here can be some pre-work */
358 \layout LyX-Code
359
360         ...
361 \layout LyX-Code
362
363         /* call real operation */
364 \layout LyX-Code
365
366         backfs_sb->s_op->dirty/write_inode(backfs_inode);
367 \layout LyX-Code
368
369   
370 \layout LyX-Code
371
372         /* postprocessing */
373 \layout LyX-Code
374
375         duplicate_inode(inode, backfs_inode);
376 \layout LyX-Code
377
378 }
379 \layout Subsubsection
380
381 Fsfilt operations handlilng
382 \layout Standard
383
384 Fsfilt operations are handled like ordinary FS operations.
385  SMFS store fsfilt operations that corresponds to backstore FS, fsfilt module
386  just use operations declared for SMFS.
387  SMFS calls real operation with some framework.
388  There are several common steps to pass fsfilt operations to real FS:
389 \layout Itemize
390
391 get backfs sb and inode from SMFS struct inode
392 \layout Itemize
393
394 get backfs fsfilt_operations from superblock
395 \layout Itemize
396
397 call needed operation using backfs objects
398 \layout Standard
399
400 Transactions in SMFS are handled using fsfilter operation for backstore
401  FS.
402  SMFS make fs_start and fs_commit in all cases where it is needed.
403  Therefore these all extra changes will be included into current transaction:
404 \layout LyX-Code
405
406 smfs_trans_start()
407 \layout LyX-Code
408
409 ...
410 \layout LyX-Code
411
412 SMFS_HOOK()
413 \layout LyX-Code
414
415 ...
416 \layout LyX-Code
417
418 smfs_trans_commit()
419 \layout Standard
420
421 Transaction handler are passed to plugin in hook and can be used by plugin
422  to do proper transaction handling when it is needed.
423 \layout Subsubsection
424
425 SMFS plugin activation/deactivation
426 \layout Standard
427
428 Now all plugins are compiled in SMFS module and are initialized via options
429  when SMFS is mounting.
430  
431 \layout Standard
432
433 Options should be passed as mountfsoptions like this: 
434 \emph on 
435 ...
436  [kml|cache|snap...]
437 \layout Standard
438
439 SMFS parses module options and call initialization method for selected plugins.
440  It is possible to activate/deactivate plugins using ioctl (procfs or sysfs)
441  later.
442  
443 \layout Standard
444
445 While initialization plugins should registers with SMFS:
446 \layout LyX-Code
447
448 smfs_register_plugin(parameters);
449 \layout Standard
450
451 Parameters are struct smfs_plugin filled with valid data:
452 \layout Itemize
453
454 type of plugin - to distinguish it from anothers,
455 \layout Itemize
456
457 pre_op function - function that will be called before fs operation,
458 \layout Itemize
459
460 post_op function - function that will be called after fs operation,
461 \layout Itemize
462
463 helper function - helper function.
464  See Plugin API,
465 \layout Itemize
466
467 any private data - data which will be return to plugin in each call.
468 \layout Subsubsection
469
470 SMFS hook invokation
471 \layout Standard
472
473 SMFS place special wrapper in own filesystem operations to call plugins
474  hook:
475 \layout LyX-Code
476
477 /* wrapper that calls all hooks walking through the list */
478 \layout LyX-Code
479
480 #define SMFS_HOOK(opcode,...)    
481 \backslash 
482
483 \layout LyX-Code
484
485 do {                                                          
486 \backslash 
487
488 \layout LyX-Code
489
490        smfs_hooks_op * hops;                                  
491 \backslash 
492
493 \layout LyX-Code
494
495        ...
496                                                     
497 \backslash 
498
499 \layout LyX-Code
500
501        list_for_each_entry(plugin_list, hops, smh_list) {     
502 \backslash 
503
504 \layout LyX-Code
505
506               ...
507                                              
508 \backslash 
509
510 \layout LyX-Code
511
512               rc = hops->smh_hook_op(opcode, ...);            
513 \backslash 
514
515 \layout LyX-Code
516
517        }                                                      
518 \backslash 
519
520 \layout LyX-Code
521
522         ...
523                                                    
524 \backslash 
525
526 \layout LyX-Code
527
528 } while(0)     
529 \layout Standard
530
531 Hooks are placed in SMFS methods before and after calling backstore FS operation
532 s:
533 \layout LyX-Code
534
535 /* this is how to SMFS uses hooks */
536 \layout LyX-Code
537
538 smfs_some_op()
539 \layout LyX-Code
540
541
542 \layout LyX-Code
543
544         struct inode * backfs_inode = I2CI(inode);
545 \layout LyX-Code
546
547         struct smfs_file_info *sfi;
548 \layout LyX-Code
549
550        
551 \layout LyX-Code
552
553         SMFS_HOOK(..., hook_opcode , ..., PRE_HOOK, ...);
554 \layout LyX-Code
555
556         backfs_inode->i_fop->some_op(sfi->c_file, ...);
557 \layout LyX-Code
558
559         SMFS_HOOK(..., hook_opcode, ..., POST_HOOK, ...);
560 \layout LyX-Code
561
562
563 \layout Subsubsection
564
565 SMFS upcall usage
566 \layout Standard
567
568 Upcalls can be placed in any place in SMFS, where it is needed.
569 \layout LyX-Code
570
571 /* example of upcalls handling */
572 \layout LyX-Code
573
574 int smfs_upcall(int type, void * arg)
575 \layout LyX-Code
576
577 {
578 \layout LyX-Code
579
580         list_for_each(upcall_list)
581 \layout LyX-Code
582
583                 entry->upcall(type, arg);
584 \layout LyX-Code
585
586 }
587 \layout LyX-Code
588
589 \layout LyX-Code
590
591 /* example of using upcall  */
592 \layout LyX-Code
593
594 int check_uninitialization()
595 \layout LyX-Code
596
597 {
598 \layout LyX-Code
599
600         ...
601 \layout LyX-Code
602
603         smfs_upcall(SMFS_UP_SMTH, &parameter);
604 \layout LyX-Code
605
606         ...
607 \layout LyX-Code
608
609 }
610 \layout Section
611 \pagebreak_top 
612 Plugins API
613 \layout Subsection
614
615
616 \noun on 
617 Functional Specification
618 \layout Standard
619
620 Each plugin has own unique name and corresponding type.
621  There is enumerated list of plugins types.
622  Any new plugin should use next sequence number as type and name which not
623  used yet by other plugins.
624  SMFS exports two functions for plugins: 
625 \emph on 
626 smfs_register_plugin()
627 \emph default 
628  and 
629 \emph on 
630 smfs_deregister_plugin().
631
632 \emph default 
633  
634 \layout Standard
635
636 SMFS defines format of function that can be used by plugins to invoke own
637  methods.
638  Plugins should pass pointers on desired function while registration.
639 \layout Standard
640
641 After successfull registration plugin's function will be called when selected
642  FS operations are occur.
643  SMFS passes to plugin inode structre, dentry, hook opcode and fsfilt transactio
644 n handle if exists.
645  
646 \layout Standard
647
648 Plugin should return zero value in case of successfull completion and error
649  code otherwise.
650  Plugin should decide how to handle error by itself.
651  In case of critical error it can even stops operating or deregisters itself
652  from SMFS.
653  If plugin have no function for selected 
654 \emph on 
655 hook_opcode
656 \emph default 
657  it has to return also 
658 \emph on 
659 0.
660 \layout Subsection
661
662
663 \noun on 
664 Logic Specificaion
665 \layout Paragraph*
666
667 Plugin identification
668 \layout Standard
669
670 There are defined types of plugins:
671 \layout LyX-Code
672
673 #define SMFS_PLG_KML 0x01
674 \layout LyX-Code
675
676 #define SMFS_PLG_LRU 0x02
677 \layout LyX-Code
678
679 ...
680 \layout LyX-Code
681
682 \layout Paragraph*
683
684 Plugin data
685 \layout Standard
686
687 Main structure for communication between plugin and SMFS.
688  
689 \layout LyX-Code
690
691 struct smfs_plugin {
692 \layout LyX-Code
693
694         struct list_head plist;
695 \layout LyX-Code
696
697         int type;
698 \layout LyX-Code
699
700         smfs_hook_func * pre_op;
701 \layout LyX-Code
702
703         smfs_hook_func * post_op;
704 \layout LyX-Code
705
706         smfs_helper * helper;
707 \layout LyX-Code
708
709         void * plugin_data;
710 \layout LyX-Code
711
712 }
713 \layout Standard
714
715 Where 
716 \layout Itemize
717
718
719 \emph on 
720 type
721 \emph default 
722  - plugins type,
723 \layout Itemize
724
725
726 \emph on 
727 pre_hook_func
728 \emph default 
729  - function to handle pre-operations, 
730 \layout Itemize
731
732
733 \emph on 
734 post_hook_func
735 \emph default 
736  - function to handle post-hook operation,
737 \layout Itemize
738
739 helper - call to various helper functions needed by SMFS,
740 \layout Itemize
741
742 plugin_data - private plugin data.
743 \layout Paragraph*
744
745 Plugin registration
746 \layout Standard
747
748 SMFS provide following method for registration:
749 \layout LyX-Code
750
751 int smfs_register_plugin (struct smfs_plugin *);
752 \layout Standard
753
754 SMFS will return 0 in case of successfull registration or error code otherwise.
755  
756 \layout Subsubsection*
757
758 Plugin deregistration
759 \layout Standard
760
761 SMFS provide following method for deregistration:
762 \layout LyX-Code
763
764 void * smfs_deregister_plugin (int type);
765 \layout Standard
766
767 SMFS will return private plugin data from struct smfs_plugin in case of
768  successfull registration or NULL pointer otherwise.
769  
770 \layout Paragraph*
771
772 Plugins operation
773 \layout Standard
774
775 Plugin's hook function must have the same type:
776 \layout LyX-Code
777
778 typedef int (*smfs_plg_hook) (int opcode, void * parameter, void * plg_private);
779 \layout Standard
780
781 Parameter can contains:
782 \layout Itemize
783
784 inode - SMFS inode
785 \layout Itemize
786
787 dentry - SMFS dentry
788 \layout Itemize
789
790 new_inode - used in rename
791 \layout Itemize
792
793 new_dentry - used in rename
794 \layout Itemize
795
796 opcode - hook code
797 \layout Itemize
798
799 handle - fsfilt transaction if exists
800 \layout Standard
801
802
803 \emph on 
804 Plg_private 
805 \emph default 
806 is private plugin data.
807 \layout Standard
808
809 There are opcodes for now:
810 \layout LyX-Code
811
812 #define HOOK_CREATE       1
813 \layout LyX-Code
814
815 #define HOOK_LOOKUP       2
816 \layout LyX-Code
817
818 #define HOOK_LINK         3
819 \layout LyX-Code
820
821 #define HOOK_UNLINK       4
822 \layout LyX-Code
823
824 #define HOOK_SYMLINK      5
825 \layout LyX-Code
826
827 #define HOOK_MKDIR        6
828 \layout LyX-Code
829
830 #define HOOK_RMDIR        7
831 \layout LyX-Code
832
833 #define HOOK_MKNOD        8
834 \layout LyX-Code
835
836 #define HOOK_RENAME       9
837 \layout LyX-Code
838
839 #define HOOK_SETATTR      10
840 \layout LyX-Code
841
842 #define HOOK_WRITE        11
843 \layout LyX-Code
844
845 #define HOOK_READDIR      12
846 \layout LyX-Code
847
848 #define HOOK_MAX          12
849 \layout Standard
850
851 Plugin may use opcode as index for array of some type.
852  It can be table of functions for each hook type for example:
853 \layout LyX-Code
854
855 static  cache_hook_op cache_space_hook_ops[HOOK_MAX + 1] = {
856 \layout LyX-Code
857
858         [HOOK_CREATE]     cache_space_hook_create,
859 \layout LyX-Code
860
861         [HOOK_LOOKUP]     cache_space_hook_lookup,
862 \layout LyX-Code
863
864         [HOOK_LINK]       cache_space_hook_link,
865 \layout LyX-Code
866
867         [HOOK_UNLINK]     cache_space_hook_unlink,
868 \layout LyX-Code
869
870         [HOOK_SYMLINK]    cache_space_hook_create,
871 \layout LyX-Code
872
873         [HOOK_MKDIR]      cache_space_hook_mkdir,
874 \layout LyX-Code
875
876         [HOOK_RMDIR]      cache_space_hook_rmdir,
877 \layout LyX-Code
878
879         [HOOK_MKNOD]      cache_space_hook_create,
880 \layout LyX-Code
881
882         [HOOK_RENAME]     cache_space_hook_rename,
883 \layout LyX-Code
884
885         [HOOK_SETATTR]    NULL,
886 \layout LyX-Code
887
888         [HOOK_WRITE]      NULL,
889 \layout LyX-Code
890
891         [HOOK_READDIR]    NULL,
892 \layout LyX-Code
893
894 };
895 \layout Subsubsection*
896
897 Helpers
898 \layout Standard
899
900 Plugins can register helper function.
901  There are several places where helpers are needed:
902 \layout Itemize
903
904 smfs uninitialization - after deleting plugin from list it can be usefull
905  to invoke plugin deactivation
906 \layout Itemize
907
908 init_inode_info - several plugins can need to initialize own info on per-inode
909  basis
910 \layout Itemize
911
912 calculate size for transaction - if plugin will participate into transaction
913  it should return extra size value.
914 \layout Itemize
915
916 etc.
917 \layout LyX-Code
918
919 smfs_helper(int code, void * parameter, void * plg_private);
920 \layout Standard
921
922 Where 
923 \emph on 
924 code
925 \emph default 
926  is type of helper:
927 \layout LyX-Code
928
929 #define SMFS_HLP_EXIT   0x01
930 \layout LyX-Code
931
932 #define SMFS_HLP_INODE  0x02
933 \layout LyX-Code
934
935 #define SMFS_HLP_TSIZE  0x03
936 \layout Subsection
937
938
939 \noun on 
940 Use cases
941 \layout Standard
942
943 SMFS returns zero value in case of successfull registration/deregistration
944  or error code otherwise.
945 \layout Standard
946
947 Plugins will return zero value in case of successfull execution hook function
948  or error code otherwise.
949 \layout Paragraph*
950
951 New plugin design example
952 \layout LyX-Code
953
954 //add new type
955 \layout LyX-Code
956
957 #define SMFS_PLG_NEW 0x03
958 \layout LyX-Code
959
960 \layout LyX-Code
961
962 //prepare hook functions
963 \layout LyX-Code
964
965 int new_plugin_pre_function(int opcode, void * parameter) 
966 \layout LyX-Code
967
968 {
969 \layout LyX-Code
970
971         //let it be just statistic collector
972 \layout LyX-Code
973
974         array[opcode]++;
975 \layout LyX-Code
976
977 }
978 \layout LyX-Code
979
980 \layout LyX-Code
981
982 int new_plugin_init ()
983 \layout LyX-Code
984
985 {
986 \layout LyX-Code
987
988         struct smfs_plugin data;
989 \layout LyX-Code
990
991         //prepare data
992 \layout LyX-Code
993
994         data.type = SMFS_PLG_NEW;
995 \layout LyX-Code
996
997         data.pre_op = &new_plugin_pre_function;
998 \layout LyX-Code
999
1000         data.post_op = NULL;
1001 \layout LyX-Code
1002
1003         //regisration here
1004 \layout LyX-Code
1005
1006         err = smfs_register_plugin(&data);
1007 \layout LyX-Code
1008
1009 \layout LyX-Code
1010
1011 }
1012 \layout Section
1013 \pagebreak_top 
1014 Upcall API
1015 \layout Standard
1016
1017 SMFS provides the ability to place a call to other modules.
1018  This can be needed when some notification needed from SMFS for example.
1019 \layout Standard
1020
1021 There are quite a few things to keep in mind:
1022 \layout Enumerate
1023
1024 The module that causes the mount of smfs, like the low level OSS and MDS
1025  server will want to register methods for upcalls.
1026 \layout Enumerate
1027
1028 Other modules that are not mounting need to be able to find smfs and register
1029  upcall methods.
1030 \layout Enumerate
1031
1032 When these registration of upcall methods have not happened, we should get
1033  reasonable error handling.
1034  Oopses and hangs are not permitted.
1035 \layout Subsection
1036
1037
1038 \noun on 
1039 Functional Specification
1040 \layout Standard
1041
1042 We can use mechanism similar to plugin API but it is more generic.
1043  Upcall is invoked in particular place or when some conditions are occure.
1044  So each upcall has own type.
1045  There can be several upcalls with one type simultaneously.
1046  Therefore we can introduce set of types for various upcalls and make generic
1047  call function like 
1048 \emph on 
1049 smfs_upcall(int type, void * arg)
1050 \emph default 
1051 .
1052  Module should register upcall handler in SMFS with help of registering
1053  function.
1054  SMFS has list of upcalls and will call functions for each upcall type walking
1055  through list.
1056  
1057 \layout Subsection
1058
1059
1060 \noun on 
1061 Logic Specification
1062 \layout Standard
1063
1064 There are defined types of upcalls:
1065 \layout LyX-Code
1066
1067 #define SMFS_UP_SMTH 0x01
1068 \layout LyX-Code
1069
1070 #define SMFS_UP_...
1071   0x02
1072 \layout LyX-Code
1073
1074 ...
1075 \layout LyX-Code
1076
1077 \layout Standard
1078
1079 SMFS provide following method for registration/deregistration:
1080 \layout LyX-Code
1081
1082 int smfs_register_upcall (struct smfs_upcall *);
1083 \layout LyX-Code
1084
1085 int smfs_deregister_upcall (struct smfs_upcall *);
1086 \layout Standard
1087
1088 SMFS will return 0 in case of successfull registration or error code otherwise.
1089 \layout Standard
1090
1091 SMFS will invoke function for each upcall:
1092 \layout LyX-Code
1093
1094 typedef int smfs_upcall_func (int upcall_type, void * arg);
1095 \layout Standard
1096
1097 Here:
1098 \layout Itemize
1099
1100 upcall_type - upcall type.
1101  It is define where upcall was invoked and under what conditions;
1102 \layout Itemize
1103
1104 arg - any desired arguments.
1105 \layout Subsection
1106
1107
1108 \noun on 
1109 Use cases
1110 \layout Standard
1111
1112 SMFS returns zero value in case of successfull registration/deregistration
1113  or error code otherwise.
1114 \layout Standard
1115
1116 Modules should be aware about conditions under what upcall is called - locking,
1117  for example.
1118  
1119 \the_end